I am trying to work on this XML file where i would like to delete all the matching nodes based on the latest node value. In the following example the latest node value is "${DELETE}" Latest node value will be always "${DELETE}" and the node will be always at the bottom of an XML file.
Example:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<projects>
<project id="properties1">
<property name="prop1">some-value</property>
<property name="prop2">abc</property>
<property name="prop3">def</property>
</project>
<project id="properties2">
<property name="prop">testing prop from pom.xml</property>
<property name="prop1">${DELETE}</property>
<property name="prop4">abc</property>
<property name="prop5">xyz</property>
</project>
</projects>
Expected Output is:
<projects>
<project id="properties1">
<property name="prop2">abc</property>
<property name="prop3">def</property>
</project>
<project id="properties2">
<property name="prop">testing prop from pom.xml</property>
<property name="prop4">abc</property>
<property name="prop5">xyz</property>
</project>
</projects>
With XSLT 2.0 and an XSLT 2.0 processor you could use
With XSLT 1.0 you can't use a variable reference or path as the key argument in a match pattern so there you have to spell out the condition: