Identity transform strange behavior when use with another template

Viewed 42

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

1 Answers
Related