Nowadays ARQ supports date/duration arithmetic (not ARQ 2.8.8)
"2012-03-22"^^xsd:date + "-P30D"^^xsd:duration
==>
"2012-02-21"^^xsd:date
You may not need the custom function.
The values must be of the right datatype but you can cast:
xsd:date("2012-03-22") + xsd:duration("-P30D")
> 18:00:53 WARN Loader :: Class not found:
> dateadd.lib.pkgfor.arq.DateaddLibForARQ
> 18:00:53 WARN exec :: URI
> <java:dateadd.lib.pkgfor.arq.DateaddLibForARQ> has no registered
function factory
The implementation isn't on the classpath at runtime. It's warning, not
an error. The same check doesn't seem to be happening for BIND - maybe
we should make it the symmetrical.
The use of a custom functions inside SERVICE isn't ideal.
Andy
On 12/04/13 22:12, Diogo FC Patrao wrote:
Hello all,
I'm trying to run a SPARQL query specifiying a custom function (that does
date arithmetics). On ARQ 2.8.8, the following code worked perfectly:
PREFIX : <http://www.cipe.accamargo.org.br/ontologias/h2tc.owl#>
PREFIX xmls: <http://www.w3.org/2001/XMLSchema#>
select * {
SERVICE <http://0.0.0.0:2023/sparql> {
:patient1 :hasDocument ?docX .
?docX :documentType "PRESCRIPTION" .
?docX :documentDateOfCreation ?docDateX .
FILTER ( xmls:date(?docDateX) >
:xmls:date(<java:dateadd.lib.pkgfor.arq.DateaddLibForARQ>("2012-03-22",
"-P30D")) )
}
}
limit 10
However, when specifying this function using arq 2.10.1-snapshot (4/3)
(recompiled the library and updated cp), it complains :
18:00:53 WARN Loader :: Class not found:
dateadd.lib.pkgfor.arq.DateaddLibForARQ
18:00:53 WARN exec :: URI
<java:dateadd.lib.pkgfor.arq.DateaddLibForARQ> has no registered function
factory
I could get the query working that way:
select * {
SERVICE <http://0.0.0.0:2023/sparql> {
:patient1 :hasDocument ?docX .
?docX :documentType "PRESCRIPTION" .
?docX :documentDateOfCreation ?docDateX .
BIND( <java:dateadd.lib.pkgfor.arq.DateaddLibForARQ>("2012-03-22",
"-P30D") as ?teste )
FILTER ( ?docDateX > ?teste )
}
}
limit 10
Thanks a lot!
--
diogo patrĂ£o