Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Compare number value

File: Data.xml <poem author="jm" year="1667">   <verse>line 1</verse>   <verse>line 2</verse>   <verse>line 3</verse>   <verse>line 4</verse> </poem> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:output method="xml" omit-xml-declaration="yes" indent="no" />      <xsl:template match="poem">     <xsl:choose>       <xsl:when test="@year &lt; 1638">         The poem is one of Milton's earlier works.       </xsl:when>       <xsl:when test="@year &lt; 1650">         The poem is from Milton's middle period.       </xsl:when>       <xsl:when test="@year &lt; 1668">         The poem is one of Milton's later works.       </xsl:when>       <xsl:when test="@year &lt; 1675">         The poem is one of Milton's last works.       </xsl:when>       <xsl:otherwise>         The poem was written after Milton's death.       </xsl:otherwise>     </xsl:choose>   </xsl:template>    </xsl:stylesheet> Output:         The poem is one of Milton's later works.