Nic Miloslav     Example 13    KEYWORDS      EXAMPLES      AUTHORS     

You can also select elements, which contain or do not contain the given attribute. Stylesheet 1 includes and Stylesheet 2 excludes an element based on the attribute


     XML     HOME     XSL 1     XSL 2      
<xslTutorial >
<car id='a234' checked='yes' />
<car id='a111' checked='yes' />
<car id='a005' />
</xslTutorial>

     XSL 1     HOME     XML     HTML 1     OUTPUT 1     
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="car[@checked]">
<P><xsl:text> Car: </xsl:text>
<xsl:value-of select="@id"/></P>
</xsl:template>
</xsl:stylesheet>

     HTML 1     HOME     XML     XSL 1     OUTPUT 1     
<HTML>
<HEAD> </HEAD>
<BODY>
<P>Car: a234</P>
<P>Car: a111</P> </BODY> </HTML>

     OUTPUT 1     HOME     XML     XSL 1     HTML 1     

Car: a234

Car: a111


     XSL 2     HOME     XML     HTML 2     OUTPUT 2     
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="car[not(@checked)]">
<P><xsl:text> Car: </xsl:text>
<xsl:value-of select="@id"/></P>
</xsl:template>
</xsl:stylesheet>

     HTML 2     HOME     XML     XSL 2     OUTPUT 2     
<HTML>
<HEAD> </HEAD>
<BODY>
<P>Car: a005</P> </BODY> </HTML>

     OUTPUT 2     HOME     XML     XSL 2     HTML 2     

Car: a005