Can XSLT 2.0 function return arbitrary types?

I'm trying to write an XSLT 2.0 function that returns a result of a certain type — let one or more elements say. Here is what I tried, to no avail:

  <xsl:function name="util:find-parents2" as="element(parent)*">
    <xsl:variable name="output" as="element(parent)*">
      <xsl:for-each select="('one','two')">
        <parent>
          <xsl:sequence select="."/>
        </parent>
      </xsl:for-each>
    </xsl:variable>
    <xsl:value-of select="$output"/>
  </xsl:function>

Here is the error I get from the Saxon processor:

Error at xsl:function on line 192 column 65 of file:/e:/mlsh/recursive.xsl:
  XTTE0780: Required item type of result of function util:find-parents2() is element(parent,
  xs:anyType); supplied value has item type text() Failed to compile stylesheet. 1 error detected.

But I was expecting to get something like this:

<parent>one</parent>
<parent>two</parent>

What am I missing here? I thought I indicated the appropriate type for $ output (one or more elements <parent>), but the processor does not explicitly receive the message and only sees the text. How can I return a list of items <parent>here? Thanks in advance...

UPDATE:

, "". - <xsl:value-of> <xsl:sequence>. . "" <xsl:variable>, :

  <xsl:function name="util:find-parents2" as="element(parent)*">
    <xsl:for-each select="('one','two')">
      <parent>
        <xsl:sequence select="."/>
      </parent>
    </xsl:for-each>
  </xsl:function>

, ...

+3
1

, , <xsl:value-of...>. value-of node, , . , .

+3

All Articles