RE: [xsl] question about xsl:element names

Subject: RE: [xsl] question about xsl:element names
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Wed, 16 Apr 2003 15:47:10 -0600
> From: Calvin Smith [mailto:calvins@xxxxxxxxxxxxxxxxx]
> Sent: Wednesday, April 16, 2003 3:32 PM
> Subject: [xsl] question about xsl:element names
> 
> 
> Hi,
> 
> How can one create an element with a name that is not determined until
> runtime? I tried assigning to a variable and putting the 
> variable in the
> name attribute of xsl:element, but that doesn't work, and I 
> tried using
> the name function within the name attribute, since the name 
> of the element
> should be the name of another element, but that doesn't work either.
> 
> I've checked the FAQs that I'm aware of, and didn't see this question.
> Thanks in advance...

This is one of the few cases where you can use an attribute value template
(AVT) within an XSLT element:

<xsl:element name="{name()}">
  <!-- template-body -->
</xsl:element>

Note the curly braces around the name() function within the name attribute.
You can also assign the value of the namespace attribute in this manner.

Check out http://www.dpawson.co.uk/xsl/sect2/N1575.html and
http://www.dpawson.co.uk/xsl/sect2/N3257.html#d3243e40 for more info on
using AVTs.

hth,
b.

| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.708.7248 |
| cheap tickets, part of trip network                fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread