Mega Code Archive

 
Categories / XML Tutorial / Xpath
 

Includes or excludes elements if the specified attribute is present

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>