OWL 2 SHACL open ruleset


Turns an OWL Ontology into a set of SHACL Shapes. The generated Shapes remain open and will not detect a property asserted on an instance of a wrong class. Properties from other ontologies can still be asserted anywhere as the NodeShapes are not closed.

Table of Content

ClassShape

Target


Rules


 Preprocessing-CopyEquivalentIntersection

rdfs:label Copy owl:intersectionOfs from owl:equivalentClass
rdfs:comment Copies any intersections within owl:equivalentClass into the host class itself so that subsequent rules convert them further.
sh:order -1

 Preprocessing-FlattenIntersectionOf

rdfs:label Flatten owl:intersectionOf
rdfs:comment Copies the members of an owl:intersectionOf list as superclasses into the host class itself. Subsequent rules then apply.
sh:order 0

 CreateNodeShapesAndPropertyShapesFromEquivalentClassHasValue

rdfs:label owl:equivalentClass/owl:hasValue to sh:NodeShape with sh:hasValue
rdfs:comment Creates a sh:property shape for each property that is mentioned in an owl:Restriction.
sh:order 1

 CreateNodeShapesAndPropertyShapesFromRestrictions

rdfs:label owl:onProperty to sh:property
rdfs:comment Creates a sh:property shape for each property that is mentioned in an owl:Restriction.
sh:order 1

 CreateNodeShapesAndPropertyShapesFromMatchingDomains

rdfs:label rdfs:domain to sh:property
rdfs:comment Creates a sh:property shape for each property with matching rdfs:domain.
sh:order 2

 owlFunctionalProperty2shMaxCount1

rdfs:label owl:FunctionalProperty to sh:maxCount 1
rdfs:comment For each relevant property that is owl:FunctionalProperty, create sh:maxCount of 1 (unless there is an OWL cardinality restriction).
sh:order 3

 owlAllValuesFrom2shClassOrDatatype

rdfs:label owl:allValuesFrom with IRI to sh:class or sh:datatype
rdfs:comment For each owl:allValuesFrom restriction, create a corresponding sh:class or sh:datatype constraint.
sh:order 4

 owlSomeValuesFromIRI2dashHasValueWithClass

rdfs:label owl:someValuesFrom with IRI to dash:hasValueWithClass
rdfs:comment For each owl:someValuesFrom restriction with an IRI, create a corresponding dash:hasValueWithClass constraint.
sh:order 4

 owlSomeValuesFrom2shMinCount1

rdfs:label owl:someValuesFrom to sh:minCount 1
rdfs:comment For each owl:someValuesFrom restriction, create a corresponding sh:minCount 1 constraint.
sh:order 4

 rdfsRange2shNode

rdfs:label rdfs:range with IRI to sh:class or sh:datatype
rdfs:comment For each relevant property that has an rdfs:range, creates an sh:node if the range yielded a NodeShape that has an sh:hasValue constraint, instead of an sh:class
sh:order 4

 owlUnionOfIRIs2rdfsSubClassOf

rdfs:label owl:unionOf IRIs to rdfs:subClassOf
rdfs:comment For each owl:unionOf that only consists of named classes, move these classes into "normal" rdfs:subClassOf triples.
sh:order 4

 owlOneOf2shIn

rdfs:label owl:oneOf on a datatype range to sh:in
rdfs:comment For each relevant property whose rdfs:range is a datatype enumerated by owl:oneOf, create an sh:in constraint listing the permitted values. Without this the enumeration is lost: the range is an rdfs:Datatype, so no sh:class or sh:datatype constraint can express which literals are allowed.
sh:order 5

 rdfsRange2shClassOrDatatype

rdfs:label rdfs:range with IRI to sh:class or sh:datatype
rdfs:comment For each relevant property that has an rdfs:range, create sh:class or sh:datatype constraint unless it already exists (from a restriction). A range counts as a datatype when it is declared as an rdfs:Datatype, when it is an XML Schema built-in, or when it is rdf:langString; testing the range itself rather than matching a fixed list of IRIs means any rdfs:Datatype - including one defined by owl:oneOf - yields sh:datatype. sh:class is never satisfied by a literal (SHACL Core, Sec. 4.1.1), so emitting it for a datatype range produces a constraint that can only fail.
sh:order 5

 rdfsRangeLiteral2shNodeKind

rdfs:label rdfs:range rdfs:Literal to sh:nodeKind sh:Literal
rdfs:comment For each relevant property that has an rdfs:range with value rdfs:Literal, create sh:nodeKind constraint.
sh:order 5

 owlMinQualifiedCardinalityOnClass2shQualifiedMinCount

rdfs:label owl:minQualifiedCardinality with owl:onClass to sh:qualifiedMinCount
rdfs:comment For each owl:minQualifiedCardinality restriction on an IRI class, create a corresponding (new) sh:qualifiedMinCount constraint, unless the owl:onClass is identical to the rdfs:range of the property.
sh:order 6

 owlMaxQualifiedCardinalityOnClass2shQualifiedMaxCount

rdfs:label owl:maxQualifiedCardinality with owl:onClass to sh:qualifiedMaxCount
rdfs:comment For each owl:maxQualifiedCardinality restriction on an IRI class, create a corresponding (new) sh:qualifiedMaxCount constraint, unless the owl:onClass is identical to the rdfs:range of the property.
sh:order 6

 owlMaxQualifiedCardinalityOnClass2shMaxCount

rdfs:label owl:maxQualifiedCardinality with owl:onClass to sh:maxCount
rdfs:comment For each owl:maxQualifiedCardinality restriction on an IRI class, create a corresponding sh:maxCount constraint, if the owl:onClass is identical to the rdfs:range of the property.
sh:order 6

 owlQualifiedCardinalityOnDataRange2shQualifiedMinMaxCount

rdfs:label owl:qualifiedCardinality with owl:onDataRange to sh:qualifiedMax/MinCount
rdfs:comment For each owl:qualifiedCardinality restriction on an IRI datatype, create a corresponding (new) sh:qualifiedMax/MinCount constraint.
sh:order 6

 owlMinQualifiedCardinalityOnDataRange2shQualifiedMinCount

rdfs:label owl:minQualifiedCardinality with owl:onDataRange to sh:qualifiedMinCount
rdfs:comment For each owl:minQualifiedCardinality restriction on an IRI datatype, create a corresponding (new) sh:qualifiedMinCount constraint.
sh:order 6

 owlMaxQualifiedCardinalityOnDataRange2shQualifiedMaxCount

rdfs:label owl:maxQualifiedCardinality with owl:onDataRange to sh:qualifiedMaxCount
rdfs:comment For each owl:maxQualifiedCardinality restriction on an IRI datatype, create a corresponding (new) sh:qualifiedMaxCount constraint.
sh:order 6

 owlQualifiedCardinalityOnClass2shMinMaxCount

rdfs:label owl:qualifiedCardinality with owl:onClass to sh:max/minCount
rdfs:comment For each owl:qualifiedCardinality restriction on an IRI class, create corresponding sh:max/minCount constraints, if the owl:onClass is identical to the rdfs:range of the property.
sh:order 6

 owlMaxQualifiedCardinalityOnDataRange2shMaxCount

rdfs:label owl:maxQualifiedCardinality with owl:onDataRange to sh:maxCount
rdfs:comment Data-property counterpart of owlMaxQualifiedCardinalityOnClass2shMaxCount. For each owl:maxQualifiedCardinality restriction whose owl:onDataRange is an IRI identical to the property's rdfs:range, create a plain sh:maxCount. In OWL 2 a data property cardinality restriction uses owl:onDataRange exactly as an object property restriction uses owl:onClass (OWL 2 Web Ontology Language Structural Specification, Sec. 8.5 'Data Property Cardinality Restrictions'; Mapping to RDF Graphs, Sec. 3.2). When the qualifying datatype equals the property's global range (already mapped to sh:datatype by rdfsRange2shClassOrDatatype), the qualification is redundant, so - symmetric to the owl:onClass handling - it collapses to a plain sh:maxCount rather than sh:qualifiedMaxCount.
sh:order 6

 owlMinCardinality2shMinCount

rdfs:label owl:minCardinality to sh:minCount
rdfs:comment For each owl:minCardinality restriction, create a corresponding sh:minCount constraint.
sh:order 6

 owlMinQualifiedCardinalityOnDataRange2shMinCount

rdfs:label owl:minQualifiedCardinality with owl:onDataRange to sh:minCount
rdfs:comment Data-property counterpart of owlMinQualifiedCardinalityOnClass2shMinCount. For each owl:minQualifiedCardinality restriction whose owl:onDataRange is an IRI identical to the property's rdfs:range, create a plain sh:minCount. In OWL 2 a data property cardinality restriction uses owl:onDataRange exactly as an object property restriction uses owl:onClass (OWL 2 Web Ontology Language Structural Specification, Sec. 8.5 'Data Property Cardinality Restrictions'; Mapping to RDF Graphs, Sec. 3.2). When the qualifying datatype equals the property's global range (already mapped to sh:datatype by rdfsRange2shClassOrDatatype), the qualification is redundant, so - symmetric to the owl:onClass handling - it collapses to a plain sh:minCount rather than sh:qualifiedMinCount.
sh:order 6

 owlMaxCardinality2shMaxCount

rdfs:label owl:maxCardinality to sh:maxCount
rdfs:comment For each owl:maxCardinality restriction, create a corresponding sh:maxCount constraint.
sh:order 6

 owlQualifiedCardinalityOnClass2shQualifiedMinMaxCount

rdfs:label owl:qualifiedCardinality with owl:onClass to sh:qualifiedMax/MinCount
rdfs:comment For each owl:qualifiedCardinality restriction on an IRI class, create a corresponding (new) sh:qualifiedMax/MinCount constraint, unless the owl:onClass is identical to the rdfs:range of the property.
sh:order 6

 owlQualifiedCardinalityOnDataRange2shMinMaxCount

rdfs:label owl:qualifiedCardinality with owl:onDataRange to sh:max/minCount
rdfs:comment Data-property counterpart of owlQualifiedCardinalityOnClass2shMinMaxCount. For each owl:qualifiedCardinality restriction whose owl:onDataRange is an IRI identical to the property's rdfs:range, create plain sh:minCount and sh:maxCount. In OWL 2 a data property cardinality restriction uses owl:onDataRange exactly as an object property restriction uses owl:onClass (OWL 2 Web Ontology Language Structural Specification, Sec. 8.5 'Data Property Cardinality Restrictions'; Mapping to RDF Graphs, Sec. 3.2). When the qualifying datatype equals the property's global range (already mapped to sh:datatype by rdfsRange2shClassOrDatatype), the qualification is redundant, so - symmetric to the owl:onClass handling - it collapses to plain sh:minCount/sh:maxCount rather than sh:qualifiedMinCount/sh:qualifiedMaxCount.
sh:order 6

 owlMinQualifiedCardinalityOnClass2shMinCount

rdfs:label owl:minQualifiedCardinality with owl:onClass to sh:minCount
rdfs:comment For each owl:minQualifiedCardinality restriction on an IRI class, create a corresponding sh:minCount constraint, if the owl:onClass is identical to the rdfs:range of the property.
sh:order 6

 owlSomeValuesFromAllValuesFrom2dashHasValueWithClass

rdfs:label owl:someValuesFrom with IRI to dash:hasValueWithClass
rdfs:comment For each owl:someValuesFrom restriction combined with an owl:allValuesFrom on an IRI, create a corresponding dash:hasValueWithClass constraint using a path expression. For example: ex:ConstitutionalOwner a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:isPlayedBy ; owl:someValuesFrom [ a owl:Restriction ; owl:allValuesFrom ex:StockholdersEquity ; owl:onProperty ex:holdsEquityIn ; ] ; ] . becomes ex:ConstitutionalOwner a sh:NodeShape ; sh:property [ sh:path ( ex:isPlayedBy ex:holdsEquityIn ) ; dash:hasValueWithClass ex:StockholdersEquity ; ] .
sh:order 7

 owlHasValue2shHasValue

rdfs:label owl:hasValue to sh:hasValue
rdfs:comment For each owl:hasValue restriction, create a corresponding sh:hasValue constraint.
sh:order 8

 shPropertyShapeCleanUp

rdfs:label sh:property shape clean up
rdfs:comment For each value of sh:property, add a rdf:type sh:PropertyShape triple.
sh:order 100