[xsl] Copying most of an XML document

Subject: [xsl] Copying most of an XML document
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Tue, 23 Aug 2005 13:20:15 +1200
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