[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] [XPath 3.0] Can anonymous functions return markup?


Subject: RE: [xsl] [XPath 3.0] Can anonymous functions return markup?
From: Jakub Malý <jakub@xxxxxxx>
Date: Sun, 16 Dec 2012 23:41:31 +0100

I think only XQuery/XSLT functions can create new elements. 

There was a debate a few month ago regarding creating new elements in XPath
functions: 
http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201208
/msg00170.html

You may also find interesting Eric van der Vlist's suggestion for a new
syntax for writing values of @select in XSLT
https://www.w3.org/Bugs/Public/show_bug.cgi?id=18973

-----Original Message-----
From: Costello, Roger L. [mailto:costello@xxxxxxxxx] 
Sent: Sunday, December 16, 2012 11:07 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] [XPath 3.0] Can anonymous functions return markup?

Hi Folks,

I want to create an anonymous XPath function that returns markup. For
example:

         let $print := function ()
                              {
                                  <hello>World</hello>
                              }
         return ($print())

I tried embedding that XPath within an xsl:sequence element:

      <xsl:sequence select="
         let $print := function ()
                              {
                                  <hello>World</hello>
                              }
         return ($print())
         " />

but that produced this error message:

    The value of attribute "select" associated with an element 
    type "xsl:sequence" must not contain the '<' character.

So I escaped the '<' characters:

      <xsl:sequence select="
         let $print := function ()
                              {
                                  &lt;hello>World&lt;/hello>
                              }
         return ($print())
         " />

and that produced this error message:

    Unexpected token "<" in path expression

Is it possible to create an anonymous function that returns markup? 

If yes, how?

/Roger


Current Thread
Keywords