|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Creating a node from a variable
[Alessio Mazzieri]
> is there a method to create a node using the content of an <xsl:variable>?
>
> Something like this (but, unfortunately, not this!)
>
> <xsl:variable name="nodename">
> SomeName
> </xsl:variable>
>
> <xsl:element name="$nodename"/>
>
> The desidered output is
>
> <SomeName/>
>
> in the produced document.
You almost have it. You want to use
<xsl:element name="{$nodename}"/>
This use of braces ({}) is called an "attribute value template".
ALSO, you can't have any whitespace in an element name, so you should write
<xsl:variable name="nodename">SomeName</xsl:variable>
instead of what you had. Or even more trouble-free and compact:
<xsl:variable name="nodename" select='"SomeName"'/>
Note that "SomeName" is in (double) quotes to make it a string instead of
the name of an element (otherwise you would get a set of all the "SomeName"
nodes, which is not what you want). It may be hard to see that in the
example, depending on your display font.
Cheers,
Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








