[Mulgara-general] RDF Collections with SPARQL Construct

Paul Gearon gearon at ieee.org
Mon Jan 18 19:50:27 UTC 2010


Hi Alex,

On Mon, Jan 18, 2010 at 11:49 AM, Alex Hall <alexhall at revelytix.com> wrote:
> This question isn't strictly specific to Mulgara, but I think there's
> enough overlap to justify posting here.

Well, Mulgara users provide a test case for this sort of thing, so sure.  :-)

> We have an application that is working with OWL ontologies, and we would
> like to be able to create new OWL concepts based on the current contents
> of a graph using a SPARQL Construct query.  One key difficulty is that
> the RDF serialization of OWL uses RDF collections (i.e. rdf:first and
> rdf:rest) to specify the operands of boolean structures such as
> intersections and unions, and there doesn't seem to be very good support
> for this in SPARQL.

Not at all. One of my pet peeves with OWL is the use of collections,
specifically because they're so hard to use with SPARQL.

> The SPARQL language does have limited syntactic support for RDF
> collections with the "(...)" construct, but when using this notation I
> believe that you're constrained to knowing the number and order of the
> collection members.  In other words, it could be possible to construct a
> class Person as the union of Man and Woman using:
>
> CONSTRUCT { :Person a owl:Class . :Person owl:unionOf ( :Man :Woman ) }

Sure, that's OK because you know exactly how many elements you're
creating. It's just a shorthand so you don't have to construct blank
nodes and use lots of rdf:first and rdf:rest predicates.

> What I'm struggling with is how to express an equivalent query that
> would be able to work with an arbitrary number of items in the
> collection.  SPARQL alone doesn't seem to have that capability.

Not in SPARQL 1, no. SPARQL 1.1 does though.

> Also, I know that Jena in particular has some built-in predicates that
> provide special support for operations on RDF collections.  Paul, I
> think that in the past you've expressed a desire to do something similar
> in Mulgara.  Do you (or anybody else) have any ideas that would shed
> light on my problem?

Yes. You treat rdf:rest as a transitive predicate, and pull all the
rdf:first elements out. In TQL that would be:

  :Person owl:unionOf ?list and
  trans(?list rdf:rest ?rest) and
  ?list rdf:first ?elements

and in SPARQL 1.1 it's:
  :Person owl:unionOf ?list .
  ?list rdf:rest* ?rest
  ?list rdf:first ?elements

(I think that's right. I'll check it later).

No, we haven't implemented SPARQL 1.1 yet, but that has to come soon.
The grammar is settling down now, so we should be able to move ahead
without problem.

Regards,
Paul Gearon



More information about the Mulgara-general mailing list