[xsl] Checking alphabetical order

Subject: [xsl] Checking alphabetical order
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Mon, 24 Sep 2007 08:16:39 +1000
I would like to compare elements and determine if any element is out of alphabetical order, for XPath 1.0. For example,


I would like this to register that the final element is out of sequence. I thought about doing this with preceding-sibling, unfortunately, it turns out that doesn't work for strings. If they are numbers, I can do it.

For example, if I had numbers, such as,

And I used:

Elements/Element[. &lt; preceding-sibling::node()]

I would get the last element. I suspect I can do this with a template (manually compare the current node to the preceding-sibling), but I was wondering if there was a simple way of doing this.

If there isn't, can you please keep the non simple solution (ie the one where you have to create a template to compare two strings) to yourself as I would like to have a stab at it myself.


Kamal Bhatt

Current Thread