Re: Two-level grouping problem
Given that "we could as well use the value of the last() node of $rows[...] above to same effect", why is document order important?
XSLT 1.0 looks at *all* node sets returned by XPath 1.0 in document order, regardless of the proximity order used by the steps to select the nodes, and regardless of the XPath expression. Of course XSLT may choose then to sort them, but the set returned by XPath is always regarded in document order.
The predictable order is important if our reference node on the RHS ( first(), last(), whatever) is to serve as a predictably-locatable node among its like-valued ilk.
No, grouping works using any test that succeeds only once for each unique value. Since there is always a node with the true predicate [last()] and there is always a node with the true predicate  then either one could be used ... and in XSLT 1.0 functions like generate-id() will act on only the first node in document order.
But, the point was already made, "the important bit ... only one ... regardless of where in the document orer" ... so, it really is regardless of where in the document order, as long as it is a test that can be calculated for each unique value found in a set. For example, the predicate  would not work because there could be values in the set for which there is but one member.
I hope this helps.
. . . . . Ken
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format