Chapter 7. Sorting and Grouping Elements

By now, I hope you’re convinced that you can use XSLT to convert big piles of XML data into other useful things. Our examples to this point have pretty much gone through the XML source in what’s referred to as document order. We’d like to go through our XML documents in a couple of other common ways, though:

  • We could sort some or all of the XML elements, then generate output based on the sorted elements.

  • We could group the data, selecting all elements that have some property in common, then sorting the groups of elements.

We’ll give several examples of these operations in this chapter.

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.