12.4 Conditional and Repetitive Processing

<?xml version="1.0" encoding="UTF-8" ?>  
    <xsl:stylesheet version="1.0"  
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
>  
 
  <xsl:template match="list" >  
     <even-odd>  
        <xsl:apply-templates />  
     </even-odd>  
  </xsl:template>  
 
  <xsl:template match="num" >  
     <xsl:choose>  
        <xsl:when test=" (number() mod 2) = 0">  
           <even>  
             <xsl:apply-templates />  
           </even>  
        </xsl:when>  
        <xsl:otherwise>  
           <odd>  
              <xsl:apply-templates />  
           </odd>  
        </xsl:otherwise>  
     </xsl:choose>  
  </xsl:template>  
 
</xsl:stylesheet>  
<?xml version="1.0" encoding="utf-8" ?>  
<list>  
   <num>11</num>  
   <num>32</num>  
   <num>14</num>  
   <num>23</num>  
</list>  
<?xml version="1.0" encoding="UTF-8"?>  
<even-odd>  
   <odd>11</odd>  
   <even>32</even>  
   <even>14</even>  
   <odd>23</odd>  
</even-odd>