xsl-list
[Top] [All Lists]

Trying to sort node set while tagging specific nodes in it

2005-07-27 08:20:25
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



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>