jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From François Cassistat...@maya-systems.com>
Subject Re: Numeric/String comparisons in queries
Date Tue, 01 Dec 2009 18:21:41 GMT

Le 2009-12-01 à 12:10 PM, dave_gough a écrit :

> 
> Hi,
> 

Hi

> I have a a String property stored in the repository, but would like to query
> it using conditional logic as if it were a number
> 
> I have tried to implement the Atom spec in JCR and allowed extensions to be
> added on an ad-hoc basis. In this case there are number of "meta" fields
> that extend the Atom model, but they are all saved as Strings in an attempt
> to keep it simple.
> 
> However I now want to find all Entries that have a width property > 10000,
> but the query below does an ASCII comparison, so 20 > 1000
> 
> /jcr:root/element(*,atom:Entry)[./meta/width/@atom:value>'1000'] 
> 
> I tried to spoof itby removing the single=quotes around 1000 and this gave
> mixed results
> 

It's normal since @atom:value property is from string type.

> /jcr:root/element(*,atom:Entry)[./meta/width/@atom:value>1000] 
> 
> Is there a function  such as "jcr:to_number()" or something similar that
> coerces the property to be a number? Or does anyone have any suggestions on
> how to do compare strings as numbers
> 

There is a number function in standard XPath (http://www.w3.org/TR/xpath#function-number),
you can try :
/jcr:root/element(*,atom:Entry)[number(./meta/width/@atom:value)>1000] 
But I'm not sure it is supported in JCR/JackRabbit.

> regards
> 
> Dave Gough
> 
> regards
> -- 
> View this message in context: http://n4.nabble.com/Numeric-String-comparisons-in-queries-tp932301p932301.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.



Frank


Mime
View raw message