Saturday, 21 November 2015

XML : How to use AND operator in xsl file

I would like to extract the entries from a xml file with catalog elements which has a year child element. I have to extract the elements which are between a given time period but I can't find a way to do this. I tried with if's and then but couldn't find the right way to do it. Here is my code, please give me some tips. Thanks

  <?xml version="1.0" encoding="UTF-8"?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:template match="/">    <html>    <body>      <h2>Bibliography entries</h2>      <table border="1">        <tr bgcolor="#9acd32">          <th>Title</th>          <th>Type</th>          <th>Year</th>        </tr>        <xsl:for-each select="catalog/cd">        <xsl:when test="(year > 2000) and (year < 2005)">        <tr>          <td><xsl:value-of select="title"/></td>          <td><xsl:value-of select="type"/></td>          <td><xsl:value-of select="year"/></td>        </tr>        </xsl:when>        </xsl:for-each>    </table>    </body>    </html>  </xsl:template>  </xsl:stylesheet>    

No comments:

Post a Comment