Xslt xsl:function定义的函数能否替代xpath 3.0内联函数?
我在xpath 3.0规范中使用了这个示例:Xslt xsl:function定义的函数能否替代xpath 3.0内联函数?,xslt,saxon,xslt-3.0,xpath-3.0,Xslt,Saxon,Xslt 3.0,Xpath 3.0,我在xpath 3.0规范中使用了这个示例: fn:fold-left(function($a, $b) { $a + $b }, 0, 1 to 5) 我试图用xsl:function定义的函数替换内联函数 <xsl:function name="ki:plus" as="xs:integer*"> <xsl:param name="a" as="xs:integer*"> <xsl:param name="b" as="xs:integer">
fn:fold-left(function($a, $b) { $a + $b }, 0, 1 to 5)
我试图用xsl:function定义的函数替换内联函数
<xsl:function name="ki:plus" as="xs:integer*">
<xsl:param name="a" as="xs:integer*">
<xsl:param name="b" as="xs:integer">
<xsl:value-of select="$a + $b">
</xsl:function>
但得到的错误是“左折叠的第一个参数不能是空序列
我做错了什么,还是这不可能
提前感谢。这里有一个正确的例子:
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:my="my:my">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:sequence select=
"fold-left(my:add#2, 0, 1 to 5)
"/>
</xsl:template>
<xsl:function name="my:add" as="xs:integer">
<xsl:param name="arg1" as="xs:integer"/>
<xsl:param name="arg2" as="xs:integer"/>
<xsl:sequence select="$arg1 + $arg2"/>
</xsl:function>
</xsl:stylesheet>
15
我必须承认我差点忘了这个问题。但是,知道这个问题很高兴。谢谢。@FredFinkle:不用客气。几天前我只是不小心碰到了“xpath 3.0”标记。