[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Copying most of an XML document
> Here is my magnolia tree - I need it copied exactly but I want to remove > every caterpillar. Unfortunately it is infested with caterpillars > throughout. This is a very common question -- I swear it was even asked last week. You want to use the identity transformation and modify it slightly: http://www.w3.org/TR/xslt#copying <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="caterpillar" /> </xsl:stylesheet> This assume that you want to remove every "caterpillar" element along with its descendants. > 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. All you really need to know is the names of the elements and/or attributes you _don't_ want to keep. Dave
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|