[xsl] Rename Some Node ans attribute

Subject: [xsl] Rename Some Node ans attribute
From: Davide Antoni <davide.antoni@xxxxxxxxxxx>
Date: Mon, 16 Oct 2006 15:39:27 +0200
Hi to all

I need to change this xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ser="http://services.standardcup.esel.it";>
<soapenv:Body>
<ser:RICHIESTA_PRESTAZIONI_EROGABILI DataOra="10102005" idCup="1" idOperatore="1"/>
</soapenv:Body>
</soapenv:Envelope>


into this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ser="http://regione.campania.it/schemas/cup";>
<soapenv:Body>
<ser:ELENCO_PRESTAZIONI DataOra="?" idCUP="?" idOperatore="?">
<ser:PRESTAZIONE/>
</ser:ELENCO_PRESTAZIONI>
</soapenv:Body>
</soapenv:Envelope>


Pay attention on idCup that must be idCUP on the trasformation: i have this fot do it:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns="http://services.standardcup.esel.it"; xmlns:cup="http://services.standardcup.esel.it";>
<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>
<!--
most stuff you want to copy:
-->
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*[name()!='idCup']"/>
<xsl:if test="@idCup">
<xsl:attribute name="idCUP">
<xsl:value-of select="@idCup">
</xsl:value-of>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


</xsl:stylesheet>

Many thanks.

Current Thread