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

Applying transforms to parent nodes based on child nod

Subject: Applying transforms to parent nodes based on child node
From: "Derek Hinchliffe" <dhinchliffe@xxxxxxxxxx>
Date: Wed, 21 Jan 2004 12:21:10 +0800
xslt copy
Hi all,

I'm am trying to use XSLT to modify certain nodes of an XML document. 

For the most part, nodes are just copied using copy-of, except when they
contain an attribute of style='strip', in which case only the CDATA is
copied, thus stripping the XML tags away.

This seems fairly simple, as is so far achieved with:
<!--Snippet-->
        <xslt:template match="*[@style='strip']">
                <xslt:value-of select="."/>
        </xslt:template>

        <xslt:template match="*">
                <xslt:copy>
                        <xslt:copy-of select="@*" />
                        <xslt:apply-templates />
                </xslt:copy>
        </xslt:template>
<!--Snippet-->

However, now I want to also strip the tags from the parent of the node
with style='strip'.

Example:
----------------
<root>
	<item>Don't remove these tags</item>
	<item>Remove <subitem style="strip">these tags</subitem></item>
</root>

would become:

<root>
	<item>Don't remove these tags</item>
	Remove these tags
</root>
-----------------

I'm fairly new to XSLT, and it seems like all the examples and tutorials
around deal with different use cases than mine (usually grabbing data
and formatting it, rather than just making modifications to small parts
of the XML document).

I'm guessing it has something to do with using the Parent:: axis, but I
can't figure out how to go about it, so any help would be appreciated.

Cheers
Derek



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.