This has lead me down the path of the key() function and <xsl:key> element and for-each group element.
It's too late on a friday to start this.
It is opening up my thinking though.
I may be able to move a lot of the processing into xslt and output an html page at the end.
e.g. Every time I run the command I get an updated html page.
Originally posted by @mikeaintworkin in #19 (comment)