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

RE: xsl sorting

Subject: RE: xsl sorting
From: Jarno.Elovirta@xxxxxxxxx
Date: Wed, 17 Apr 2002 09:24:50 +0300
ascending xsl
Heppa,


> If there is several sorting orders, they are all applied and not
> only the last one. For example if there is xml file that includes
> severals sets like:
> 
> <Subject id="0000000001" id2="001" id3="001">Juu juu</Subject>
> <Subject id="0000000001" id2="002" id3="002">RE:Juu juu</Subject>
> <Subject id="0000000001" id2="002" id3="001">RE:Juu juu</Subject>
> 
> and sets are sorted:
> <xsl:sort select="Subject/@id" order="ascending" /> 
> <xsl:sort select="Subject/@id2" order="ascending" />
> <xsl:sort select="Subject/@id3" order="ascending" />
> 
> So the result would be:
> <Subject id="0000000001" id2="001" id3="001">Juu juu</Subject>
> <Subject id="0000000001" id2="002" id3="001">RE:Juu juu</Subject>
> <Subject id="0000000001" id2="002" id3="002">RE:Juu juu</Subject>
> 
> Right?

Right, but make sure when you're using the sort instruction that your context node is the corrent one for the sort select expressions. If you have 

  <xsl:for-each select="Subject">
    <xsl:sort select="Subject/@id" order="ascending" /> 
    <xsl:sort select="Subject/@id2" order="ascending" />
    <xsl:sort select="Subject/@id3" order="ascending" />
    <xsl:copy-of select="." />    
  </xsl:for-each>

that will not work, because the Subject doesn't have a Subject child. Instead use

<xsl:template match="f">
  <xsl:for-each select="Subject">
    <xsl:sort select="@id" order="ascending" /> 
    <xsl:sort select="@id2" order="ascending" />
    <xsl:sort select="@id3" order="ascending" />
    <xsl:copy-of select="." />    
  </xsl:for-each>
</xsl:template>

Cheers,

Santtu


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


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.