Attach two string sequences in xpath

How to create a union of two string sequences in xpath 2.0?

Having these two functions ...

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

I want to iterate both resulting string sequences, for example:

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

Just found the answer in the book "XSLT 2.0 and XPath 2.0 4th Edition", chapter 10 "Serif Operator":

The operands of the operator "," can be any two sequences. Of course, one element in itself is a sequence, so operands can also be separate elements. Any of the sequences may be empty, in which case the result of the expression is the value of the other operand.

So it will look like this:

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

Source: https://habr.com/ru/post/1498966/


All Articles