SHACL Input
As already mentioned in wizard step 1, the wizard enables to import one or more ontologies. This provides the opportunity to combine multiple ontologies to be the model behind the message model. However, another feature of the wizard is to import SHACL files, which define the shape of an ontology model.
The high-level vocabulary makes SHACL also a schema language, allowing the wizard to examine the structure of a class to, for example, suggest how properties of a class should be presented on an input form. Besides, SHACL is a great language to define a set of conditions for RDF graphs. For example, with the well known sh:minCount and sh:maxCount. All in all, a SHACL specification can be used as vocabulary to determine the structure, cardinalities and other constaints for a message model specification.
The wizard first looks at the SHACL shapes of an ontology and then at the restrictions defined in OWL. This is an arbitrary choice, but many people consider RDFS + SHACL as more intuitive than full OWL restrictions. The most important properties from SHACL property shapes that are picked up by the wizard are discussed below.
Properties from SHACL property shapes
SHACL target class
Properties that are mentioned in a SHACL property shape sh:path
that target the class are shown as possible sub elements.
For example:
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :knows ;
] .
SHACL cardinality
sh:minCount
and sh:maxCount
determine the cardinality of the possible sub elements of the target class.
In this particular example the cardinatily of the possible sub element 'knows' is [1..1]:
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :knows ;
sh:minCount 1 ;
sh:maxCount 1 ;
] .
SHACL description
The sh:description
property is shown as the description of the possible sub element of the target class in Semantic Treehouse.
SHACL file example:
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :knows ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:description "A person knows" ;
] .
Visualization in Semantic Treehouse:
SHACL datatype
sh:datatype
specifies a condition to be satisfied with regards to the datatype of each value node.
In the SHACL file example, the age of a person is specified as an integer.
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :age ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:description "The age of a person" ;
sh:datatype xsd:integer ;
] .
SHACL value constraints
sh:minExclusive
and sh:minInclusive
define the conditions for the minimum inclusive and exclusive value in Semantic Treehouse. For the sh:minExlusive
,
a value must be strictly greater than the value of sh:minExclusive
. Whereas, for the sh:minInclusive
, a value must be greater than or equal to the value of sh:minInclusive
.
For example,
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :age ;
sh:datatype xsd:integer ;
sh:minExclusive 65;
] .
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :age ;
sh:datatype xsd:integer ;
sh:minInclusive 66;
] .
sh:maxExclusive
and sh:maxInclusive
are basically the other way around, which set the conditions for the maximum inclusive and exclusive value in Semantic Treehouse. To be valid, a value must be strictly less than the value of sh:maxExclusive
. For the `sh:maxInclusive holds that a value must be less than or equal to the value of xs:maxInclusive.
For example,
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :age ;
sh:datatype xsd:integer ;
sh:minExclusive 65;
] .
:PersonShape
a sh:NodeShape ;
sh:targetClass :Person .
sh:property [
sh:path :age ;
sh:datatype xsd:integer ;
sh:minInclusive 64;
] .
SHACL string constraints
sh:minLength
specifies the minimum string length of each value node that satisfies the condition. In contrary, sh:maxLength
specifies the maximum string length of each value node that satisfies the condition.
For example,
:PersonShape
a sh:NodeShape ;
sh:targetNode :Person ;
sh:property [
sh:path :password ;
sh:minLength 8 ;
sh:maxLength 10 ;
] .