Previous topic  Top  Next topic  Print this Topic
 

Using Namespaces in ObjectLogic Expressions

 

In ObjectLogic expressions every concept, method, object, predicate and function may be qualified by a namespace. To separate the namespace from the name, the "#"-sign is used (as conventionally used in the RDF world and in HTML to locate local links inside a Web page). The following examples use the namespace declaration from above:

cars#Car[

 cars#driver {1:*} *=>  cars#Person,

 cars#passenger {1:*} *=>  cars#Person,

 cars#seats {1:*} *=>  xsd#integer].

cars#Person[

 cars#name {1:*} *=>  xsd#string,

 cars#age {1:1} *=>  xsd#integer,

 cars#drivingLicenseId {1:1} *=>  xsd#string].

         

finance#Bank[

 finance#customer {1:*} *=>  finance#Person,

 finance#location {1:*} *=>  finance#City].

finance#Person[

 cars#name {1:*} *=>  xsd#string,

 finance#monthlyIncome {1:*} *=>  xsd#integer].

 

?Y[finance#hasBank -> ?X] :-

         ?Y:finance#Person AND

         ?X:finance#Bank[finance#customer -> ?Y].

 

me:cars#Person[cars#age -> 28].

myBank:finance#Bank[finance#location -> karlsruhe].

The semantics of a namespace-qualified object is always a pair of strings, i.e. each object is represented by a URI (its namespace) and a local name. Thus finance#Person and cars#Person become clearly distinguishable. During parsing of the ObjectLogic program the aliases are resolved, so that the following pairs are constructed.

finance#Person stands for <http://www.financeWorld.tv/Person>
cars#Person stands for <http://www.cars-r-us.tv/Person>

If no declared namespace URI is found for a used alias, the alias itself is assumed to represent the namespace of an ObjectLogic object. URIs can also be used directly in namespace terms, i.e. the use of aliases is optional.

As described above, the ending character of namespaces is important for compatibility with RDF and OWL. In cases where the namespace does not end with one of the characters "/", "#" or ":", the ObjectLogic parser automatically adds a "#" to the end of the namespace. This patch is applied to literal namespaces and also to the namespace declaration.