Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Selectively =?utf-8?Q?=22delete=22?= elements/attributes from the output

From: avo@-------------
To:
Date: 12/1/2005 4:53:00 AM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent