在xpath中连接两个字符串序列

时间:2013-08-26 13:47:02

标签: xslt xpath

如何在xpath 2.0中创建两个字符串序列的并集?

有这两个功能......

<xsl:function name="my:foo" as="xs:string*">
    ....
</xsl:function>

<xsl:function name="my:bar" as="xs:string*">
    ....
</xsl:function>

我想迭代两个结果字符串序列,如:

<xsl:variable name="myResult" select="for $s in my:foo() ??union?? my:bar() return my:doSomethingWith($s)" />

1 个答案:

答案 0 :(得分:5)

刚刚在“XSLT 2.0和XPath 2.0第4版”,第10章“逗号运算符”一书中找到答案:

  

«,»运算符的操作数可以是任意两个序列。当然,单个项目本身就是一个序列,   所以操作数也可以是单个项目。任何一个序列都可以是空的,在这种情况下是结果   表达式是另一个操作数的值。

所以它看起来像:

<xsl:variable name="myResult" select="for $s in (my:foo(), my:bar()) return my:doSomethingWith($s)" />