[programmer-defined sort order in XSLT 1.0 using exsl:node-set()]
It worked! Thanks for your help.
Glad to hear it.
How did you come up with this solution? I'm having a difficult time with
XSLT and I'm wondering how did you come up with this interesting solution.
A diseased mind and a lot of drugs.
Tip 1: use exsl:node-set(). It makes XSLT *much* more powerful. In particular,
it's the only way you can 'sweep' twice over the same bit of source XML, i.e.
apply one template to a piece of the source, then apply a second template to
the result of that first template (the tree-shaped result, not just its
string-value.) The decision in the XSLT 1.0 spec not to allow XPath operations
on a tree-fragment variable "to allow for this to be implemented in future
versions" strikes me as truly bizarre. Thankfully XSLT 2.0 will do away with
that. (XSLT 2.0 also has a programmer-defineable sort order construct, I
believe. Michael Kay's Saxon at
www.saxonica.com implements the current
working draft of 2.0, but I'm shy of working drafts so I'm sticking with 1.0
for the time being and using exsl:node-set a lot.)
Tip 2: don't be afraid to do clever things that look inefficient. If your data
is XML rather than strings, XSLT is *fast*. The only real exception I have
found to this is that in both the implementations I have used (MSXML and
Saxon), sweeping down the following-sibling:: axis is much faster than using
preceding-sibling:: (e.g. when you're trying to find the first unique value of
something - finding the last will be faster.)
Does one need to read the XSLT spec or is there a real good book that
explains XSLT.
The lovely Michael Kay strikes again: "XSLT Programmer's Reference", in the
"Programmer to Programmer" series by Wrox Press. The documentation on his site
is also very helpful.
I consider myself a very technical person (I know several
programming languages) but XSLT just kicks my butt.
"Assignment statement considered harmful."
--
Robin Johnson
rj at robinjohnson dot f9 dot co dot uk
http://www.robinjohnson.f9.co.uk
Only joking about the drugs.