Re: [xsl] Rename Some Node and attribute

Subject: Re: [xsl] Rename Some Node and attribute
From: Abel Braaksma <>
Date: Mon, 16 Oct 2006 18:27:25 +0200
Mukul Gandhi wrote:
Oops, I used the wrong namespace. The correct template is below..

On 10/16/06, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:

<xsl:template match="*[local-name() = 'RICHIESTA_PRESTAZIONI_EROGABILI']">
<ser:ELENCO_PRESTAZIONI xmlns:ser="";>
<xsl:copy-of select="@*[not(local-name() = 'idCup')]" />
<xsl:attribute name="idCUP"><xsl:value-of select="@idCup"/></xsl:attribute>
<xsl:apply-templates />

Just an opinion, but isn't it much easier to use xpath-default-namespace and friends to make it more readable? At least you would not have to deal with local-name() and all those complex constructs (well, 'complex' is a matter of taste, of course). Also, in the (rare case?) that you would use the above generalized template with node names that are the same, but in different namespaces, you would end up matching too much.

Something along the lines (but the default may be placed in the xsl:stylesheet decl as well):

<xsl:template match="RICHIESTA_PRESTAZIONI_EROGABILI" xpath-default-namespace=""; >

And by using copy-of, there's no opportunity to add new templates that apply to elements lying deeper in the nesting structure. Using apply-templates gives the possibility to extend this stylesheet with more overriding idiom. I would vote for the latter ;-)

-- Abel Braaksma

Current Thread