This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: XSL Filtering


For the sample XML you posted, 
> 
> <TABLE>
>     <RECORD>
>         <TYPE>Red Barn</TYPE>
>         <COST>$195</COST>
>         <SKU>JHD384234</SKU>
>         <AVAIL>No</AVAIL>
>     </RECORD>
> </TABLE>

The following works: 
<?xml version="1.0"?> 
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/> 
<xsl:template match="/">
<table>
<xsl:for-each select="TABLE/RECORD[contains(TYPE,'Barn')]">
        <tr>
                <td><xsl:value-of select="TYPE"/></td>
                <td><xsl:value-of select="COST"/></td>
                <td><xsl:value-of select="SKU"/></td>
                <td><xsl:value-of select="AVAIL"/></td>
         </tr>
</xsl:for-each>
</table>
   </xsl:template>
</xsl:stylesheet>

There were several errors in the code you posted. 
- You were looking for a DESCRIPTION elemement that contained 'Barn', but
there is no such element in your source. I guess you mean TYPE.
- You were looking for the string 'Barn' but in your source it was written
in all caps, 'BARN'. That would not result in a match. 
- Your <xsl:value-of select=""/> weren't closed. 

Hope this helps, 
Linda


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]