Hi Devs,

I'm in the process of reworking the type alternatives implementation for
Xerces2/J. I'm done with the XPath parser for the most part and now I'm on
to the XPath evaluator. As John instructed me I had a look at the comparison
rules stated in the XPath 2 spec. However I still have a couple of issues to
get clarified. So here goes.

1. According to the rules given in the XPath 2.0 spec it seems most of the
comparisons require casting the values to either double or string types. For
an example almost all the numerics are casted into double. So is it
acceptable to use the Double and String types of Java and ordinary Java type
casts to perform such comparisons (where possible)? Or should I use the
XSSimpleType to validate the values and compare them? (Actually I prefer the
latter even if that means more work for me. It seems more organized and well
structured. Khaled adviced me to do the same when I was implementing the
type alternatives support for the first time. So I can reuse some of the old
code as well.)

2. How do we handle comparisons of numeric literals against string literals
(eg: '5' = 5)? Are they allowed (the grammar certainly does)? If yes to
which type I should cast them before comparing them; string or double?

3. When a literal is compared against a cast expression (eg: 5 = '5.2' cast
as xs:integer) to which type I should cast them? Should I cast both values
to the type mentioned in the cast expression (xs:integer in the above
example)?

4. When two explicit casts are involved (eg: 5.1 cast as xs:integer = '5'
cast as xs:double) to which type I should cast them in order to compare
them?

Most of the comparison scenarios are covered in the general comparison rules
section in the XPath 2.0 spec (specially the ones with attributes involved
whose type is untypedAtomic). But I couldn't find any matching rules to the
above scenarios. Even though they are bit impractical the grammar allows
such expressions. So I think it's better if we can handle them.

WDYT?

Thanks

Best Regards,
Hiranya

Reply via email to