xml - Can an XSLT 2.0 function return arbitrary types? -


i trying write xslt 2.0 function returns result of specific type--let's 1 or more elements. here's i've tried, 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's error saxon processor:

error @ xsl:function on line 192 column 65 of file:/e:/mlsh/recursive.xsl:   xtte0780: required item type of result of function util:find-parents2() element(parent,   xs:anytype); supplied value has item type text() failed compile stylesheet. 1 error detected. 

but expected this:

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

what missing here? thought had specified appropriate type $output (one or more <parent> elements), processor isn't getting message , seeing text. how can return list of <parent> elements here? in advance...

update:

summarizing, answer question in title 'yes'. key in original example difference between <xsl:value-of> , <xsl:sequence>. replacing former latter 1 way desired behavior. way 'unwrap' contents <xsl:variable> element, makes things bit tidier:

  <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> 

thanks michael , jim catching original oversight...

i believe problem should remove final <xsl:value-of...>. value-of produces text node, not want. sequence constructor contains nodes want output.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -