|
Subject: Re: [xsl] Filtering Problem using position() From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 08 Nov 2002 12:08:13 -0500 |
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.
T:\ftemp>type rechell.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<test>
<table>
Nothing here
</table>
<table>
<tr><td><a></a></td></tr>
<tr><td>good</td></tr>
<tr><td><a></a></td></tr>
<tr><td>good</td></tr>
<tr><td>good</td></tr>
<tr><td><a></a></td></tr>
<tr><td>good</td></tr>
</table>
<table>
Nothing here as well
</table>
</test>
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:apply-templates select="tr[td[not(a) and not(@class)]]"/>
</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>T:\ftemp>saxon rechell.xml rechell.xsl <test>
<table>
Nothing here <table>
<tr>
<td class="oddRowStyle">good</td>
</tr>
<tr>
<td class="evenRowStyle">good</td>
</tr>
<tr>
<td class="oddRowStyle">good</td>
</tr>
<tr>
<td class="evenRowStyle">good</td>
</tr>
</table> <table>
Nothing here as well</test> T:\ftemp>rem Done!
-- Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO: - North America: Feb 3 - Feb 7,2003
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Filtering Problem using p, David Carlisle | Thread | RE: [xsl] Filtering Problem using p, Schwartz, Rechell R, |
| Re: [xsl] Any recommended XSLT book, G. Ken Holman | Date | Re: [xsl] Any recommended XSLT book, Antonio Gallardo Riv |
| Month |