OWL as Input for the Wizard
The Web Ontology Language (OWL) was conceived as an extension of RDF Schema to provide modelers with rich syntax-independent modeling capabilities. Just like RDF Schema extended the basic RDF language, OWL extends the RDFS to provide a richer set of constructs for defining classes, properties and relations between them. The most commonly used form of OWL is OWL DL. For example, OWL (and also RDFS) supports the definition of subclasses, which allow for hierarchical classification of entities. OWL allows modelers to define object and datatype properties. The wizard is able to use these properties to propose elements for a new message models.
In addition, OWL allows for the definition of cardinality constraints on properties, which specify the minimum and maximum number of values that can be associated with a property. This is a useful feature in defining the structure of message models, as it allows for the specification of required and optional fields.
Overall, OWL provides a powerful language for representing knowledge about entities and their relationships, and can be used to define the structure of message models in the wizard.
This section elaborates on the features of OWL, RDFS and RDF in relation to Semantic Treehouse's wizard. To be clear, being an extension OWL uses RDF and RDFS constructs, so some of the following modeling constructs originate from RDF and RDF Schema.
Classes and Properties
Classes
Section wizard step 1 explains that the wizard requires you to select a root class for your message model. The root class can be any class from the imported ontologies, and provides the starting point for the further filling in of your message model. The wizard looks for all rdfs:Class
constructs in your ontology to find suitable classes to build your message on.
For example:
:Person rdf:type rdfs:Class .
This triple states that the resource identified by the URI "Person" is an instance of the rdfs:Class class, which means it represents a class in the ontology. rdf:type
is used to indicate the class or datatype that a resource (:Person) belongs to. If this is your ontology, now the Wizard allows you to use this Person class (with its full URI) as a valid starting point for your new message model.
OWL Object Property & Datatype Property
owl:ObjectProperty
After selecting the root class, the Wizard finds outgoing properties of the root class selected in step 1 from the ontology and presents them as possible sub elements. The two main types of these properties that are supported by the wizard are object properties and datatype properties.
An object property is used to relate two classes in the ontology. For example, we might define an object property called "isParentOf" to indicate the parent-child relationship between individuals:
:isParentOf owl:ObjectProperty .
This above states that isParentOf
is an object property in the ontology. RDFS allows us to specify the domain and range of this property. For example, if our interest is in people only, we can state that the property isParentOf
goes from person to person.
:isParentOf rdf:type owl:ObjectProperty .
rdfs:label 'is parent of';
rdfs:domain :Person ;
rdfs:range :Person .
- The
rdfs:label
property is used to provide a human-readable label or name for a resource. The element's name in the message tree view shows this label. - The
rdfs:domain
property is used to specify the domain of a property, which is the class of the subject of the property. In other words, it specifies which classes of resources can be the subject of a given property. In our example isParentOf the domain refers to he parent person. - The
rdfs:range
property is used to specify the range of a property, which is the class of the object of the property. In our example isParentOf the range is also a person, referring to the child.
Though our goal is to also support incoming properties (going the other way over a property, from range to domain), the current implementation of the message tree view in step 2 of the wizard only presents outgoing properties
owl:DatatypeProperty
In OWL, a datatype property is like an object property but the range is not a class, but a datatype. A datatype is a value that identifies itself, like the number 13
or the date 2024-01-01
. It is used to relate an individual to a value of a specific datatype, such as a string, integer, or date. For example, we might define a datatype property called "hasAge" to indicate the current age of an individual. The domain of that class is a Person and the range is a whole number (an integer):
hasAge: owl:DatatypeProperty ;
rdfs:label 'has age';
rdfs:domain :Person ;
rdfs:range xs:integer .
Datatype properties typically form the leaf nodes of a message tree. This coincides with the technical restriction in OWL that a datatype cannot be the domain of a property (so you can't 'build further' on the tree after you've reached a datatype).
In summary, object properties are used to describe relationships between individuals in classes, while datatype properties are used to describe relationships between individuals and values of a specific datatype. Both types of properties are important for representing knowledge in ontologies, and can be used to create a tree of elements that are presented in the message tree view of the wizard.
OWL individuals
rdf:type
To have a uniform way of defining allowed values (codelist - for more information please refer to Ontology best practices - Codelists) of a property, the wizard leverages class individuals. After including in a message model an owl:ObjectProperty
with rdfs:range
a owl:Class
, the Wizard picks up from the ontology the individuals of the range class. The wizard presents these individuals as allowed values.
To illustrate this functionality we introduce a new object property, a new class and a couple of individuals of that class:
:Nationality rdf:type rdfs:Class .
:Dutch rdf:type :Nationality .
:British rdf:type :Nationality .
:hasNationality rdf:type owl:ObjectProperty ;
rdfs:label 'has nationality' ;
rdfs:domain :Person ;
rdfs:range :Nationality .
Based on the given examples, when including the object property hasNationality
, the allowed values associated with it would be Dutch
and British
.
OWL cardinality constraints
RDFS doesn't support this, but it's useful in real-life applications: cardinality constraints. That's why OWL includes cardinality constraints. They can express restrictions such as 'each person should have at most one birth date', or 'each employee should have at least two phone numbers'.
The owl:maxCardinality
, owl:cardinality
, and owl:minCardinality
determine the cardinality of the object and dataytype properties, and therefore the possible sub elements of the subject class.
In this particular example the cardinality of the datatype property 'has age' is [1..1], expressing that each person has exactly one age. Note that OWL requires use of a subclass to express this constraints, which may seem a bit confusing at first.
:Person rdf:type owl:Class ;
rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty :hasAge ;
owl:cardinality 1 ;
].
The square brackets in the above code define an anonymous restriction class, ie. a class with no explicit name. If we should think of a meaningful name, for explanatory purposes it could be something like 'ExactlyOneAgeHavingThing'. So our model states that the Person class is a subclass of an 'exactly one age having thing'.
Besides the exactly one value restriction, the wizard makes also use of these other OWL Cardinality restrictions:
- The
maxCardinality
property is used to specify the maximum number of values that a property can have for a given class. minCardinality
to specify a minimum number of values that a property must have.
The astute reader will see that cardinality
of 1 is equivalent to the combination of maxCardinality
of 1 and minCardinality
of 1.
Example
Here is an integrated example that includes all the properties and classes listed:
@prefix : <http://example.org/person#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
:Person rdf:type rdfs:Class;
rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty :hasAge ;
owl:cardinality 1 ;
].
:isParentOf rdf:type owl:ObjectProperty ;
rdfs:label 'is parent of';
rdfs:domain :Person ;
rdfs:range :Person .
:hasAge rdf:type owl:DatatypeProperty ;
rdfs:label 'has age';
rdfs:domain :Person ;
rdfs:range xs:integer .
:Nationality rdf:type rdfs:Class .
:Dutch rdf:type :Nationality .
:British rdf:type :Nationality .
:hasNationality rdf:type owl:ObjectProperty ;
rdfs:label 'has nationality' ;
rdfs:domain :Person ;
rdfs:range :Nationality .
# individual instances
:John rdf:type :Person ;
:hasAge 40 ;
:hasNationality :British .
:Mary rdf:type :Person ;
:hasAge 35 ;
:isParentOf :John ;
:hasNationality :Dutch .