xsl-list
[Top] [All Lists]

Re: Testing attribute name and replacing them with other attribute name

2005-09-05 10:28:35
Hi,

Tempore 17:11:04, die 09/05/2005 AD, hinc in 
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Thomas Winkler 
<thomasm003(_at_)yahoo(_dot_)de>:

I want to find some attributes by name and then
replacing them with other attributes (actually doing
language transformation) :

for example

<tshirts size="XXL" brand="Nike" price="14">

should be changed into :

<tshirts länge="XXL" marke="Nike" preis="14">

How can this be done ?

This is a typical job for an identity transformation:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="node()|@*">
        <xsl:copy>
                <xsl:apply-templates select="node()|@*" />
        </xsl:copy>
</xsl:template>

<xsl:template match="@size">
        <xsl:attribute name="länge"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>

<xsl:template match="@brand">
        <xsl:attribute name="marke"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>

<xsl:template match="@price">
        <xsl:attribute name="preis"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>

</xsl:stylesheet>

But perhaps the language-string mapping is already done in some XML file. In 
that case, you load that in the XSLT.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
«Error, keyboard not found— press F1 to continue» , BIOS

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--