cancel
Showing results for 
Search instead for 
Did you mean: 

XPath date comparison

ananius
Champ in-the-making
Champ in-the-making
Hi, shouldn't alfersco support date comparison in xpath queries over jcr? At least jcr spec defines minimal set of operators for date comparing (=, !=, <, >, >=, <=).

I have following simple xpath query, and it doesn't return anything although it should:

//app:company_home/xx:documents/xx:document[@xx:created = 2004-12-22]

xx:created property is of type d:date
4 REPLIES 4

andy
Champ on-the-rise
Champ on-the-rise
Hi

Indeed it should.

The implementation uses Jaxen here. Having looked at the Jaxen API and equality operator it is treating dates as strings. No special date/time/date time treatment. You should be able to get this to work with string comparison and the ISO8601 date format.

I will report back ….

Regards

Andy

lfuller
Champ in-the-making
Champ in-the-making
Did you find anything out Andy?  I attempted to construct the query using xs:dateTime as defined in the spec.   That didn't work, and the ISO8601 date format doesn't appear to work either.

andy
Champ on-the-rise
Champ on-the-rise
Hi

We are using Jaxen which gives us XPath v1.0 support (more than the spec). However, internally it supports a limited set of data types when evaluating equalities. DefaultEqualityExpr does dynamic type detection for boolean, numeric and String (but not date in 1.1B8).

I think we can add the missing function, this will then do a Date.toString() comparison and should give the desired result.

Functions are registered in org.alfresco.repo.search.NodeServiceXPath if you want to give this a go.
(This should move out into a config file)

See http://issues.alfresco.com/browse/AR-1364

Regards

Andy

spearson23
Champ in-the-making
Champ in-the-making
what is the current status of this?  is it possible to do date comparisons? (=, <, >, etc.)