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

RE: How do I reference the name of a tag?

Subject: RE: How do I reference the name of a tag?
From: Kevin Williams <Kevin.Williams@xxxxxxxxxxxxxx>
Date: Wed, 31 May 2000 15:43:43 -0400
reference by name
> From: jhbooth@xxxxxxxxxxxxx [mailto:jhbooth@xxxxxxxxxxxxx]

> how can I get at the expanded-name of sometag and someothertag?

Ah, the dreaded attributes-vs-elements issue. This works:

For this document:

<doc>
  <sometag>blah</sometag>
  <someothertag>blah blah</someothertag>
</doc>

applying this stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

  <xsl:template match="doc">
    <xsl:element name="result">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="doc/*">
    <xsl:element name="attribute">
      <xsl:attribute name="name">
        <xsl:value-of select="name()"/>
      </xsl:attribute>
      <xsl:element name="value">
        <xsl:value-of select="./text()"/>
      </xsl:element>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

produces this result:

<result>
  <attribute name="sometag"><value>blah</value></attribute>
  <attribute name="someothertag"><value>blah blah</value></attribute>
</result>

HTH...

- Kevin

Kevin Williams
XML Architect
Ultraprise Corporation


 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.