The technique you used in your post is called Muenchian grouping, and it's the appropriate solution if you're stuck with an XSLT 1.0 processor. But I think you want to output the level1 outside the inner for-each, and the level2 inside it.
Martin's solution is much better if you've got XSLT 2.0 available.
As for efficiency, both solutions are likely to use indexes or hash tables internally and therefore be pretty scaleable.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|