Re: [xsl] copy attribute question

Subject: Re: [xsl] copy attribute question
From: Garvin Riensche <g.riensche@xxxxxxx>
Date: Wed, 25 Mar 2009 00:06:02 +0100
Michael Kay schrieb:
If template 1 doesn't produce any output that's because it's not being
invoked. Where is the apply-templates call that selects a node that it would
match?
There is none. So the default apply-templates is used which doesn't select template 1 because it matches an attribute node.

regards,
Garvin


Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: Garvin Riensche [mailto:g.riensche@xxxxxxx] Sent: 24 March 2009 22: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