xsl-list
[Top] [All Lists]

[xsl] Checking alphabetical order

2007-09-23 15:13:15
Hi,
I would like to compare elements and determine if any element is out of alphabetical order, for XPath 1.0. For example,

<Elements>
<Element>AAA</Element>
<Element>BBB</Element>
<Element>CCCC</Element>
</Element>AAAAAA</Element>
</Elements>

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,
<Elements>
<Element>1</Element>
<Element>2</Element>
<Element>3</Element>
</Element>1</Element>
</Elements>

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.

Thanks.

--
Kamal Bhatt


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>