Below is the really simple transformation producing the wanted result of
global renaming a given attribute. It uses the most fundamental XSLT design
pattern -- overriding the identity rule.
A word of caution is that you haven't specified what to do in case of a
potential conflict -- such as when an element has both a "webclass" and a
"class" attribute.
When this transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@webclass">
<xsl:attribute name="class">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
is applied on this source xml:
<t>
<x webclass="a" myclass="b">
<y webclass="c" yClass="d"/>
<z/>
</x>
</t>
the wanted result is produced:
<t>
<x class="a" myclass="b">
<y class="c" yClass="d"></y>
<z></z>
</x>
</t>
Cheers,
Dimitre Novatchev.
"Martin Plantec" <ma************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi again,
If I may, I have another, slightly more complex, XSLT question. (I'm
learning, but it's not as easy as I would have thought!) I would like a
rule that says: for every element that has an attribute "webclass",
rename the attribute as "class", keeping the same value for the
attribute (and keeping the same element name). In other words, I would
like to rename an attribute, whatever the element it comes in.
I gather it is possible, but I had no luck so far with my tries.
Thanks,
Martin