W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > June 2005

Re: Statements in queries?

From: Jeen Broekstra <jeen@aduna.biz>
Date: Tue, 14 Jun 2005 10:17:17 +0200
Message-ID: <42AE928D.6080808@aduna.biz>
To: Danny Ayers <danny.ayers@gmail.com>
Cc: public-rdf-dawg-comments@w3.org

Danny Ayers wrote:
> I re-skimmed the spec, couldn't see a way of doing this, and the
> charter, couldn't see an exclusion. Something that may be useful, if
> there's an uncomplicated way of doing it.
> Basically I'd like to somehow pass a statement(s) from the query to
> the results. The use case is I want to select a group of people, and
> have that group labelled in the results. The label isn't in the
> triplestore, it's something I want to add at query time. The
> triplestore will not be affected, this isn't graph update.
> I realise I could include the label or whatever in XSLT, but for the
> app I'm working on it would be much more convenient to have the XSLT
> fixed, with the query generated dynamically.
> It seems to me that for my specific kind of application a
> pseudo-statement could work, something like:
> ?label  VALUE "dawg" .
> producing 
> <result>
>     <label>dawg</label>
> ...
> at the appropriate places.
> But I wonder whether this might be more usefully done as assertions in
> the query, with the RDF results going something like this -
> data:
> <#groupA> rdf:type my:Group . 
> <#groupB> rdf:type my:Group .
> query:
> ?group rdf:type my:Group .
> ?group my:label ?label .
> APPEND ?label rdf:value "dawg" . 
> results:
> <#groupA> rdf:type my:Group .
> <#groupA> my:label "dawg" .
> <#groupB> rdf:type my:Group .
> <#groupB> my:label "dawg" .

This kind of functionality is offered by the CONSTRUCT clause:

CONSTRUCT { ?group rdf:type my:Group ;
                    my:label "dawg"  }
WHERE { ?group rdf:type my:Group }

Basically CONSTRUCT allows you to specify a graph template for the 
result set in which you can introduce new properties and values if so 

(personal note: it might be useful to include an example in the spec
  to illustrate the use of CONSTRUCT a bit more).

Jeen Broekstra          Aduna BV
Knowledge Engineer      Julianaplein 14b, 3817 CS Amersfoort
http://aduna.biz        The Netherlands
tel. +31 33 46599877
Received on Tuesday, 14 June 2005 08:18:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:14:48 GMT