Intoduction to OWL-QL Queries

OWL-QL queries send to RacerManager must be XML documents that conform the OWL-QL Schema. Please note that the proposed OWL-QL Schema has been slightly adjusted for RacerManager:

  • Elements that are not supported in the current implementation (mayBindVars, proof, proofStep) are removed from the schema.
  • The schema is syntactically restructured so that it could cooperate with the frameworks used.

Following simple query, named getDestinationsFromTravelOnt.xml, is avaliable as default in the sample queries select box on the quering page, after OwlQlWebApp has been deployed:

<?xml version="1.0"?>
<query
        xmlns="http://www.w3.org/2003/10/owl-ql-syntax#"
        xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:tra="http://www.owl-ontologies.com/travel.owl#">
<queryPattern>
        <rdf:RDF>
                <rdf:Description
                        rdf:about="http://www.w3.org/2003/10/owl-ql-variables#x">
                        <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
                </rdf:Description>
        </rdf:RDF>
</queryPattern>
<mustBindVars>
        <var:x/>
</mustBindVars>
<answerKBPattern>
        <kbRef rdf:resource="http://protege.stanford.edu/plugins/owl/owl-library/travel.owl"/>
</answerKBPattern>
<answerSizeBound>
4
</answerSizeBound>
</query>

This query asks for at most 4 destinations that are described by the travel ontology. The question is phrased in the queryPattern tag: Find values for the variable x that are of type Destination as defined in the travel ontology.

In the mustBindVars tag the variable that must be bound to available answers, namely x, is defined. The URL of the KB to answer the query is specified in the answerKBPattern tag. The answerSizeBound tag defines the maximum number of results the client wants to get for this query.

RacerManager returns following answer:

<answerBundle xmlns="http://www.w3.org/2003/10/owl-ql-syntax#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
  <queryPattern>
    <rdf:RDF>
      <rdf:Description rdf:about="http://www.w3.org/2003/10/owl-ql-variables#x">
        <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
      </rdf:Description>
    </rdf:RDF>
  </queryPattern>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#Woomera"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:fam="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#Woomera">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#Coonabarabran"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:fam="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#Coonabarabran">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#BlueMountains"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:fam="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#BlueMountains">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#Canberra"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:fam="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#Canberra">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <continuation>
    <continuation-token>
      <processHandle>26147375#11985797</processHandle>
      <answerBundleSize>4</answerBundleSize>
    </continuation-token>
  </continuation>
</answerBundle>  

Each answer tag contains a destionation bound to the variable x. Finally the continuation token contains a process handle that can be used to receive more answers for this query. To do this the process handle above can be inserted in to the default query named getMoreDestinationsFromTravelOnt.xml on the quering page. Lets assume that the client wants six more answers to the query he send before the continuation query should look like below:

<?xml version="1.0"?>
<query xmlns="http://www.w3.org/2003/10/owl-ql-syntax#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <serverContinuation>
    <processHandle>26147375#11985797</processHandle>
  </serverContinuation>
  <answerKBPattern>
    <kbRef rdf:resource="http://protege.stanford.edu/plugins/owl/owl-library/travel.owl"/>
  </answerKBPattern>
  <answerSizeBound>6</answerSizeBound>
</query>  

RacerManager returns following answer:

<answerBundle xmlns="http://www.w3.org/2003/10/owl-ql-syntax#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
  <queryPattern>
    <rdf:RDF>
      <rdf:Description rdf:about="http://www.w3.org/2003/10/owl-ql-variables#x">
        <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
      </rdf:Description>
    </rdf:RDF>
  </queryPattern>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#BondiBeach"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:j.0="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#BondiBeach">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#CurrawongBeach"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:j.0="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#CurrawongBeach">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#Warrumbungles"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:j.0="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#Warrumbungles">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#CapeYork"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:j.0="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#CapeYork">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#Sydney"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:j.0="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#Sydney">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <answer>
    <binding-set>
      <var:x rdf:resource="http://www.owl-ontologies.com/travel.owl#Cairns"/>
    </binding-set>
    <answerPatternInstance>
      <rdf:RDF xmlns:j.0="http://www.owl-ontologies.com/travel.owl#" xmlns:var="http://www.w3.org/2003/10/owl-ql-variables#">
        <rdf:Description rdf:about="http://www.owl-ontologies.com/travel.owl#Cairns">
          <rdf:type rdf:resource="http://www.owl-ontologies.com/travel.owl#Destination"/>
        </rdf:Description>
      </rdf:RDF>
    </answerPatternInstance>
  </answer>
  <continuation>
    <termination-token>
      <end/>
    </termination-token>
  </continuation>
</answerBundle>

Please note that this time RacerManager ends the message with a termination token-end message. This is because this client now received all possible answers to his query (The travel ontology contains alltogether ten destinations).