includes or excludes elements if the specified attribute is present : attribute « XPath « XML Tutorial






File: Data.xml
<?xml version="1.0" encoding="utf-8"?>
<data>    
     <car id="a234" checked="yes"/>
   <car id="a111" checked="yes"/>
   <car id="a005"/>
</data>

File: Transform.xslt

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="car[not(@checked)]">
      <paragraph>
        <xsl:text>Car: </xsl:text>
        <xsl:value-of select="@id"/>
      </paragraph>
    </xsl:template>
</xsl:stylesheet>
Output:

<?xml version="1.0" encoding="UTF-8"?>    
     
   
   <paragraph>Car: a005</paragraph>








4.6.attribute
4.6.1.What is Attribute Axis
4.6.2.Attributes can be accessed in similar way as elements
4.6.3.select="state/@joined"
4.6.4.If the element has an attribute
4.6.5.Check attribute existance
4.6.6.Check value of attribute
4.6.7.Attributes can be processed in the same way as elements
4.6.8.Select elements, which contain or do not contain the given attribute
4.6.9.includes or excludes elements if the specified attribute is present
4.6.10.for-each select="attribute::*"