Subject: [xsl] Selectively "delete" elements/attributes from the output From: avo@xxxxxxxxxxxxx Date: Thu, 01 Dec 2005 04:52:39 +0000 |
I'm doing XML to XML transformation (newbie when it comes to XML and XSLT) Say I have an XML document like this <element1 att1="a" att2="b"> <element11>text1</element11> </element1> <element2>text2</element2> </root> I want to delete att1 and att2 from element1 so that output will look like this: <root> <element1> <element11>text1</element11> </element1> <element2>text2</element2> </root> I could write a template that call <xsl:copy-of select=3D"..." to basically copy everything except the two attributes there. But this is just small examples, with more complex XML files, where I want to delete things here and there, this becomes unscalable (the problem applies to both attributes elements, and text, not just attributes) Basically what I want to do is to have a template for each element/attribute that I want to "not copy" (delete), for ex: <xsl:template match=3D"root/element1/@att1"/> (doing nothing, essentially not copying the attribute over) Since the built-in templates for everything else do not copy the element nodes over (only text nodes are output), I have to provide templates for the rest to copy them over (not sure how to do this effectively, either), which is not very efficient. So my question comes down to: Can I provide rules for each of the thing I want to "delete", and then have one template to copy over everything else ~Anh
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] formatting lines to a fix, Kamal Bhatt | Thread | [no subject], Unknown |
Re: [xsl] Using contains in but nee, Kamal Bhatt | Date | [no subject], Unknown |
Month |