[Home] [By Thread] [By Date] [Recent Entries]
At 2002-11-08 12:22 -0500, Schwartz, Rechell R, ALCAS wrote:
I still need to copy those rows that don't need to have the odd/even row styles applied to them. Gee! Why didn't you say that the first time? :{)} Do I need to set up a separate template rule for the filtered out nodes? Nope ... undo what I told you last time, since you are still working with all of the rows. In this case I don't think position() is going to help you ... I suggest using count() as below. It is important when working with XSLT to know that sometimes you need to approach problems without always using matching. Other tools are available to examine the source node tree. I hope this helps. ............... Ken
T:\ftemp>type rechell.xsl
<?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="count( preceding-sibling::tr[td[not(a) and not(@class)]] ) mod 2 = 1"> <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> T:\ftemp>saxon rechell.xml rechell.xsl <test> <table>
Nothing here</table> <table> <tr>
<td><a></a></td>
</tr> <tr>
<td class="oddRowStyle">good</td>
</tr> <tr>
<td><a></a></td>
</tr> <tr>
<td class="evenRowStyle">good</td>
</tr> <tr>
<td class="oddRowStyle">good</td>
</tr> <tr>
<td><a></a></td>
</tr> <tr>
<td class="evenRowStyle">good</td>
</tr></table> <table>
Nothing here as well</table> </test> T:\ftemp>rem Done!
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-10-1 Practical Formatting Using XSL-FO Next conference training: 2002-12-08,03-03,06 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|

Cart



