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

Understanding Identity Transformations

Subject: Understanding Identity Transformations
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Fri, 11 Feb 2005 15:56:58 -0700
xsl identity
Seems like this is pretty standard:

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

But then I've also seen this:

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

How do they compare?  I make not of the SAMPLE_001 within the xsl:copy
there are 2 apply templates, what does each do?

Then, understanding what is happening, is the following sample true
that this will strip an XML doc of all attribute elements?

SAMPLE_003:
<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates select="*"/>
  </xsl:copy>
</xsl:template>

And finally, when I identity transform the following my document i
quadrupled in size, but I though I was following standard practices
from previous example.

SAMPLE_004:
<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates select="*"/>
    <xsl:apply-templates />
  </xsl:copy>
</xsl:template>

Ahh, I think I understand what is going on in SAMPLE_004 (please
confirm) I am basically applying templates for all nodes twice and in
the case of lets say SAMPLE_001 the first apply-templates simply gets
all attributes, the 2nd then gets all nodes.  We'd call this a
recursive call on the node set?

Karl

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.