[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Identity Transform

Subject: Re: Identity Transform
From: Adam Turoff <ziggy@xxxxxxxxx>
Date: Mon, 22 Sep 2003 17:10:09 -0400
identity transform
On Mon, Sep 22, 2003 at 08:28:57PM +0000, Abie Hamaoui wrote:
> hello there,
> why does the standard identity transform use copy instead of copy-of?
> ie:
>  <xsl:template match="/ | @* | node()">
>    <xsl:copy>
>      <xsl:apply-templates select="@* | node()"/>
>    </xsl:copy>
>  </xsl:template>
>
> instead of just
>  <xsl:template match="/">
>    <xsl:copy-pf select="."/>
>  </xsl:template>

xsl:copy-of is a deep copy of a node and its descendants.  using xsl:copy
instead recursively visits the entire document, while your xsl:copy-of
template visits only the root node and copies it in its entirety, as-is.

Using the identity transform, I can have other templates in my
stylesheet, such as:

	<!-- relabel <foo> to become <bar> -->
	<xsl:template match="foo">
	 <bar>
	  <xsl:apply-templates select="@* | node()"/>
	 </bar>
	</xsl:template>

	<!-- prune nodes -->
	<xsl:template match="text() | baz | quuz"/>

	<!-- copy children, selectively delete attributes -->
	<xsl:template match="para">
	 <xsl:copy>
	  <xsl:apply-templates select="@*[name(.) != 'id'] | node()"/>
	 </xsl:copy>
	</xsl:template>

Additionally, xsl:copy-of doesn't give the XSLT processor a chance
to do any optional decoration, like <xsl:output method="xml" indent="yes"/>

Z.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.