Re: Global change of an attribute name

Subject: Re: Global change of an attribute name
From: Sebastian Rahtz <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jun 2000 15:55:39 +0100 (BST)
Chris Powell writes:
 > 
 > I am using XSLT to change XML in one DTD to XML in a slightly modified
 > DTD.  In the original DTD, the attribute R can appear on virtually any
 > element; I would prefer that the attribute be called REND.  Is there a way
 > to change this globally anywhere it appears (<xsl:template match="@R">, I
 > presume), or does it have to be adressed on an element by element level?

depends how you copy the attributes. if you use xsl:copy, the
template will not fire. I do something like this, to get a handle on
the attributes:

<xsl:template match="*">
 <xsl:element name="name()">
   <xsl:apply-templates select="@*"/>
   <xsl:apply-templates/>
 </xsl:element>
</xsl:template>


<xsl:template match="@*">
 <xsl:variable name="attname" select="name()"/>
 <xsl:choose>
    <xsl:when test="........."> ...... </xsl:when><!-- exception -->
    <xsl:otherwise>
     <xsl:copy/>
    </xsl:otherwise>
 </xsl:choose>
</xsl:template>


which I guess would work in your situation too

Sebastian


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


Current Thread