On 15/12/11 17:25, Paolo Castagna wrote:
Hi Andy,
thanks for the quick reply.

Andy Seaborne wrote:
ARQ has it's own evaluation engine.  Currently, it needs code changes to
extend it.  It covers most of XSD already.

I had a look into NodeValue.java [1], would it be possible to do something
along these lines?

See NodeValue.compareAlways (which has the SPARQL rules for ORDER BY which are more than just "<")


Index: src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java
===================================================================
--- src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java    (revision 
1214849)
+++ src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java    (working copy)
@@ -1036,6 +1036,14 @@
                  boolean b = ((Boolean)lit.getValue()).booleanValue() ;
                  return new NodeValueBoolean(b, node) ;
              }
+
+
+            Object clazz = lit.getDatatype().getJavaClass();
+            if ( clazz.getClass().isInstance(Double.class) )
+            {
+                double d = ((Number)lit.getValue()).doubleValue() ;
+                return new NodeValueDouble(d, node) ;
+            }

That makes it a double, a number, no units.
(aside from the fact doubles are NOT numbers in XSD - use xsd:decimal - their value space is "m × 2^e" i.e. (m,e) pairs, for fixed length m and e extended with NaN, Inf, -Inf and a lot of machinery for comparison and addition etc for rounding and mapping ).

Saying a temperature has a value which is a number is wrong. Different value spaces.

Can you compare the height of a mountain with a temperature? Ones in meters, the other in Kelvin.


              // If wired into the TypeMapper via 
RomanNumeralDatatype.enableAsFirstClassDatatype
  //            if ( RomanNumeralDatatype.get().isValidLiteral(lit) )

Note that RomanNumeralDatatype are another way to write integers. Same value space.

Creating an ordering function that returns a number (no units) means comparison is defined.

  [1] 
https://svn.apache.org/repos/asf/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/expr/NodeValue.java

Reply via email to