is a W3C Candidate Recommendation
towards a standard query language for the Semantic Web. Its focus is on querying RDF graphs at the triple level.
SPARQL can be used to query an RDF Schema or OWL model to filter out individuals with specific characteristics.
Please refer to the SPARQL specification for examples.
To use SPARQL in Protégé-OWL, you need version 3.2 or above. After launching Protégé,
click on the OWL -> Open SPARQL Query panel... menu item. This will open a panel at the bottom of the screen.
In the Query panel on the left, you can enter your query in the SPARQL syntax, press the Execute Query button, and the
query results will be shown on the right-hand side. In the example above, the query selects the name, symbol,
atomic number, and optionally the color of all the elements in the periodic table. Additionally, the results will be
ordered by name. Double-clicking on a result entry will navigate to the particular individual in the Individuals
The RDF representation of the periodic table and the example SPARQL query shown above are accessible as part of
a tutorial entitled
"Introducing SPARQL: Querying the Semantic Web"
by Leigh Dodds that is available on the XML.com
You may need to take extra care when working with XML Schema datatypes, because SPARQL maps literals
such as "42" or "4.2" with xsd:integer and xsd:double, while most Protégé-OWL ontologies
will use xsd:int and xsd:float. As a result, you may need to add the datatype explicitly to match with the query.
The trivial example above also illustrates that queries can in principle be used for constraint checking.
Protégé-OWL has an experimental assertion mechanism that allows you to declare whether a given statement
is assumed to have results or not. These assertions can be added as annotation properties to the selected class using
the small assertion buttons above the query panel. You can use the OWL -> Run ontology tests... menu item to check
all of these assertions.
This mechanism illustrates how queries can be kept in the model - they can simply be stored as annotation property values
at a class. You can right-click on the annotation property in the upper right-corner to copy it down into the query area.
For programmers, the Protégé-OWL API can be used to issue queries at run-time. The implementation is based on a
mechanism to wrap a Jena
model inside the
Protégé API. The queries are executed by the Jena SPARQL engine. The relevant method is
Currently maintained by:
Protégé staff members, last updated April 5, 2007