Error when using days-from-date() xpath function in comparison

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error when using days-from-date() xpath function in comparison

Toon Wouters
Hi all,

I'm aware that the days-from-date() function is deprecated and no longer relevant when using xpath 2.0 but our product currently still uses the function because it needs to remain xpath 1 compliant so I thought I would report this anyway. I've also found an easy fix for this problem.

The problem is that when you have a comparison somewhere in an xform between two days-from-date() function calls (or one days-from-date() call and something else that evaluates to an integer) and the days-from-date() argument cannot be interpreted as a date then the function will return a string value of 'NaN'. But the function is registered in org.orbeon.oxf.xforms.library.XFormsDeprecatedFunctions as returning only type INTEGER results so when doing the comparison saxon will use a ComparableAtomicValueComparer which will result in a ClassCastException when trying to cast the string value to a Comparable.

This can be fixed by changing the registered return type for the days-from-date() function to ANY_ATOMIC in XFormsDeprecatedFunctions because it will force Saxon to perform another runtime check of the types. Not sure if it is the best solution.

To reproduce simply add something like the following anywhere as a condition in a form:

days-from-date('bla') < days-from-date('bla')

(In this particular case this was as a constraint on a bind)

Thanks.

Toon

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Error when using days-from-date() xpath function in comparison

Alessandro  Vernet
Administrator
Hi Toon,

I am not sure to follow you. I'm trying to put days-from-date('2015-02-26') < days-from-date('2015-02-27') as the calculated value of a field, and am getting true as expected, not a ClassCastException. How should we go about reproducing the issue you're having?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet