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

xsl:sort question: sorting element based upon particul

Subject: xsl:sort question: sorting element based upon particular child node
From: "Bruce Rojas-Rennke" <brr@xxxxxxx>
Date: Wed, 13 Aug 2003 15:58:39 -0600
datarow sort
Hello all,

  I have a sorting prb, - I have to put all the 'ColData' elements for each
'DataRow' into a row like so...

2003-07-01  70103     AMS Courier      2003-08-15  0   27.50
2003-07-23  29190087  Aegis Staffing   2003-08-22  0  260.00
2003-00-01  93        Boulder CC       2003-09-01  0   70.00
2003-05-13  70103     Yellow Book USA  2003-06-12  0  285.00

  In short, I have to spit out all the 'DataRows''ColData' elements,
- sorted upon the '@value' attribute of only those ColData elements which
have an '@colID' = '4'.

  Or put another way, I have to sort on element(DataRow) and it's child
nodes(all named ColData), by evaluating one attribute(ColData/@value) based
upon the value(4) of another attribute(ColData/@colID).

  The crux of my prb, as I see it, is that all the child nodes of node
'DataRow' have the same bloody name (ColData).


Here is new test code: XSLT
(OK for the one ColData (@colID='4'),
 but not all the ColData elements)
*****************************************

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="ReportRet">
  <table>
    <xsl:for-each select="//DataRow/ColData[@colID='4']">
      <xsl:sort select="@value" data-type="text" />
    <tr>
      <td>
        <xsl:value-of select="@value"/>
      </td>
    </tr>
      </xsl:for-each>
    </table>
  </xsl:template>
</xsl:stylesheet>

Here is new input XML test code: *************************************

<?xml version="1.0"?>
<ReportRet>
  <ReportData>
    <DataRow rowNumber="2">
      <ColData colID="2" value="2003-07-01" />
      <ColData colID="3" value="70103" />
      <ColData colID="4" value="AMS Courier" />
      <ColData colID="5" value="2003-08-15" />
      <ColData colID="6" value="0" />
      <ColData colID="7" value="27.50" />
    </DataRow>
    <DataRow rowNumber="2">
      <ColData colID="2" value="2003-05-13" />
      <ColData colID="3" value="May03" />
      <ColData colID="4" value="Yellow Book USA" />
      <ColData colID="5" value="2003-06-12" />
      <ColData colID="6" value="56" />
      <ColData colID="7" value="285.00" />
    </DataRow>
    <DataRow rowNumber="3">
      <ColData colID="2" value="2003-07-23" />
      <ColData colID="3" value="29190087" />
      <ColData colID="4" value="Aegis Staffing Services, Inc." />
      <ColData colID="5" value="2003-08-22" />
      <ColData colID="6" value="0" />
      <ColData colID="7" value="260.00" />
    </DataRow>
    <DataRow rowNumber="4">
      <ColData colID="2" value="2003-08-01" />
      <ColData colID="3" value="93" />
      <ColData colID="4" value="Boulder CC" />
      <ColData colID="5" value="2003-09-01" />
      <ColData colID="6" value="0" />
      <ColData colID="7" value="70.00" />
    </DataRow>
  </ReportData>
</ReportRet>

Above gives me results as below:
(just for the one ColData element (colID='4')
*********************************************************************

Aegis Staffing Services, Inc.
AMS Courier
Boulder CC
Yellow Book USA


tanx all


 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.