Copying nodes depending on children values
The input XML needs to be refined to contain only nodes where the value element of a characteristics element where the name attibute is weight is greater than 15.
XML
<root>
<quality>
<batch id="1">
<characteristic name="weight">
<value>12</value>
</characteristic>
<characteristic name="length">
<value>45</value>
</characteristic>
<characteristic name="volume">
<value>67</value>
</characteristic>
</batch>
<batch id="2">
<characteristic name="weight">
<value>12</value>
</characteristic>
<characteristic name="weight">
<value>17</value>
</characteristic>
</batch>
<batch id="3">
<characteristic name="weight">
<value>56</value>
</characteristic>
<characteristic name="volume">
<value>65</value>
</characteristic>
</batch>
</quality>
</root>
XSL
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/root">
<quality>
<xsl:copy-of select="
quality/batch[characteristic[@name= 'weight' and value > 15]]
"/>
</quality>
</xsl:template>
</xsl:transform>
No comments:
Post a Comment