Altova Mailing List Archives

Re: [xsl] transformation does happen after copy-of?

From: Jeni Tennison <jeni@---------------->
Date: 7/23/2002 4:23:00 AM
Hi Andrew,

> DC wrote:
>>no node() does match attribute nodes.
> This is interesting - can you show an example, because I from that
> would read that I could drop the @* match like this:
> <xsl:template match="node()">
>   <xsl:copy>
>     <xsl:apply-templates select="@*|node()"/>
>   </xsl:copy>
> </xsl:template>
> Which you can't - what am I missing?

David C.'s being a little pedantic (now there's a surprise) and saying
that the *node test* "node()" matches attribute nodes. He's not saying
that the *pattern* "node()" matches attribute nodes.

The *pattern* "node()" as in:

<xsl:template match="node()">

is actually a shorthand for the pattern "child::node()", and matches
any node that is a child of another node. Attributes aren't children
of any other nodes, so they don't match this pattern.

However, if you use the pattern "attribute::node()" (or @node()) then
that will match any node that is an attribute of another node, and
will therefore match attributes. This is because the node test
"node()" matches all nodes, including attributes.

The same goes for expressions: the expression "node()" is a shorthand
for the expression "child::node()" and will select all child nodes of
the context node. The expression "attribute::node()" or "@node()" will
select all attributes of the context node; since only attributes are
attributes of a node, it's equivalent to do "@*", which has the
benefit of being shorter, so that's what we use most of the time.



Jeni Tennison

 XSL-List info and archive:


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.