[xsl] The identity transform and attributes

Subject: [xsl] The identity transform and attributes
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 21 Jan 2008 10:28:42 +0000
I'm wondering if the default identity transform should be this:

<xsl:template match="@*|node()">
        <xsl:apply-templates select="@*|node()"/>

Or this:

<xsl:template match="node()">
        <xsl:apply-templates select="@*|node()"/>

<xsl:template match="@*">

The former is nice and compact, but when the node is an attribute node
does the apply-templates call have any effect - even if it's a few
clock cycles wasted?  It's a pointless instruction at that point.  I
guess it is too for non-element node()'s such as whitespace?

Also, the shallow copy copies the entire attribute, so there is no
opportunity to override the text() of the attribute.  The only way is
to add a separate matching template for the attribute - the latter
perhaps makes this a little clearer.

A useful distinction or a waste of time? :)

Andrew Welch
Kernow: http://kernowforsaxon.sf.net/

Current Thread