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

Re: Selectively "delete" elements/attributes from the

Subject: Re: Selectively "delete" elements/attributes from the output
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Thu, 01 Dec 2005 16:37:03 +1100
xsl delete element
yes
If you have this template:

<xsl:template match="@*|node()" priority="-1">
   <xsl:copy>
      <xsl:apply-templates select"@*|node()"/>
   </xsl:copy>
<xsl:template>

it should pick up all templates that are not catered for by another template and copy them over.

Cheers.

Kamal.

avo@xxxxxxxxxxxxx wrote:

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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