xsl-list
[Top] [All Lists]

RE: Another Alternate table-row background color question - Using filters

2005-05-30 08:09:08

stylesheet will extract only some information (filter) from the XML and
create a table. I want the rows in this table to have alternate background
color. Because of the filter condition in the XSL, I cannot use the
position() to check for odd/even rows. I need to (essentially) check the
row number inserted into the HTML <TABLE>.

Here're 2 XSLT 1.0 options: split the transform into 2 stylesheets--the first picks out only the rows you want, and the second formats them into HTML, this time using position() to determine even/odd rows. Alternatively you could do this in 1 stylesheet if you're willingto use an extension function such as node-set(). The idea here is to create a variable containing the rows you want, then to iterate rows inthis variable, this time using position(). Something like so:

<xsl:variable name="r">
   <xsl:copy-of select="Codes/Code[Name = 30 ... etc]"/>
</xsl:variable>

<xsl:for-each select="node-set($r)">
   //.. do something with .
</xsl:for-each>

node-set comes into play because what's held in $r is a "result tree fragment", which needs to be converted to a "nodeset" before it may be iterated over, etc.

I gather that XSLT 2.0 has features that obviate this step.

Regards,

--A

<Codes>
    <Code>
        <Name>10</Name>
        <Description>Decription 10</Description>
    </Code>
    <Code>
        <Name>20</Name>
        <Description> Description 20</Description>
    </Code>
    <Code>
        <Name>30</Name>
        <Description>description 30</Description>
    </Code>
    <Code>
        <Name>40</Name>
        <Description> Description 40</Description>
    </Code>
</Codes>

And here is my stylesheet (it extracts only codes 30, 50 & 60). The output
should contain the first and third rows in one bg color and the second row
in a different color. I tried the position() in this XSL, but it does not
work...

_________________________________________________________________
Don?t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--