creating an element at runtime to pass into a template

Discussion in 'XML' started by Biff Malone, Oct 29, 2003.

  1. Biff Malone

    Biff Malone Guest

    I'm creating an element at run time with the following code

    <xsl:variable name="myElement">
    <xsl:element name="abc">
    <xsl:value-of select="." />
    </xsl:element>
    </xsl:variable>

    <xsl:call-template name="myTemplate">
    <xsl:with-param select="$myElement">
    </xsl:call-template>

    But XML Spy gives me a "Error in XPath expression, Cannot use result
    tree fragment"
    I can do a <xsl:value-of select="$myElement" /> but I can't pass the
    newly created element as a parameter.

    Does anyone know of a solution?
     
    Biff Malone, Oct 29, 2003
    #1
    1. Advertising

  2. Biff Malone wrote:

    > I'm creating an element at run time with the following code
    >
    > <xsl:variable name="myElement">
    > <xsl:element name="abc">
    > <xsl:value-of select="." />
    > </xsl:element>
    > </xsl:variable>
    >
    > <xsl:call-template name="myTemplate">
    > <xsl:with-param select="$myElement">
    > </xsl:call-template>
    >
    > But XML Spy gives me a "Error in XPath expression, Cannot use result
    > tree fragment"
    > I can do a <xsl:value-of select="$myElement" /> but I can't pass the
    > newly created element as a parameter.
    >
    > Does anyone know of a solution?


    This is a known restriction in XSLT 1.0, however many XSLT processors
    provide an extension function to convert a result tree fragment to a
    node set, see
    http://www.exslt.org/exsl/functions/node-set/index.html
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Oct 29, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keith
    Replies:
    9
    Views:
    2,156
    Graham Underwood
    Aug 8, 2008
  2. HANM
    Replies:
    2
    Views:
    767
    Joseph Kesselman
    Jan 29, 2008
  3. Mike N.
    Replies:
    3
    Views:
    593
    Joseph Kesselman
    Mar 17, 2008
  4. CRPietschmann
    Replies:
    1
    Views:
    268
    marss
    Apr 28, 2006
  5. Replies:
    1
    Views:
    158
    David Mark
    Oct 2, 2007
Loading...

Share This Page