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


> From: <Patrick.Stickler@nokia.com>>  
>  
> Howdy folks,
>  
> As fodder for the coming discussions in Cannes regarding DAWG and
> related issues,  I wanted to draw attention to the latest specification =
> of RDFQ [1]
> an RDF vocabulary and query model for expressing queries and query =
> results
> in RDF.
>  
> RDFQ supports both query-by-example like templates, returning =
> descriptions
> of the matched resources, as well as SELECT like queries, returning =
> variable
> bindings using the Result Set Vocabulary [2].
>  
> E.g. Here is a query to identify all resources where their dct:modified =
> timestamp=20
> occurs between  the specified timestamps (match exclusive), which will =
> return
> the concise bounded description of each matched resource:=20
>  
> In minimal Turtle form (with RDFQ as default namespace and RDFS =
> closures):
>  
> [:target [dct:modified [:gt "2001-08-11T10:30:00Z"^^xsd:dateTime;  :lt =
> "2002-02-28T20:45:00Z"^^xsd:dateTime]]].
>  
> which in full Turtle equates to:
>  
> [a rdfq:Query;
>    rdfq:target
>       [a rdfq:Target;
>           dct:modified
>              [a rdfq:Value;
>                 rdfq:gt "2001-08-11T10:30:00Z"^^xsd:dateTime;
>                 rdfq:lt "2002-02-28T20:45:00Z"^^xsd:dateTime
>              ]
>       ]
> ].
>  
> which in RDF/XML equates to:
>  
> <rdfq:Query>
>    <rdfq:target>
>       <rdfq:Target>
>          <dct:modified>
>             <rdfq:Value>
>                <rdfq:gt =
> rdf:datatype=3D"http://www.w3.org/2001/XMLSchema#dateTime">2001-08-11T10:=
> 30:00Z</rdfq:gt>
>                <rdfq:lt =
> rdf:datatype=3D"http://www.w3.org/2001/XMLSchema#dateTime">2002-02-28T20:=
> 45:00Z</rdfq:lt>
>             </rdfq:Value>
>          </dct:modified>
>       </rdfq:Target>
>    </rdfq:target>
> </rdfq:Query>
>  
> Here is a query to identify all resources having a dc:title defined, =
> returning the variable=20
> bindings for 'target' and 'title' for each matched resource:=20
>  
> [:select ("target", "title"); :target [:id "target"; dc:title [:id =
> "title"]]].
>  
> or
>  
> [a rdfq:Query; rdfq:select ("target", "title");
>    rdfq:target [a rdfq:Target; rdfq:id "target"; dc:title [a rdfq:Value; =
> rdfq:id "title"]]].
>  
> or
>  
> <rdfq:Query>
>    <rdfq:select>
>       <rdf:List>
>          <rdf:first>target</rdf:first>
>          <rdf:rest>
>             <rdf:List>
>                <rdf:first>title</rdf:first>
>                <rdf:rest =
> rdf:resource=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
>             </rdf:List>
>          </rdf:rest>
>       </rdf:List>
>    </rdfq:select>
>    <rdfq:target>
>       <rdfq:Target>
>          <rdfq:id>
>             target
>          </rdfq:id>
>          <dc:title>
>             <rdfq:Value>
>                <rdfq:id>
>                   title
>                </rdfq:id>
>             </rdfq:Value>
>          </dc:title>
>       </rdfq:Target>
>    </rdfq:target>
> </rdfq:Query>
>  
> Which correlates to
>  
> SELECT ?target, ?title
> WHERE {dc:title, ?target, ?title};
>  
> The generic selection query to obtain all statements in a knowledge base
>  
> SELECT ?subject ?predicate ?object=20
> WHERE {?predicate, ?subject, ?object};
>  
> would be expressed in RDFQ as
>  
> [:select ("subject", "predicate", "object");
>  :target [:id "subject"; :property [:id "object"; :predicate [:id =
> "predicate"]]]].
>  
> (note that encoding the query in RDF requires the predicate variable
> to be defined in terms of the object for each property:value pair)
>  
> The RDFQ spec includes numerous additional examples.
>  
> One of the key benefits of RDFQ is that it is pure RDF. Both queries and =
> results
> are RDF, which means that only one parser is needed and one can employ =
> RDF
> tools and methods on the queries and results. Furthermore, auxiliary =
> information
> can be included in the request input, allowing e.g. the requesting agent =
> to provide
> vocabulary relations (e.g. rdfs:subPropertyOf, owl:sameAs) between =
> common and
> local terms so that  execution of the query can be optimized for that =
> agent without
> affecting the server's own knowledge base.
>  
> Using a keyboard-friendly serialization of RDF such as Turtle, where the =
> RDFQ
> namespace is default and RDFS closures for RDFQ terms are applied, =
> queries are=20
> as concise and easy to express as most SQUISH like queries, as the =
> examples
> should illustrate.
>  
> The open source release of the Nokia Semantic Web Server [3] has some =
> initial
> support for RDFQ, which should become complete in the very near future.
>  
> Anyway, just wanted to give a heads up about RDFQ in case folks find it =
> useful
> input to next week's discussions.
>  
> Regards,
>  
> Patrick
>  
> [1] http://sw.nokia.com/rdfq/RDFQ.html
> [2] http://www.w3.org/2003/03/rdfqr-tests/recording-query-results.html
> [3] http://sw.nokia.com/tools
>  
>  
> --
>  
> Patrick Stickler
> patrick.stickler@nokia.com
>  
>  
>  
-- 

Received on Tuesday, 2 March 2004 09:45:16 UTC