On 22/08/14 13:55, Joshua TAYLOR wrote:
On Fri, Aug 22, 2014 at 8:40 AM, Y. Dong <[email protected]> wrote:
I need to do a fairly complex order by operation like:
order by (datediff(“second”, ?date, now())*?score) while datediff and now are
builtin functions in virtuoso.
I need to express this with arq api, and I think i should use Expr, specifically,
E_function. But E_function constructor always requires a functionIRI so the output is
always <datediff>(). Is there anyway I can get rid of the square brackets?
Your function should be identified by an absolute URI, so you should
probably end up with something like:
[[[
prefix ext: <http://tq00oqi.com/arq/>
...
order by ext:datediff( ... )
]]]
yes - extensibility is defined by the SPARQL specs via adding functions
named by URIs, rather than changing the syntax of the language itself to
add a keyword.
Using a prefix as Joshua shows makes it print nicely.
ARQ supports arithmetic on xsd:dateTimes, xsd:dates, and Gregorian
dates/ties (xsd:gYear etc) where compatible as defined by the
XSD/Functions+operations.
The difference of 2 xsd:dateTimes is an xsd:duration. it's defined that
way by "XQuery/Xpath functions and operators".
You can order by an xsd:duration.
You can extract the hours/minutes/seconds via HOURS, MINUTES, SECONDS --
note these are accessors so for seconds you need
3600*hours+60*minutes+seconds
Andy