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

RE: Copying most of an XML document

Subject: RE: Copying most of an XML document
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 23 Aug 2005 09:16:24 +0100
copying xml document
The classic design pattern for this a stylesheet that contains

(a) an identity template

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

(b) an extra template for the elements you want to remove or modify

<xsl:template match="caterpillar"/>

Michael Kay 

> -----Original Message-----
> From: Trevor Nicholls [mailto:trevor@xxxxxxxxxxxxxxxxxx] 
> Sent: 23 August 2005 02:20
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Copying most of an XML document
> Hello
> Given an original XML document that I need to process in 
> several different
> ways I am finding the job much more difficult than it needs 
> to be, I think,
> because the file contains a lot of "noise". I want to use XSL 
> to clean the
> file up in a first pass so that it will be simpler to process 
> later on.
> Here is my magnolia tree - I need it copied exactly but I 
> want to remove
> every caterpillar. Unfortunately it is infested with caterpillars
> throughout.
> Basically I want to do something like copy every single node, 
> children and
> attributes and all, but whenever I find (e.g.) an <a> node I 
> want to ignore
> it. If I could somehow tell 'xsl:copy-of' what to ignore that 
> would be all I
> needed (but I can't). If I knew the full structure of the file I could
> create templates to match and replicate all the nodes I wanted to keep
> without losing any of their attributes, but sadly this XML has been
> generated by Framemaker (from unstructured original 
> documents) and there is
> no document definition to work from.
> I'm hoping there is an XSL solution to this.
> Cheers
> Trevor

Current Thread


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.
First Name
Last Name
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.