[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:59:17 +1000
xsl deep copy
Interesting variation of the identity transformation, I used the following code which worked!

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:html="http://www.w3.org/1999/xhtml">
<xsl:template match="/html:html">

<xsl:apply-templates select="html:body/node()" mode="identity"/>

</xsl:template>

<xsl:template match="node()|@*" mode="identity">

  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates mode="identity"/>
  </xsl:copy>

</xsl:template>
</xsl:stylesheet>


Thanks for the tip!




Robert Koberg wrote:
Hi,

You want to get to the body and then copy the elements. For example:

<xsl:template match="/html">

<xsl:apply-templates select="body" mode="identity"/>
</xsl:template>


<xsl:template match="node()|@*" mode="identity">

<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="identity"/>
</xsl:copy>
</xsl:template>


best,
-Rob



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Terence
Kearns
Sent: Tuesday, September 03, 2002 11:48 PM

Hi everyone, I just joined this list so "greetings". I joined because even after reading the entire http://www.dpawson.co.uk/xsl/sect2/N1930.html page on copying, and reading the reference on xsl:copy and xsl:copy-of I am still vexed by an annoying problem. I'm using XALAN through the ColdFusion MX implementation of their xmlTransform() function. I'm not sure exactly which version of Xalan that is.

I'm trying to deep copy [the _content_ of] an xhtml body element. I have users who enter arbitary HTML which I then pass through HTML TIDY which produces a nice well-formed XHTML document for me. I want to extract the body and store the content only.





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



--
my staff profile:
http://www.canberra.edu.au:8888/cn%3dKearns%20Mr%20T.%2c%20ou%3dClient%20Services%20Division%2c%20o%3dUniversity%20of%20Canberra%2c%20c%3dAU



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.