[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Creating a node from a variable
Subject: Re: [xsl] Creating a node from a variable From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx> Date: Mon, 3 Dec 2001 11:38:00 -0500 |
[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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Creating a node from a va, Jörg Heinicke | Thread | [xsl] select all nodes WITHOUT a sp, William Bagby |
Re: [xsl] Creating a node from a va, Jörg Heinicke | Date | Re: [xsl] building of a variable wh, Stephane . Le-Deaut |
Month |