In reference to the Rational datatype example in 'User defined non-XSD data
types'
at the bottom of the page at '
https://jena.apache.org/documentation/notes/typed-literals.html'


Is it possible, and if so how to do it,
to define/override suitable methods (which methods?) in the class
definition so that to overload SPARQL operators in jena's engine
for a user defined non-XSD datatype.

I am interested in both comparison (< > >= etc)
and arithmetic operators (+ - * /)

In reference to the given example the objective would be to do arithmetic
operations, for example the query :

SELECT ?result WHERE {
BIND ("3/5"^^urn:x-hp-dt:rational AS ?a) .
BIND ("4/7"^^urn:x-hp-dt:rational AS ?b) .
BIND (?a + ?b AS ?result) .
}

would return "41/35"^^urn:x-hp-dt:rational (or an equivalent representation
such as 82/70)

Also, for input data of the form:

<A> rdf:value "3/5"^^urn:x-hp-dt:rational .
<B> rdf:value "3/8"^^urn:x-hp-dt:rational .

the query

SELECT * WHERE {
?s rdf:value ?value .
FILTER (?value >= "1/2"^^urn:x-hp-dt:rational ) .
}

would return
?s    ?value
<A> "3/5"^^urn:x-hp-dt:rational


Finally, if the above is possible, how would one define operations and
results between different datatypes:
for example adding xsd:float with urn:x-hp-dt:rational
or comparing xsd:float with urn:x-hp-dt:rational

I am not actually interested in the specific Rational datatype use case,
but I figured since the example is there to use that as a reference.

Reply via email to