Subject: RE: Trying to Detect corrupt data
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 25 Oct 2007 09:51:26 +0100
|
> 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/
|