Reputation: 460
I have seen strange behavious, by strange mean it act as opposite to the conditions as we do in normally. following are the details:
XSLT Code
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:template match="child[@include='1']"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
Source XML
<?xml version="1.0" encoding="UTF-8"?>
<Parent>
<child include='1'>
<Attribute>Attribute1</Attribute>
</child>
<child include='1'>
<Attribute>Attribute2</Attribute>
</child>
<child include='0'>
<Attribute>Attribute3</Attribute>
</child>
<child include='0'>
<Attribute>Attribute4</Attribute>
</child>
</Parent>
And my result is:
<Parent>
<child include="0">
<Attribute>Attribute3</Attribute>
</child>
<child include="0">
<Attribute>Attribute4</Attribute>
</child>
</Parent>
Acoording to normal conditions we apply the result should be like below acccording to condition
<xsl:template match="child[@include='1']"/>
<Parent>
<child include="1">
<Attribute>Attribute3</Attribute>
</child>
<child include="1">
<Attribute>Attribute4</Attribute>
</child>
</Parent>
hopefully I have explained in details: this is the link to the code and xslt processor: Sample Code
Upvotes: 3
Views: 45
Reputation: 116993
I am not sure what you base your expectations on.
Your first template has a priority of 0.5, while your second (identity transform) template has a priority of -0.5.
Therefore the template applied to all the child
elements whose include
attribute is 1
is the first template. This template is empty, so it outputs nothing. As a result, no child
element with the include
attribute of 1
appears in the output.
All the other nodes are matched by the second template which copies them (and by recursion, their descendants) to the output.
Upvotes: 1