Previous topic  Top  Next topic  Print this Topic
 

Query Client

 

Query Client (query.cmd/query.sh)

The query client also supports specifying a query file for easier handling of multiline queries:

query.cmd -qf myQueryFile.obl

or

query.cmd -queryFile myQueryFile.obl

A query file contains a query (as you would type one in the Web console):

:- prefix b = "http://www.ontoprise.com/ontologies#".

:- module = b#ontowebtravel.

:- default prefix = "http://www.ontoprise.com/ontologies/ontowebtravel#".

?- ?X:?Y.

When you execute the query file you get your results as usual (this example uses the "travel" example ontology):

X    Y  

----------

<http://www.ontoprise.com/ontologies/ontowebtravel#h2>    <http://www.ontoprise.com/ontologies/ontowebtravel#Hotel>  

<http://www.ontoprise.com/ontologies/ontowebtravel#john>    <http://www.ontoprise.com/ontologies/ontowebtravel#Customer>  

<http://www.ontoprise.com/ontologies/ontowebtravel#d2>    <http://www.ontoprise.com/ontologies/ontowebtravel#Date>  

<http://www.ontoprise.com/ontologies/ontowebtravel#d3>    <http://www.ontoprise.com/ontologies/ontowebtravel#Date>  

<http://www.ontoprise.com/ontologies/ontowebtravel#d1>    <http://www.ontoprise.com/ontologies/ontowebtravel#Date>  

<http://www.ontoprise.com/ontologies/ontowebtravel#washington>    <http://www.ontoprise.com/ontologies/ontowebtravel#City>  

<http://www.ontoprise.com/ontologies/ontowebtravel#madrid>    <http://www.ontoprise.com/ontologies/ontowebtravel#City>  

<http://www.ontoprise.com/ontologies/ontowebtravel#newyork>    <http://www.ontoprise.com/ontologies/ontowebtravel#City>  

<http://www.ontoprise.com/ontologies/ontowebtravel#t1>    <http://www.ontoprise.com/ontologies/ontowebtravel#Transport>  

<http://www.ontoprise.com/ontologies/ontowebtravel#h1>    <http://www.ontoprise.com/ontologies/ontowebtravel#Hotel>  

<http://www.ontoprise.com/ontologies/ontowebtravel#h2>    <http://www.ontoprise.com/ontologies/ontowebtravel#Location>  

<http://www.ontoprise.com/ontologies/ontowebtravel#washington>    <http://www.ontoprise.com/ontologies/ontowebtravel#Location>  

<http://www.ontoprise.com/ontologies/ontowebtravel#madrid>    <http://www.ontoprise.com/ontologies/ontowebtravel#Location>  

<http://www.ontoprise.com/ontologies/ontowebtravel#newyork>    <http://www.ontoprise.com/ontologies/ontowebtravel#Location>  

<http://www.ontoprise.com/ontologies/ontowebtravel#h1>    <http://www.ontoprise.com/ontologies/ontowebtravel#Location>  

But it is also possible to abbreviate the namespace terms with the namespaces given in the query text:

query.cmd -queryFile myQueryFile.obl -abbreviateNamespaces

In this case you get

X    Y  

----------

h2    Hotel  

john          Customer  

d2                  Date  

d3                  Date  

d1                  Date  

washington    City  

madrid          City  

newyork          City  

t1                  Transport  

h1                  Hotel  

h2                  Location  

washington    Location  

madrid          Location  

newyork          Location  

h1                  Location  

If you additionally specify the "-formatting" option then the result will be formatted to be easily readable. However, in this case, the whole query will be executed before the result will be printed. The result looks like this:

X          Y        

---------------------

h2         Hotel    

john       Customer

d2         Date    

d3         Date    

d1         Date    

washington City    

madrid     City    

newyork    City    

t1         Transport

h1         Hotel    

h2         Location

washington Location

madrid     Location

newyork    Location

h1         Location

If you prefer to get the result without abbreviated namespaces, but formatted the result looks like this:

X                                                              Y                                                            

-----------------------------------------------------------------------------------------------------------------------------

<http://www.ontoprise.com/ontologies/ontowebtravel#h2>         <http://www.ontoprise.com/ontologies/ontowebtravel#Hotel>    

<http://www.ontoprise.com/ontologies/ontowebtravel#john>       <http://www.ontoprise.com/ontologies/ontowebtravel#Customer>

<http://www.ontoprise.com/ontologies/ontowebtravel#d2>         <http://www.ontoprise.com/ontologies/ontowebtravel#Date>    

<http://www.ontoprise.com/ontologies/ontowebtravel#d3>         <http://www.ontoprise.com/ontologies/ontowebtravel#Date>    

<http://www.ontoprise.com/ontologies/ontowebtravel#d1>         <http://www.ontoprise.com/ontologies/ontowebtravel#Date>    

<http://www.ontoprise.com/ontologies/ontowebtravel#washington> <http://www.ontoprise.com/ontologies/ontowebtravel#City>    

<http://www.ontoprise.com/ontologies/ontowebtravel#madrid>     <http://www.ontoprise.com/ontologies/ontowebtravel#City>    

<http://www.ontoprise.com/ontologies/ontowebtravel#newyork>    <http://www.ontoprise.com/ontologies/ontowebtravel#City>    

<http://www.ontoprise.com/ontologies/ontowebtravel#t1>         <http://www.ontoprise.com/ontologies/ontowebtravel#Transport>

<http://www.ontoprise.com/ontologies/ontowebtravel#h1>         <http://www.ontoprise.com/ontologies/ontowebtravel#Hotel>    

<http://www.ontoprise.com/ontologies/ontowebtravel#h2>         <http://www.ontoprise.com/ontologies/ontowebtravel#Location>

<http://www.ontoprise.com/ontologies/ontowebtravel#washington> <http://www.ontoprise.com/ontologies/ontowebtravel#Location>

<http://www.ontoprise.com/ontologies/ontowebtravel#madrid>     <http://www.ontoprise.com/ontologies/ontowebtravel#Location>

<http://www.ontoprise.com/ontologies/ontowebtravel#newyork>    <http://www.ontoprise.com/ontologies/ontowebtravel#Location>

<http://www.ontoprise.com/ontologies/ontowebtravel#h1>         <http://www.ontoprise.com/ontologies/ontowebtravel#Location>