xsl-list
[Top] [All Lists]

RE: [xsl] Trying to Detect corrupt data

2007-10-25 01:51:58

To check that all <agent>s contain the same value use:

agent != agent  (one of the few times you want to use !=   ....!)

or maybe in 2.0:

count(distinct-values(agent) eq 1)


agent != agent is probably going to have O(n^2) performance. It can be
optimized of course but it's not a common construct so that's unlikely.
O(n^2) is the worst case, but the worst case occurs when the data is
correct, so it's also the most likely case.

count(distinct-values(agent)) is likely to have O(n log n) performance.

You can do it in linear time with

not(agent[. != following-sibling::agent[1]])

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
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>