There are several ways to extend ARQ:
Any system that implements the Jena Graph API or Jena Model API can be queried.
SPARQL allows custom functions in filter expressions so that queries can be used on domain-specific data. SPARQL defines a function by URI (or qname) in FILTER expressions. ARQ provides a function library and supports application-provided functions. There is a mechanism for dynamically loading.
Function name | Description |
---|---|
jfn:langeq(literal, lang) |
Compare the language tag of the literal with a language tag. Comparison reflects language tag rules so "foo"@en matches "EN-gb". |
jfn:now() |
Current time. Actually, the fixed time the query started. |
jfn:bnode(?x) |
Return the blank node label if ?x is a blank node. |
More functions will be added. Contributions welcome.
@@add details - see javadoc for now.
URIs for functions in the (fake) URI scheme java:
are
dynamically loaded. The class name forms the scheme specific part of the URI.
The ARQ function library uses this mechanism. The namespace of the ARQ function library
is <java:com.hp.hpl.jena.query.function.library.>
(note the trailing dot).
PREFIX jfn: <java:com.hp.hpl.jena.query.function.library.> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?v { ?x rdfs:label ?v . FILTER jfn:langeq(?v, "en" ) }
ARQ also provides the ability to write custom graph matching extensions. This not part of SPARQL; the application will need to use the ARQ query language (a superset of SPARQL). Unlike a value function, a matcher extension can set variables and generate multiple solutions.
EXT q:name(?a, ?b, ?c)
@@ to be written. Extension is loaded like functions. Likely to change.
The DESCRIBE
result form in SPARQL does not define an exact form
of RDF to return. Instead, it allows the server or query processor to
return what it considers to be an appropriate description of the resources
located. This description will be specific to the domain, data modelling or
application.
ARQ comes with one built-in handler which calculates the blank node closure
of resources found. While suitable for many situations, it is not general (for
example, a FOAF file usually consists
of all blank nodes). ARQ allows the application to replace or add handlers for
producing DESCRIBE
result forms.
Application-specific handlers can be added to the
DescribeHandlerRegistry
. The handler will be called for each resource
(not literals) identified by the DESCRIBE
query.
URIs from with scheme name "_" (which is illegal) are created as blank node labels for directly accessing a blank node in the queried graph or dataset. This are constant terms in the query - not unnamed variables. Do not confuse these with the standard qname notation for blank nodes in queries. This is not portable - use with case.
<_:1234-5678-90> # A blank node in the data
_:b0 # A blank node in the query - a variable