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
> 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:

  <someothertag>blah blah</someothertag>

applying this stylesheet:

<xsl:stylesheet xmlns:xsl="";

  <xsl:template match="doc">
    <xsl:element name="result">

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


produces this result:

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


- Kevin

Kevin Williams
XML Architect
Ultraprise Corporation

 XSL-List info and archive:

Current Thread