[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
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
|
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
|