RE: [xsl] copy attribute question

Subject: RE: [xsl] copy attribute question
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Tue, 24 Mar 2009 23:19:15 +0100
Hi Garvin,

Templates for attributes are not called by default. Make sure you do
<xsl:apply-templates select="@*" /> or <xsl:apply-templates select="@*|node()"
/> from 'outside' the template. An <xsl:apply-templates /> actually means
<xsl:apply-templates select="node()" />..

Kind regards,
Geert

>


Drs. G.P.H. Josten
Consultant


http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - is afkomstig van
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit
bericht kunnen geen rechten worden ontleend.


> From: Garvin Riensche [mailto:g.riensche@xxxxxxx]
> Sent: dinsdag 24 maart 2009 23:14
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] copy attribute question
>
> Hello,
>
> I am wondering why the context seems to be different in the
> following templates because I thought the output would be the same.
>
> Input:
> <a id="1"/>
>
> Template 1:
> <xsl:template match="a/@*">
>    <aa>
>      <xsl:copy/>
>    </aa>
> </xsl:template>
>
> Template 2:
> <xsl:template match="a">
>    <xsl:for-each select="@*">
>      <aa>
>        <xsl:copy/>
>      </aa>
>    </xsl:for-each>
> </xsl:template>
>
> Template 1 doesn't produce any output and template 2 outputs:
> <aa id="1"/>
>
> Why doesn't Template 1 copy the attribute node to element
> <aa> like template 2?
>
>
> regards,
> Garvin

Current Thread