【问题标题】:Why does XSL/XPath think that this zero is a string?为什么 XSL/XPath 认为这个零是一个字符串?
【发布时间】:2019-06-19 14:00:09
【问题描述】:

执行此 XSLT 时:

<xsl:variable name="numDeps" select="count(wd:Deps)"/>
<xsl:variable name="depRelation_FieldMaxLength" select="16 * 2"/>
<xsl:variable name="relationFieldRemainingBlanks" select="$depRelation_FieldMaxLength - ($numDeps*2)"/>
<xsl:variable name="spacesNeeded" select="max(0, $relationFieldRemainingBlanks)"/>

它会产生错误:“检测到 1 个错误。max() 的第二个参数的必需项类型是 xs:string;提供的值具有项类型 xs:integer”这似乎表明 max() 的第一个参数是被解释为字符串,而不是整数。

为什么?

【问题讨论】:

    标签: xml xslt


    【解决方案1】:

    max 函数的第一个参数可以是max((0, $relationFieldRemainingBlanks)) 形式的值序列。通过您的调用,您尝试将max 应用于由0 值形成的序列,$relationFieldRemainingBlanks 被视为预期是排序规则的第二个(可选)参数(https://www.w3.org/TR/xpath-functions/#func-max)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多