[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Another Alternate table-row background color quest

Subject: RE: Another Alternate table-row background color question - Using filters
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Mon, 30 May 2005 15:09:08 +0000
xslt alternating table rows
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...

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.