W3C home > Mailing lists > Public > www-rdf-interest@w3.org > March 2004

Re: RDFQ: RDF Query in RDF

From: Patrick Stickler <patrick.stickler@nokia.com>
Date: Tue, 2 Mar 2004 19:34:02 +0100
Message-Id: <2DAD5E9C-6C78-11D8-8625-000A95EAFCEA@nokia.com>
To: "'www-rdf-interest@w3.org' Interest" <www-rdf-interest@w3.org>

 > 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.




Patrick Stickler
Nokia, Finland
Received on Tuesday, 2 March 2004 13:34:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:44:48 UTC