You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Jonathan Mark <jh...@xenops.com> on 2003/02/10 21:13:40 UTC

string compare operators not working?

I am running into the following issue using Xindice from CVS:
(my xalan file is xalan-2.4.0.jar).

The operators <= >= > and < seem to always return false when applied to
strings.
For example if I add ["abc"<="abc"] to the end of an xpath query which
returned some results, it now returns no results.
An example of a failing query is:
/db:datebook/db:category/db:date[string(db:start) = "2000-06-23 09:00"]["abc"<="abc"]

The = operator works as expected, and the inequalities work as expected if
applied to numbers rather than strings.
(So appending ["abc"="abc"] or [5<=5] has no effect on the query result.)
I have checked that the "<" and ">" signs are being quoted correctly when
passed to the Xindice server over XML/RPC.

Should I put this in bugzilla ... if so, for Xindice or Xalan?
Or is it a known problem, or am I misunderstanding how it's supposed to
work?

many thanks,

	Jonathan Mark


Re: string compare operators not working?

Posted by Terry Rosenbaum <Te...@amicas.com>.
You can't compare strings using the operators that
have ">" or "<" in them. That's explained in the
XPath standard (http://www.w3.org/TR/xpath).

/"When neither object to be compared is a node-set and the *operator* is 
|=| or |!=|,
then the objects are compared by converting them to a common type as follows
and then comparing them. ..."/

Thus "=" works.

But,

/"When neither object to be compared is a node-set and the *operator* is 
|<=|, |<|, |>=| or |>|,
then the objects are compared by converting both objects to numbers and 
comparing
the numbers according to IEEE 754. ..."/

Since the conversion(s) fail, the comparison returns false.

Lexicographic comparison of strings is not supported for the
<, >, <=, and >= operators!

The behavior you see is consistent with the standard and is
not a bug.

-Terry


Jonathan Mark wrote:

>I am running into the following issue using Xindice from CVS:
>(my xalan file is xalan-2.4.0.jar).
>
>The operators <= >= > and < seem to always return false when applied to
>strings.
>For example if I add ["abc"<="abc"] to the end of an xpath query which
>returned some results, it now returns no results.
>An example of a failing query is:
>/db:datebook/db:category/db:date[string(db:start) = "2000-06-23 09:00"]["abc"<="abc"]
>
>The = operator works as expected, and the inequalities work as expected if
>applied to numbers rather than strings.
>(So appending ["abc"="abc"] or [5<=5] has no effect on the query result.)
>I have checked that the "<" and ">" signs are being quoted correctly when
>passed to the Xindice server over XML/RPC.
>
>Should I put this in bugzilla ... if so, for Xindice or Xalan?
>Or is it a known problem, or am I misunderstanding how it's supposed to
>work?
>
>many thanks,
>
>	Jonathan Mark
>
>  
>