View Single Post
  #2 (permalink)  
Old January 17th, 2005, 07:14 PM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In general to do sorting then grouping you need to do a two-phase transformation. You can do this using two stylesheets, or using a single stylesheet if you write the result of the first phase to a variable and then (assuming XSLT 1.0) convert this variable to a node-set using the xx:node-set() extension function. This means that after sorting you need to copy the sorted records to the intermediate tree using xsl:copy-of; the preceding-sibling axis on the copied nodes will reflect their position in the intermediate tree. Remember that axes always reflect relationships among the nodes in a tree: sorting only changes the processing order of the nodes, it doesn't modify the original tree.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote