[xsl] Filtering Problem using position()

Subject: [xsl] Filtering Problem using position()
From: "Schwartz, Rechell R, ALCAS" <rrschwartz@xxxxxxx>
Date: Fri, 8 Nov 2002 11:48:11 -0500
All,

I am having a filtering problem using the position() function (I am
still new to XSLT, so please bear with me). I am outputting an HTML
table from one XSLT stylesheet, and using it as input to another. The
second stylesheet uses the identity transformation to filter out only
certain rows on which to apply styling elements. The stylesheet indeed
applies the styling only to those elements that I request it to.
However, the styling is based on odd and even rows in the stylesheet,and
it seems that it is applying the calculation of the position() to
INCLUDE those rows that I had excluded when I did a template match.  Any
help would be appreciated.

Following is the stylesheet that applies the styling:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 version="1.0">
<xsl:output method="html" indent="yes"/>

<xsl:template match="node()|@*"> <!--identity transform-->
   <xsl:copy>
     <xsl:apply-templates select="node()|@*"/>
   </xsl:copy>
</xsl:template>


<xsl:template match="table[2]/tr[td[not(a)  and not(@class)]]">
      <xsl:copy>
   <xsl:choose>
   <xsl:when test="position() mod 2 = 0">
   <xsl:for-each select="td">
    <td class="evenRowStyle">
     <xsl:apply-templates select="node()|@*"/>
     </td>
    </xsl:for-each>
   </xsl:when>
   <xsl:otherwise>
   <xsl:for-each select="td">
     <td class="oddRowStyle">
     <xsl:apply-templates select="node()|@*"/>
     </td>
    </xsl:for-each>
   </xsl:otherwise>
   </xsl:choose>
     </xsl:copy>
</xsl:template>


</xsl:stylesheet>

Rechell 

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


Current Thread