xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Table alternate rows colors within xsl:sort


Subject: RE: [xsl] Table alternate rows colors within xsl:sort
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Thu, 20 Nov 2003 09:41:24 -0000


> I would want to display a datagrid which lines colors
> varies regarding the position (one line white, one
> line gray, one line white, ...) AFTER an xsl:sort.
> 
> The problem is that the "<xsl:if test="position() mod
> 2 = 0"> won't work after a <xsl:sort> because the
> position() function returns the position in the
> original xml, not the in sorted nodes.
> 
> I can't use a variable because xslt do not allow to
> increment it within my xsl:for-each
> 
> Do someone know a solution to this ?

A simple way is to do the sort in a variable first, then for-each over
the variable to produce your table rows.

<xsl:variable name="sortedRows-rtf">
  <xsl:for-each select="links/link">
    sort, xsl:copy etc...
  </xsl:for-each>
</xsl:variable>
<xsl:variable name="sortedRows" select="xxx:node-set($sortedRows-rtf)"/>

Then...

<table>
  <xsl:for-each select="$sortedRows">
    <xsl:for-each select="link">
       ....


Get the idea?

Whenver you have some multi-stage processing to do, just split it up
into variables, each one working on the previous one.

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



Current Thread
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor