xsl-list
[Top] [All Lists]

Re: [xsl] The identity transform and attributes

2008-01-21 14:39:15
On Mon, Jan 21 2008 17:15:39 +0000, colinpauladams(_at_)googlemail(_dot_)com 
wrote:
...
Here's a version that might be more understandable to a beginner (IMHO):

     <xsl:template match="child::*">

Except that in XSLT 2.0, this could also match a parentless element
node.

Arguably, you wouldn't want to talk too much about parentless nodes
straight away, though in any introductory history of the XSLT standards
there's a good chance the concept would be mentioned as one of the
things added in XSLT 2.0.

Michael Kay's version from this morning is (unsurprisingly) clearer for
expressing an XSLT 2.0 identity transform.  IMO, trying to cover both
XSLT versions at once is counterproductive since it's easy enough to
have two version-specific boilerplates that you copy as needed.

         <xsl:copy>
             <xsl:apply-templates select="attribute::*|child::node()"/>
          </xsl:copy>
     </xsl:template>

     <xsl:template
match="attribute::*|text()|comment()|processing-instruction()">

Why not 'child::text()', etc., here if it made it more understandable
above?

         <xsl:copy/>
     </xsl:template>

Regards,


Tony Graham.
======================================================================
Tony(_dot_)Graham(_at_)MenteithConsulting(_dot_)com   
http://www.menteithconsulting.com

Menteith Consulting Ltd             Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
----------------------------------------------------------------------
Menteith Consulting -- Understanding how markup works
======================================================================

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--