Re: [xsl] Checking alphabetical order

Subject: Re: [xsl] Checking alphabetical order
From: "Deborah Pickett" <debbiep-list-xsl@xxxxxxxxxx>
Date: Mon, 24 Sep 2007 13:38:47 +1000 (EST)
On Mon, September 24, 2007 08:16, Kamal Bhatt wrote:
> Hi,
> I would like to compare elements and determine if any element is out of
> alphabetical order, for XPath 1.0. For example,
[...]

Although there isn't an XPath 1.0 operator for string comparison, XSLT 1.0
still has to be able to compare strings because of <xsl:sort>.

So you could apply-templates or for-each on the list, using <xsl:sort> to
sort alphabetically, and then flag any element where its position() !=
count(preceding-sibling::*) + 1.

I'm not certain that it's any prettier.  Because you are using
apply-templates/for-each (which conceptually does its items in parallel),
you can't stop after flagging the first out-of-order item.  You are also
at the mercy of your locale as to what "alphabetical order" is. That may
or may not matter to you.

Current Thread