Re: RDFQ: RDF Query in RDF

 > Hi Patrick,
 >
 > Is there any way to use the new 'select' stuff to do optional variable
 > binding?
 >
 > e.g. bind variable 'a' to the subject nodes of all triples matching a
 > certain criteria, and bind variable 'b' to the rdfs:label of the
 > subject node if it exists.
 >
 > Many thanks,
 >
 > Phil

I believe so, yes, though I need to work on this aspect a bit more
before I can give an absolutely confident 'yes'.

The selection variables are defined for each query. Each query can
have any number of templates, which are conjunctively joined,
and a result set is generated for each query, but in terms of each
template. Thus, if for any given template, there is no specification
of a selection variable, the result set will have a null binding for
that variable if the template otherwise matches.

So, per your example, you'd have to define a query that selects 'a'
and 'b', and then two templates, one that matches resources with
both 'a', 'b', and some other criteria, and one that matches
resources with only 'a', no 'b' and the other criteria. E.g.

[:select ("a" "b");
  :target [:id "a"; some:property some:value; rdfs:label [:id "b"]]
  :target [:id "a"; some:property some:value; rdfs:label :null]].

would return a result set where "a" is bound to resources having
some:property with some:value and "b" is bound to either its
rdfs:label, if any, or to null.

Because the second template excludes those targets that have a
label, you won't get duplicate bindings for "a" with label and
"a" with null where there actually is a label.

Cheers,

Patrick


--

Patrick Stickler
Nokia, Finland
patrick.stickler@nokia.com

Received on Tuesday, 2 March 2004 13:34:15 UTC