creating an element at runtime to pass into a template

B

Biff Malone

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

Martin Honnen

Biff said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top