I need to be able to remove a specific parent node (and its children) depending on the attributes contained within the child element <version>
of the paragraph. So in the below example, i need XSLT to find the instance of <version version="ABCD">
and remove everything from the parent <para0>
element. In other words i'm trying to accomplish conditional text filtering. The element i need to match (and remove) will ALWAYS be the parent of <applic>
but might not always be a <para0>
as in the example, so i need to specify somehow that it needs to match the parent of the 'applic' element rather than explicitly specify the para0.
It should be clearer from the example. I need to remove all the para0 data with a version attribute of ABCD.
So this is some sample XML
<root>
<para0>
<applic>
<model>
<version version="ABCD"></version>
</model>
</applic>
<subpara1><title>First Title</title>
<para>Some text relating to ABCD configuration</para>
</subpara1>
<subpara1><title>Second Title</title>
<para>Some other text and stuff relating to ABCD configuration</para>
</subpara1>
</para0>
<para0>
<applic>
<model>
<version version="TRAINING"></version>
</model>
</applic>
<subpara1><title>First Title</title>
<para>Some text relating to TRAINING configuration</para>
</subpara1>
<subpara1><title>Second Title</title>
<para>Some other text and stuff relating to TRAINING configuration</para>
</subpara1>
</para0>
</root>
Here is the XSLT i have so far, but i need it, once matched to ABCD, to basically select and delete the parent of 'applic' and all the child nodes.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "xml" indent="yes"/>
<xsl:strip-space elements = "*" />
<xsl:template match = "@*|node()" >
<xsl:copy>
<xsl:apply-templates select = "@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match = "//applic/model[@*]/version[@version='ABCD']" />
</xsl:stylesheet>