SPARQL-DL Examples

This page provides some examples of queries supported by our SPARQL-DL implementation. More examples can be found in the distribution package.

Get all classes:

 SELECT ?c WHERE { Class(?c) }

Ask whether class A is a direct subclass of B:

 PREFIX ex: <http://example.com#>
ASK { DirectSubClassOf(ex:A, ex:B) }

Get all fillers of transitive properties of a given individual:

 SELECT ?x
WHERE { Transitive(?p),
PropertyValue(<http://example.com#myClass>, ?p, ?x) }

Get the complete class hierarchy by means of direct class/sub-class pairs:

 SELECT ?a ?b
WHERE { DirectSubClassOf(?a, ?b) }

Get union of individuals of two separate classes:

 PREFIX wine: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>
SELECT ?i
WHERE { Type(?i, wine:PinotBlanc) }
OR WHERE { Type(?i, wine:DryRedWine) }