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

RE: sorting - lost in a maze

Subject: RE: sorting - lost in a maze
From: cknell@xxxxxxxxxx
Date: Fri, 11 Mar 2005 11:24:34 -0500
maze template
I simplified your output a little by using the <xsl:choose> construct to set the class attribute for alternating rows rather than trying to concatenate a class name to a string as you have.

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" indent="yes" />
 <xsl:strip-space elements="*" />

<xsl:param name="keyword" select="'Agrotourisme'" />

 <xsl:template match="/">
   <xsl:apply-templates />
 </xsl:template>

 <xsl:template match="fiches">
   <table>
   <xsl:for-each select="fiche[texte/cattouristique=$keyword]">
     <xsl:sort order="descending" select="texte/fichetitre"/>
     <xsl:apply-templates select="." />
   </xsl:for-each>
   </table>
 </xsl:template>

 <xsl:template match="fiche">
   <xsl:choose>
     <xsl:when test="count(preceding-sibling::fiche) mod 2 = 0">
       <tr class="even-row-color"><td><xsl:value-of select="texte/fichetitre" /></td><td><xsl:value-of select="texte/typeheberg" /></td><td>123</td><td><xsl:value-of select="region/regionnseo" /></td></tr>
     </xsl:when>
     <xsl:otherwise>
       <tr class="odd-row-color"><td><xsl:value-of select="texte/fichetitre" /></td><td><xsl:value-of select="texte/typeheberg" /></td><td>123</td><td><xsl:value-of select="region/regionnseo" /></td></tr>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>

</xsl:stylesheet>
--
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Jason Tripanier <jtrepanier@xxxxxxxxxxx>
Sent:     Fri, 11 Mar 2005 10:09:42 -0500
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:   sorting - lost in a maze



I am trying to get records out of an xml file that match a $parameter givin.

for example the parameter must search "cattouristique" for "Agrotourisme"
and then the records that match "Agrotourisme" are returned.
Also the records returned must have alternating row colors.

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.