Hi Ethan,
Finally, the last issue seems to be performance. I had originally mentioned another
solution that someone had assisted me with that employed for-each rather than templates
and used the Muenchian method as well. It performed well -- 2 seconds to transform a 3MB
file, although it didn't group to the number of levels as above (though I suspect it
would not have made a significant difference). However, the templates-based solution
above takes about 45 seconds, which is of course a major difference. I'm not sure why
(perhaps the number of keys stored in memory due to the various grouping levels, or the
use of "ancestor"?), or where improvements could be made, so I may need to
revisit the other solution.
Yes, 2 seconds or 45 seconds is a big difference. But I don't think this
can be caused by using apply-templates vs. for-each. Maybe the other one
was faster because it restricted the Muenchian grouping to a limited
nodeset (rather than concatenating ancestor::country names etc. in the
keys).
Anyway, there must be ways to optimize this. I'd like to help, but I
would need a large file to test with - if you could send me a 3MB input
file off-list?
Cheers,
Anton