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

Trying to sort node set while tagging specific nodes i

Subject: Trying to sort node set while tagging specific nodes in it
From: Stan <sgd@xxxxxxxxxxxx>
Date: Wed, 27 Jul 2005 11:20:25 -0400
sort a set
I want to transform the following...

<root>
   <rec>
      <name>z</name>
      <year>2004</name>
   </rec>
   <rec>
      <name>z</name>
      <year>2005</year>
   </rec>
   <rec>
      <name>a</name>
      <year>2002</year>
   </rec>
   <rec>
      <name>a</name>
      <year>2003</year>
   </rec>
</root>

...to...


<root> <rec> <name tag="latest">a</name> <year>2003</year> </rec> <rec> <name>a</name> <year>2002</year> </rec> <rec> <name tag="latest">z</name> <year>2005</year> </rec> <rec> <name>z</name> <year>2004</name> </rec> </root>

In other words, sort by <name> ascending and then by <year> descending
while tagging the most recent of each name.

The sorting is easy, but tagging the most recent is proving difficult
for me. I thought to use the preceding axis to test the preceding name
and if it is different than the current name put in the tag attribute,
but as I understand it, the precding axis  applies to document order,
not sort order. Is there some better way to do this?

Thanks,
Stan Dyck

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.