normalize-space()不起作用

时间:2015-06-17 17:19:40

标签: xslt xslt-2.0

版本1.0有xslt代码,但我想将其转换为2.0版。

 <xsl:value-of select="normalize-space(round((. - $var1) div $var2))"/>

但是当我尝试运行它时,SAXON输出是:

F [Saxon-HE 9.5.0.2] XPTY0004: Required item type of first argument of normalize-space() is xs:string; supplied value has item type numeric

帮我找到并解决这个问题?提前致谢。

1 个答案:

答案 0 :(得分:1)

正如错误消息所提到的,normalize-space期望字符串作为参数,但round返回一个数值。虽然数字实际上没有空格,因此无需在结果上使用normalize-space

这应该起作用:

<xsl:value-of select="round((. - $var1) div $var2)"/>