Looping and Sorting

Until now, we've mostly gone along with the order of the XML document, although that might be difficult to see because we've been so selective about what we've output.

At this point, we're going to take a little more control over how things are done. Using the templates all by themselves, we can output the vendor_name only once (without jumping through some rather intricate hoops), but we want to have a list of vendor names at the top of the page with links to that vendor's offerings.

To do this, we need to keep in mind two things: how the document is actually processed and where we are in the source tree at all times.

We need to remember that the processor will do absolutely nothing until we tell it to start processing the ...

Get XML and Java™ from scratch 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.