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

Re: Sorting seems not to work completely

Subject: Re: Sorting seems not to work completely
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Wed, 27 Jul 2011 12:35:52 -0700
Re:  Sorting seems not to work completely
Thanks Murray et al,
I did have to make one small change to the placement of the <Item> element, but I now have what I want.
This has to be the most responsive and helpful list on the Internet!
Mark


The final template:
<xsl:template match="List">
<xsl:element name="List">
<xsl:for-each-group select="Item/Stamp" group-by="concat(Date/@year, '', Date/@month, ' ', Date/@day)">
<xsl:sort select="Date/@year" data-type="number"></xsl:sort>
<xsl:sort select="Date/@month" data-type="number"></xsl:sort>
<xsl:sort select="Date/@day" data-type="number"></xsl:sort>
<xsl:element name="Item">
<!-- output a Date element for each date "group" **within the "Item>-->
<xsl:copy-of select="current()/Date" copy-namespaces="no"></xsl:copy-of>
<xsl:for-each select="current-group()">
<!-- this sorts the elements within each group -->
<xsl:sort select="@value" order="descending" data-type="number"></xsl:sort>
<!-- this outputs each individual element within the group in sorted order -->
<xsl:copy-of select="." copy-namespaces="no"></xsl:copy-of>
</xsl:for-each>
</xsl:element>
</xsl:for-each-group>
</xsl:element>
</xsl:template>



-----Original Message----- From: Murray McDonald
Sent: Wednesday, July 27, 2011 12:19 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Sorting seems not to work completely


Hi Mark,

Try this:

<xsl:template match="List">
  <xsl:element name="List">
    <xsl:for-each-group select="Item/Stamp" group-by="concat(Date/@year, '
', Date/@month, ' ', Date/@day)">
      <xsl:sort select="Date/@year" data-type="number"></xsl:sort>
      <xsl:sort select="Date/@month" data-type="number"></xsl:sort>
      <xsl:sort select="Date/@day" data-type="number"></xsl:sort>
      <!-- output a Date element for each date "group" -->
      <xsl:copy-of select="current()/Date"
copy-namespaces="no"></xsl:copy-of>
      <xsl:for-each select="current-group()">
        <!-- this sorts the elements within each group -->
        <xsl:sort select="@value" order="descending"
data-type="number"></xsl:sort>
        <!-- this outputs each individual element within the group in
sorted order -->
        <xsl:element name="Item">
<xsl:copy-of select="."/>
</xsl:element>
      </xsl:for-each>
    </xsl:for-each-group>
  </xsl:element>
</xsl:template>

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.