2013-08-26 34 views
4

如何在xpath 2.0中創建兩個字符串序列的並集?在xpath中加入兩個字符串序列

有了這兩個功能......

<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)" /> 

回答

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)" />