[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Creating a node from a variable

Subject: Re: Creating a node from a variable
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Mon, 3 Dec 2001 11:38:00 -0500
xsl creating a node
[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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.