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

Re: deep "copy-of" a source fragment

Subject: Re: deep "copy-of" a source fragment
From: Terence Kearns <terencek@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 05 Sep 2002 15:51:46 +1000
terence kearns
Please see post in response to Dave on the resolution to my problem...

I've included responses to this email below...

Peter Davis wrote:

<xsl:template match="/"> <xsl:copy-of select="html/body/node()"/> </xsl:template>

This works but only after I apply the namespaces as per the solution in my other post (replied to dave)

An alternative to using copy-of is to use the "identity template", which can look something like this (untested):

<!-- ignore all nodes unless otherwise specified -->
<xsl:template match="node()" priority="0"/>

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

You might want to go this route if you ever want to apply other templates to specific elements in the /html/body//* tree. Using xsl:copy-of doesn't allow you to modify the output of the copy with other templates. If you don't think you'll ever need to apply other templates, then copy-of should work fine.


Ah yes, I _will_ be attempting to apply other template rules to the content so I will definately take your advice on this one. Now that I have the namespaces sorted out, I should be able to easily apply the identity transformation method. Thanks for the tip!




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.