I have added two cases (owl:unionOf with length 2 and 3 in the attached
update, which will also be part of TopBraid 7.3. Handling arbitrary
length lists would require JavaScript but I hope the provided solution
will keep you going.
Jan, I would appreciate if you could test this and let us know if it works.
Holger
On 2022-03-30 11:30 pm, David Price wrote:
FYI it’s not hard to extend the OWL2SHACL capability to handle more
complex cases.
See
https://www.topquadrant.com/doc/7.2/user_guide/guidance_specific_to_asset_collection_type/working_with_ontologies/shacl_enablement.html
Cheers,
David
On 30 Mar 2022, at 14:11, Jan Voskuil <[email protected]> wrote:
Hi,
We intend to convert an RDFS/OWL ontology to a shape file and, from
then on, work with SHACL.
So, we are very happy with the conversion functionality.
It appears that unions of datatype ranges are not converted. Thus,
x:someProperty
rdf:type owl:DatatypeProperty ;
rdfs:domain x:Domain ;
rdfs:range [
rdf:type owl:Class ;
owl:unionOf (
xsd:date
xsd:gYearMonth
xsd:gYear
) ;
] ;
.
Results in:
x:Domain-someProperty
rdf:type sh:PropertyShape ;
sh:pathx:someProperty;
.
With no range indicated. Unions that are the value of rdfs:domain are
converted correctly. Best regards, -Jan
*Jan Voskuil*| CEO Taxonic | Ontologist
Veldzigt 2, 3454 PW,De Meern, The Netherlands
T+31 (0)88 829 66 00| M:+31 (0)6 14488335
[email protected]
<mailto:[email protected]>|www.taxonic.com
<http://www.taxonic.com/>
Registered office in Den Haag, The Netherlands
Registration Number Chamber of Commerce: 54529190
--
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email [email protected].
To view this discussion on the web
visithttps://groups.google.com/d/msgid/topbraid-users/AM0PR03MB37455EFCF930C93E291E3E6EE91F9%40AM0PR03MB3745.eurprd03.prod.outlook.com
<https://groups.google.com/d/msgid/topbraid-users/AM0PR03MB37455EFCF930C93E291E3E6EE91F9%40AM0PR03MB3745.eurprd03.prod.outlook.com?utm_medium=email&utm_source=footer>.
UK +44 (0) 7788 561308
US +1 (336) 283-0808
--
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/6A4932F1-81D3-444C-BBB9-988A91B66BE1%40topquadrant.com
<https://groups.google.com/d/msgid/topbraid-users/6A4932F1-81D3-444C-BBB9-988A91B66BE1%40topquadrant.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "TopBraid
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/9d71af49-048c-11a7-489e-7540b4a0ab25%40topquadrant.com.
# baseURI: http://datashapes.org/owl2shacl
# imports: http://datashapes.org/dash
# prefix: owl2shacl
@prefix dash: <http://datashapes.org/dash#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix owl2shacl: <http://datashapes.org/owl2shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix swa: <http://topbraid.org/swa#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://datashapes.org/owl2shacl>
a owl:Ontology ;
rdfs:comment """A collection of SHACL rules that take an RDFS/OWL ontology as
input and produce corresponding SHACL statements, essentially adding
closed-world semantics on top of the classes.
Many rules produce mapping metadata that can be used to track which of the
anonymous superclasses have been converted and could be removed from the OWL
model.""" ;
rdfs:label "OWL to SHACL conversion rules" ;
owl:imports <http://datashapes.org/dash> ;
sh:declare [
a sh:PrefixDeclaration ;
sh:namespace "http://datashapes.org/owl2shacl#"^^xsd:anyURI ;
sh:prefix "owl2shacl" ;
] ;
.
owl2shacl:AddTypeNodeShape
a sh:SPARQLRule ;
rdfs:comment "Makes sure that each class also has rdf:type sh:NodeShape." ;
rdfs:label "Add type node shape" ;
sh:construct """CONSTRUCT {
$this a sh:NodeShape .
}
WHERE {
}""" ;
sh:order "0"^^xsd:decimal ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:ClassShape
a sh:NodeShape ;
rdfs:comment "Creates SHACL constraints from RDFS and OWL restrictions
attached to the given classes." ;
sh:rule owl2shacl:AddTypeNodeShape ;
sh:rule owl2shacl:CopyEquivalentIntersection ;
sh:rule owl2shacl:CreatePropertyShapesFromMatchingDomains ;
sh:rule owl2shacl:CreatePropertyShapesFromRestrictions ;
sh:rule owl2shacl:FlattenIntersectionOf ;
sh:rule owl2shacl:owlAllValuesFrom2shClassOrDatatype ;
sh:rule owl2shacl:owlAllValuesFromUnion2shClassOrDatatype ;
sh:rule owl2shacl:owlDisjointWith2NotClass ;
sh:rule owl2shacl:owlFunctionalProperty2shMaxCount1 ;
sh:rule owl2shacl:owlHasValue2shHasValue ;
sh:rule owl2shacl:owlMaxCardinality2shMaxCount ;
sh:rule owl2shacl:owlMaxQualifiedCardinalityOnClass2shMaxCount ;
sh:rule owl2shacl:owlMaxQualifiedCardinalityOnClass2shQualifiedMaxCount ;
sh:rule owl2shacl:owlMaxQualifiedCardinalityOnDataRange2shQualifiedMaxCount ;
sh:rule owl2shacl:owlMinCardinality2shMinCount ;
sh:rule owl2shacl:owlMinQualifiedCardinalityOnClass2shMinCount ;
sh:rule owl2shacl:owlMinQualifiedCardinalityOnClass2shQualifiedMinCount ;
sh:rule owl2shacl:owlMinQualifiedCardinalityOnDataRange2shQualifiedMinCount ;
sh:rule owl2shacl:owlQualifiedCardinalityOnClass2shMinMaxCount ;
sh:rule owl2shacl:owlQualifiedCardinalityOnClass2shQualifiedMinMaxCount ;
sh:rule owl2shacl:owlQualifiedCardinalityOnDataRange2shQualifiedMinMaxCount ;
sh:rule owl2shacl:owlSomeValuesFrom2shMinCount1 ;
sh:rule owl2shacl:owlSomeValuesFromAllValuesFrom2dashHasValueWithClass ;
sh:rule owl2shacl:owlSomeValuesFromIRI2dashHasValueWithClass ;
sh:rule owl2shacl:owlSomeValuesFromUnion2dashHasValueWithClass ;
sh:rule owl2shacl:rdfsRange2shClassOrDatatype ;
sh:rule owl2shacl:rdfsRangeLength2Union2shOr ;
sh:rule owl2shacl:rdfsRangeLength3Union2shOr ;
sh:rule owl2shacl:shPropertyShapeCleanUp ;
sh:rule owl2shacl:xsdLength2shMaxMinLength ;
sh:rule owl2shacl:xsdMaxExclusive2shMaxExclusive ;
sh:rule owl2shacl:xsdMaxInclusive2shMaxInclusive ;
sh:rule owl2shacl:xsdMaxLength2shMaxLength ;
sh:rule owl2shacl:xsdMinExclusive2shMinExclusive ;
sh:rule owl2shacl:xsdMinInclusive2shMinInclusive ;
sh:rule owl2shacl:xsdMinLength2shMinLength ;
sh:rule owl2shacl:xsdPattern2shPattern ;
sh:target [
a sh:SPARQLTarget ;
rdfs:comment "Targets all named classes, skipping blank nodes such as
owl:Restrictions and system namespace classes" ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
sh:select """SELECT ?this
WHERE {
{
?type rdfs:subClassOf* rdfs:Class .
?this a ?type .
FILTER isIRI(?this) .
}
FILTER (afn:namespace(?this) NOT IN (
"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"http://www.w3.org/2000/01/rdf-schema#",
"http://www.w3.org/2002/07/owl#",
"http://www.w3.org/2001/XMLSchema#"))
}""" ;
] ;
.
owl2shacl:CopyEquivalentIntersection
a sh:SPARQLRule ;
rdfs:comment "Copies any intersections within owl:equivalentClass into the
host class itself so that subsequent rules convert them further." ;
rdfs:label "Copy owl:intersectionOfs from owl:equivalentClass" ;
sh:construct """CONSTRUCT {
$this owl:intersectionOf ?inter .
}
WHERE {
$this owl:equivalentClass ?equi .
FILTER isBlank(?equi) .
?equi owl:intersectionOf ?inter .
}""" ;
sh:order -1 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:CreatePropertyShapesFromMatchingDomains
a sh:SPARQLRule ;
rdfs:comment "Creates a sh:property shape for each property with matching
rdfs:domain." ;
rdfs:label "rdfs:domain to sh:property" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
}
WHERE {
{
?property rdfs:domain $this .
}
UNION {
?unionOf rdf:rest*/rdf:first $this .
?domain owl:unionOf ?unionOf .
?property rdfs:domain ?domain .
}
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 2 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:CreatePropertyShapesFromRestrictions
a sh:SPARQLRule ;
rdfs:comment "Creates a sh:property shape for each property that is mentioned
in an owl:Restriction." ;
rdfs:label "owl:onProperty to sh:property" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
}
WHERE {
$this rdfs:subClassOf/owl:onProperty ?property .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 1 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:FlattenIntersectionOf
a sh:SPARQLRule ;
rdfs:comment "Copies the members of an owl:intersectionOf list as
superclasses into the host class itself. Subsequent rules then apply." ;
rdfs:label "Flatten owl:intersectionOf" ;
sh:construct """CONSTRUCT {
$this rdfs:subClassOf ?superClass .
}
WHERE {
$this owl:intersectionOf ?list .
?list rdf:rest*/rdf:first ?superClass .
FILTER isBlank(?superClass) .
}""" ;
sh:order 0 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:OWL2SHACLJSLibrary
a sh:JSLibrary ;
sh:jsLibrary dash:DASHJSLibrary ;
sh:jsLibraryURL "http://TopBraid/SHACL/owl2shacl.js"^^xsd:anyURI ;
.
owl2shacl:baseDatatype
a sh:SPARQLFunction ;
rdfs:label "base datatype" ;
sh:parameter [
a sh:Parameter ;
sh:path owl2shacl:datatype ;
sh:class rdfs:Datatype ;
sh:description "The datatype that is either returned as-is or that may
have a owl:onDatatype." ;
sh:name "datatype" ;
sh:nodeKind sh:IRI ;
] ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
sh:returnType rdfs:Datatype ;
sh:select """SELECT ?result
WHERE {
OPTIONAL {
$datatype (owl:onDatatype |
(owl:equivalentClass/owl:onDatatype)) ?base
}
BIND(COALESCE(?base, $datatype) AS ?result) .
}""" ;
.
owl2shacl:createPropertyShapeURIs
a rdf:Property ;
rdfs:comment "A flag that informs the engine as to whether it should create
property shape URIs. Needs to be set to true for any subject in the shapes
graph." ;
rdfs:label "create property shape URIs" ;
rdfs:range xsd:boolean ;
.
owl2shacl:createPropertyShapeURIsWithPrefixes
a rdf:Property ;
rdfs:comment "A flag that informs the engine as to whether it should include
a namespace prefix into the property shape URIs." ;
rdfs:label "create property shape URIs with prefixes" ;
rdfs:range xsd:boolean ;
.
owl2shacl:getPropertyShape
a sh:SPARQLFunction ;
dash:private true ;
rdfs:comment "Gets an existing sh:PropertyShape for a given property at a
given shape. If none is found, return a new blank node that will be reused by
future calls." ;
rdfs:label "get property shape" ;
sh:parameter [
sh:path owl2shacl:predicate ;
sh:class rdf:Property ;
sh:description "The predicate to match." ;
] ;
sh:parameter [
sh:path owl2shacl:shape ;
sh:class sh:Shape ;
sh:description "The shape hosting the constraint." ;
] ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
sh:returnType sh:PropertyShape ;
sh:select """
SELECT ?result
WHERE {
{
?shape sh:property ?result .
?result sh:path ?predicate .
}
UNION
{
BIND (IF(isIRI($shape) && EXISTS { ?any
owl2shacl:createPropertyShapeURIs true },
IRI(CONCAT(str($shape), "-", IF(EXISTS
{ ?any owl2shacl:createPropertyShapeURIsWithPrefixes true },
spif:replaceAll(smf:qname(?predicate), ":", "_"), afn:localname(?predicate)))),
BNODE()) AS ?result) .
}
}
""" ;
.
owl2shacl:isDatatypeRange
a sh:SPARQLFunction ;
sh:ask """
ASK WHERE {
FILTER bound(?range) .
FILTER ((?range = rdfs:Literal) ||
EXISTS { ?range a rdfs:Datatype } ||
EXISTS { ?range owl:equivalentClass/rdf:type
rdfs:Datatype } ||
EXISTS {
GRAPH <http://datashapes.org/owl2shacl>
{
?range a rdfs:Datatype .
}
}) .
}
""" ;
sh:parameter [
sh:path owl2shacl:range ;
sh:class rdfs:Class ;
sh:description "The range to test." ;
] ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
sh:returnType xsd:boolean ;
.
owl2shacl:mappedFromDatatype
a rdf:Property ;
rdfs:comment "Remembers the original datatype used to derive a sh:datatype
from. Used by follow-up rules to copy datatype facets such as xsd:minLength
into corresponding SHACL constraints. The triples are discarded after the rules
complete." ;
rdfs:label "mapped from datatype" ;
.
owl2shacl:mappedTo
a rdf:Property ;
rdfs:comment "Associates an OWL/RDFS subject with one or more SHACL subjects
that have been produced by the mapping rules. Statements that have been mapped
to others can in principle be deleted. This is currently only used to flag
blank nodes that appear in rdfs:subClassOf triples." ;
rdfs:label "mapped to" ;
.
owl2shacl:owlAllValuesFrom2shClassOrDatatype
a sh:SPARQLRule ;
rdfs:comment "For each owl:allValuesFrom restriction, create a corresponding
sh:class or sh:datatype constraint." ;
rdfs:label "owl:allValuesFrom with IRI to sh:class or sh:datatype" ;
sh:construct """
CONSTRUCT {
?propertyShape ?parameter ?value .
?restriction owl2shacl:mappedTo ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype
?mappedFromDatatype .
}
WHERE {
{
{
$this rdfs:subClassOf
?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:onProperty ?property .
?restriction owl:allValuesFrom
?allValuesFrom .
FILTER isIRI(?allValuesFrom) .
}
BIND (owl2shacl:isDatatypeRange(?allValuesFrom)
AS ?isDatatype) .
BIND (IF(?isDatatype, sh:datatype, sh:class) AS
?parameter) .
BIND (IF(?isDatatype,
owl2shacl:baseDatatype(?allValuesFrom), ?allValuesFrom) AS ?value) .
BIND (IF(?isDatatype, ?allValuesFrom, ?none) AS
?mappedFromDatatype) .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 4 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlAllValuesFromUnion2shClassOrDatatype
a sh:JSRule ;
rdfs:comment "For each owl:allValuesFrom that has an owl:unionOf as its
value, create a sh:or of sh:class or sh:datatype shapes." ;
rdfs:label "owl:allValuesFrom with union to sh:or of sh:class or sh:datatype"
;
sh:jsFunctionName "owlAllValuesFromUnion2shClassOrDatatype" ;
sh:jsLibrary owl2shacl:OWL2SHACLJSLibrary ;
sh:order "4"^^xsd:decimal ;
.
owl2shacl:owlDisjointWith2NotClass
a sh:SPARQLRule ;
rdfs:comment "For each owl:disjointWith from class A to B, create one
constraint at A with the pattern sh:not [ sh:class B ]." ;
rdfs:label "owl:disjointWith to sh:not/sh:class" ;
sh:construct """CONSTRUCT {
$this sh:not ?class .
?class sh:class ?disjointWith .
?class rdfs:label ?label .
}
WHERE {
$this owl:disjointWith ?disjointWith .
FILTER isIRI(?disjointWith) .
BIND (BNODE() AS ?class) .
BIND (<http://uispin.org/ui#label>(?disjointWith) AS ?l) .
BIND (CONCAT("Instance of ", ?l) AS ?label)
}""" ;
sh:order "1"^^xsd:decimal ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlFunctionalProperty2shMaxCount1
a sh:SPARQLRule ;
rdfs:comment "For each relevant property that is owl:FunctionalProperty,
create sh:maxCount of 1 (unless there is an OWL cardinality restriction)." ;
rdfs:label "owl:FunctionalProperty to sh:maxCount 1" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:maxCount 1 .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
?property a owl:FunctionalProperty .
FILTER NOT EXISTS {
$this rdfs:subClassOf* ?class .
?class rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
?restriction owl:onProperty ?property .
?restriction
owl:maxCardinality|owl:cardinality ?any .
}
}
""" ;
sh:order 3 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlHasValue2shHasValue
a sh:SPARQLRule ;
rdfs:comment "For each owl:hasValue restriction, create a corresponding
sh:hasValue constraint." ;
rdfs:label "owl:hasValue to sh:hasValue" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:hasValue ?hasValue .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:onProperty ?property .
?restriction owl:hasValue ?hasValue .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 8 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMaxCardinality2shMaxCount
a sh:SPARQLRule ;
rdfs:comment "For each owl:maxCardinality restriction, create a corresponding
sh:maxCount constraint." ;
rdfs:label "owl:maxCardinality to sh:maxCount" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:maxCount ?maxCount .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
?restriction owl:onProperty ?property .
?restriction owl:maxCardinality|owl:cardinality
?raw .
BIND (xsd:integer(?raw) AS ?maxCount) .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMaxQualifiedCardinalityOnClass2shMaxCount
a sh:SPARQLRule ;
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." ;
rdfs:label "owl:maxQualifiedCardinality with owl:onClass to sh:maxCount" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:maxCount ?maxCount .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:maxQualifiedCardinality ?raw .
?restriction owl:onProperty ?property .
?restriction owl:onClass ?onClass .
FILTER isIRI(?onClass) .
FILTER EXISTS { ?property rdfs:range ?onClass }
.
BIND (xsd:integer(?raw) AS ?maxCount) .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMaxQualifiedCardinalityOnClass2shQualifiedMaxCount
a sh:SPARQLRule ;
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." ;
rdfs:label "owl:maxQualifiedCardinality with owl:onClass to
sh:qualifiedMaxCount" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
?propertyShape sh:qualifiedMaxCount ?maxCount .
?propertyShape sh:qualifiedValueShape
?valueShape .
?valueShape sh:class ?onClass .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:maxQualifiedCardinality ?raw .
?restriction owl:onProperty ?property .
?restriction owl:onClass ?onClass .
FILTER isIRI(?onClass) .
FILTER NOT EXISTS { ?property rdfs:range
?onClass } .
BIND (xsd:integer(?raw) AS ?maxCount) .
BIND (BNODE() AS ?propertyShape) .
BIND (BNODE() AS ?valueShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMaxQualifiedCardinalityOnDataRange2shQualifiedMaxCount
a sh:SPARQLRule ;
rdfs:comment "For each owl:maxQualifiedCardinality restriction on an IRI
datatype, create a corresponding (new) sh:qualifiedMaxCount constraint." ;
rdfs:label "owl:maxQualifiedCardinality with owl:onDataRange to
sh:qualifiedMaxCount" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
?propertyShape sh:qualifiedMaxCount ?maxCount .
?propertyShape sh:qualifiedValueShape
?valueShape .
?valueShape sh:datatype ?onDataRange .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:maxQualifiedCardinality ?raw .
?restriction owl:onProperty ?property .
?restriction owl:onDataRange ?onDataRange .
FILTER isIRI(?onDataRange) .
BIND (xsd:integer(?raw) AS ?maxCount) .
BIND (BNODE() AS ?propertyShape) .
BIND (BNODE() AS ?valueShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMinCardinality2shMinCount
a sh:SPARQLRule ;
rdfs:comment "For each owl:minCardinality restriction, create a corresponding
sh:minCount constraint." ;
rdfs:label "owl:minCardinality to sh:minCount" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:minCount ?maxCount .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:minCardinality|owl:cardinality
?raw .
?restriction owl:onProperty ?property .
BIND (xsd:integer(?raw) AS ?maxCount) .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 4 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMinQualifiedCardinalityOnClass2shMinCount
a sh:SPARQLRule ;
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." ;
rdfs:label "owl:minQualifiedCardinality with owl:onClass to sh:minCount" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:minCount ?minCount .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:minQualifiedCardinality ?raw .
?restriction owl:onClass ?onClass .
?restriction owl:onProperty ?property .
FILTER isIRI(?onClass) .
FILTER EXISTS { ?property rdfs:range ?onClass }
.
BIND (xsd:integer(?raw) AS ?minCount) .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMinQualifiedCardinalityOnClass2shQualifiedMinCount
a sh:SPARQLRule ;
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." ;
rdfs:label "owl:minQualifiedCardinality with owl:onClass to
sh:qualifiedMinCount" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
?propertyShape sh:qualifiedMinCount ?minCount .
?propertyShape sh:qualifiedValueShape
?valueShape .
?valueShape sh:class ?onClass .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:minQualifiedCardinality ?raw .
?restriction owl:onClass ?onClass .
?restriction owl:onProperty ?property .
FILTER isIRI(?onClass) .
FILTER NOT EXISTS { ?property rdfs:range
?onClass } .
BIND (xsd:integer(?raw) AS ?minCount) .
BIND (BNODE() AS ?propertyShape) .
BIND (BNODE() AS ?valueShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlMinQualifiedCardinalityOnDataRange2shQualifiedMinCount
a sh:SPARQLRule ;
rdfs:comment "For each owl:minQualifiedCardinality restriction on an IRI
datatype, create a corresponding (new) sh:qualifiedMinCount constraint." ;
rdfs:label "owl:minQualifiedCardinality with owl:onDataRange to
sh:qualifiedMinCount" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
?propertyShape sh:qualifiedMinCount ?minCount .
?propertyShape sh:qualifiedValueShape
?valueShape .
?valueShape sh:datatype ?onDataRange .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:minQualifiedCardinality ?raw .
?restriction owl:onDataRange ?onDataRange .
?restriction owl:onProperty ?property .
FILTER isIRI(?onDataRange) .
BIND (xsd:integer(?raw) AS ?minCount) .
BIND (BNODE() AS ?propertyShape) .
BIND (BNODE() AS ?valueShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlQualifiedCardinalityOnClass2shMinMaxCount
a sh:SPARQLRule ;
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." ;
rdfs:label "owl:qualifiedCardinality with owl:onClass to sh:max/minCount" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:maxCount ?count .
?propertyShape sh:minCount ?count .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:qualifiedCardinality ?raw .
?restriction owl:onClass ?onClass .
?restriction owl:onProperty ?property .
FILTER isIRI(?onClass) .
FILTER EXISTS { ?property rdfs:range ?onClass }
.
BIND (xsd:integer(?raw) AS ?count) .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlQualifiedCardinalityOnClass2shQualifiedMinMaxCount
a sh:SPARQLRule ;
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." ;
rdfs:label "owl:qualifiedCardinality with owl:onClass to
sh:qualifiedMax/MinCount" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
?propertyShape sh:qualifiedMaxCount ?count .
?propertyShape sh:qualifiedMinCount ?count .
?propertyShape sh:qualifiedValueShape
?valueShape .
?valueShape sh:class ?onClass .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:qualifiedCardinality ?raw .
?restriction owl:onClass ?onClass .
?restriction owl:onProperty ?property .
FILTER isIRI(?onClass) .
FILTER NOT EXISTS { ?property rdfs:range
?onClass } .
BIND (xsd:integer(?raw) AS ?count) .
BIND (BNODE() AS ?propertyShape) .
BIND (BNODE() AS ?valueShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlQualifiedCardinalityOnDataRange2shQualifiedMinMaxCount
a sh:SPARQLRule ;
rdfs:comment "For each owl:qualifiedCardinality restriction on an IRI
datatype, create a corresponding (new) sh:qualifiedMax/MinCount constraint." ;
rdfs:label "owl:qualifiedCardinality with owl:onDataRange to
sh:qualifiedMax/MinCount" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape sh:path ?property .
?propertyShape sh:qualifiedMaxCount ?count .
?propertyShape sh:qualifiedMinCount ?count .
?propertyShape sh:qualifiedValueShape
?valueShape .
?valueShape sh:datatype ?onDataRange .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:qualifiedCardinality ?raw .
?restriction owl:onDataRange ?onDataRange .
?restriction owl:onProperty ?property .
FILTER isIRI(?onDataRange) .
BIND (xsd:integer(?raw) AS ?count) .
BIND (BNODE() AS ?propertyShape) .
BIND (BNODE() AS ?valueShape) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlSomeValuesFrom2shMinCount1
a sh:SPARQLRule ;
rdfs:comment "For each owl:someValuesFrom restriction, create a corresponding
sh:minCount 1 constraint." ;
rdfs:label "owl:someValuesFrom to sh:minCount 1" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:minCount 1 .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
?restriction owl:someValuesFrom ?someValuesFrom
.
?restriction owl:onProperty ?property .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 4 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlSomeValuesFromAllValuesFrom2dashHasValueWithClass
a sh:SPARQLRule ;
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 ;
] .""" ;
rdfs:label "owl:someValuesFrom with IRI to dash:hasValueWithClass" ;
sh:construct """
CONSTRUCT {
$this sh:property ?propertyShape .
?propertyShape dash:hasValueWithClass
?allValuesFrom .
?propertyShape sh:path ?firstNode .
?firstNode rdf:first ?property .
?firstNode rdf:rest ?secondNode .
?secondNode rdf:first ?allValuesFromProperty .
?secondNode rdf:rest rdf:nil .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
{
$this rdfs:subClassOf
?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:someValuesFrom
?someValuesFrom .
?someValuesFrom owl:allValuesFrom
?allValuesFrom .
FILTER isIRI(?allValuesFrom) .
FILTER (!owl2shacl:isDatatypeRange(?allValuesFrom)) .
FILTER isBlank(?someValuesFrom) .
}
?restriction owl:onProperty ?property .
?someValuesFrom owl:onProperty
?allValuesFromProperty .
BIND (BNODE() AS ?propertyShape) .
BIND (BNODE() AS ?firstNode) .
BIND (BNODE() AS ?secondNode) .
}
""" ;
sh:order 7 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlSomeValuesFromIRI2dashHasValueWithClass
a sh:SPARQLRule ;
rdfs:comment "For each owl:someValuesFrom restriction with an IRI, create a
corresponding dash:hasValueWithClass constraint." ;
rdfs:label "owl:someValuesFrom with IRI to dash:hasValueWithClass" ;
sh:construct """
CONSTRUCT {
?propertyShape dash:hasValueWithClass
?someValuesFrom .
?restriction owl2shacl:mappedTo ?propertyShape .
}
WHERE {
{
$this rdfs:subClassOf ?restriction .
?restriction a owl:Restriction .
FILTER isBlank(?restriction) .
}
?restriction owl:someValuesFrom ?someValuesFrom
.
?restriction owl:onProperty ?property .
FILTER (isIRI(?someValuesFrom) &&
!owl2shacl:isDatatypeRange(?someValuesFrom)) .
FILTER NOT EXISTS { ?property rdfs:range
?someValuesFrom } .
BIND (owl2shacl:getPropertyShape(?property,
$this) AS ?propertyShape) .
}
""" ;
sh:order 4 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:owlSomeValuesFromUnion2dashHasValueWithClass
a sh:JSRule ;
rdfs:comment "For each owl:someValuesFrom that has an owl:unionOf as its
value, create a sh:or of dash:hasValueWithClass shapes." ;
rdfs:label "owl:someValuesFrom with union to sh:or of dash:hasValueWithClass"
;
sh:condition [
a sh:NodeShape ;
sh:sparql [
rdfs:comment "Don't perform this rule if any of the members of the
nested rdf:List are not IRIs." ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
sh:select """SELECT $this
WHERE {
$this rdfs:subClassOf/owl:someValuesFrom/owl:unionOf ?union .
?union rdf:rest*/rdf:first ?member .
FILTER (isBlank(?member) || owl2shacl:isDatatypeRange(?member)) .
}""" ;
] ;
] ;
sh:jsFunctionName "owlSomeValuesFromUnion2dashHasValueWithClass" ;
sh:jsLibrary owl2shacl:OWL2SHACLJSLibrary ;
sh:order "4"^^xsd:decimal ;
.
owl2shacl:propertyShapeLocalName
a rdf:Property ;
rdfs:comment "Populated in a pre-processing step, this adds a triple to each
property that has a duplicate local name with another property. The suggested
value is using the prefix of the namespace where possible." ;
rdfs:label "property shape local name" ;
.
owl2shacl:rdfsRange2shClassOrDatatype
a sh:SPARQLRule ;
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)." ;
rdfs:label "rdfs:range with IRI to sh:class or sh:datatype" ;
sh:construct """
CONSTRUCT {
?propertyShape ?parameter ?value .
?propertyShape owl2shacl:mappedFromDatatype
?mappedFromDatatype .
}
WHERE {
{
{
$this sh:property
?propertyShape .
FILTER NOT EXISTS {
?propertyShape sh:class|sh:datatype ?any } .
}
?propertyShape sh:path ?property .
?property rdfs:range ?range .
FILTER isIRI(?range) .
}
BIND (owl2shacl:isDatatypeRange(?range) AS
?isDatatype) .
BIND (IF(?isDatatype, sh:datatype, sh:class) AS
?parameter) .
BIND (IF(?isDatatype,
owl2shacl:baseDatatype(?range), ?range) AS ?value) .
BIND (IF(?isDatatype, ?range, ?none) AS
?mappedFromDatatype) .
}
""" ;
sh:order 5 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:rdfsRangeLength2Union2shOr
a sh:SPARQLRule ;
rdfs:comment "For each relevant property that has an rdfs:range with a
owl:unionOf of length 2, create a sh:or of sh:class or sh:datatype constraint
unless a sh:class or sh:datatype already exists." ;
rdfs:label "rdfs:range with length 2 union to sh:or" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:or ?newItem1 .
?newItem1 rdf:first ?shape1 .
?shape1 ?parameter1 ?value1 .
?newItem1 rdf:rest ?newItem2 .
?newItem2 rdf:first ?shape2 .
?shape2 ?parameter2 ?value2 .
?newItem2 rdf:rest rdf:nil .
}
WHERE {
{
{
$this sh:property
?propertyShape .
FILTER NOT EXISTS {
?propertyShape sh:class|sh:datatype ?any } .
}
?propertyShape sh:path ?property .
?property rdfs:range ?range .
FILTER isBlank(?range) .
?range owl:unionOf ?list .
?list rdf:first ?range1 .
?list rdf:rest ?item2 .
?item2 rdf:first ?range2 .
?item2 rdf:rest rdf:nil .
FILTER (isIRI(?range1) &&
isIRI(?range2)) .
}
BIND (owl2shacl:isDatatypeRange(?range1) AS
?isDatatype1) .
BIND (owl2shacl:isDatatypeRange(?range2) AS
?isDatatype2) .
BIND (IF(?isDatatype1, sh:datatype, sh:class)
AS ?parameter1) .
BIND (IF(?isDatatype2, sh:datatype, sh:class)
AS ?parameter2) .
BIND (IF(?isDatatype1,
owl2shacl:baseDatatype(?range1), ?range1) AS ?value1) .
BIND (IF(?isDatatype2,
owl2shacl:baseDatatype(?range2), ?range2) AS ?value2) .
BIND (BNODE() AS ?newItem1) .
BIND (BNODE() AS ?newItem2) .
BIND (BNODE() AS ?shape1) .
BIND (BNODE() AS ?shape2) .
}
""" ;
sh:order 5 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:rdfsRangeLength3Union2shOr
a sh:SPARQLRule ;
rdfs:comment "For each relevant property that has an rdfs:range with a
owl:unionOf of length 3, create a sh:or of sh:class or sh:datatype constraint
unless a sh:class or sh:datatype already exists." ;
rdfs:label "rdfs:range with length 3 union to sh:or" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:or ?newItem1 .
?newItem1 rdf:first ?shape1 .
?shape1 ?parameter1 ?value1 .
?newItem1 rdf:rest ?newItem2 .
?newItem2 rdf:first ?shape2 .
?shape2 ?parameter2 ?value2 .
?newItem2 rdf:rest ?newItem3 .
?newItem3 rdf:first ?shape3 .
?shape3 ?parameter3 ?value3 .
?newItem3 rdf:rest rdf:nil .
}
WHERE {
{
{
$this sh:property
?propertyShape .
FILTER NOT EXISTS {
?propertyShape sh:class|sh:datatype ?any } .
}
?propertyShape sh:path ?property .
?property rdfs:range ?range .
FILTER isBlank(?range) .
?range owl:unionOf ?list .
?list rdf:first ?range1 .
?list rdf:rest ?item2 .
?item2 rdf:first ?range2 .
?item2 rdf:rest ?item3 .
?item3 rdf:first ?range3 .
?item3 rdf:rest rdf:nil .
FILTER (isIRI(?range1) &&
isIRI(?range2) && isIRI(?range3)) .
}
BIND (owl2shacl:isDatatypeRange(?range1) AS
?isDatatype1) .
BIND (owl2shacl:isDatatypeRange(?range2) AS
?isDatatype2) .
BIND (owl2shacl:isDatatypeRange(?range3) AS
?isDatatype3) .
BIND (IF(?isDatatype1, sh:datatype, sh:class)
AS ?parameter1) .
BIND (IF(?isDatatype2, sh:datatype, sh:class)
AS ?parameter2) .
BIND (IF(?isDatatype3, sh:datatype, sh:class)
AS ?parameter3) .
BIND (IF(?isDatatype1,
owl2shacl:baseDatatype(?range1), ?range1) AS ?value1) .
BIND (IF(?isDatatype2,
owl2shacl:baseDatatype(?range2), ?range2) AS ?value2) .
BIND (IF(?isDatatype3,
owl2shacl:baseDatatype(?range3), ?range3) AS ?value3) .
BIND (BNODE() AS ?newItem1) .
BIND (BNODE() AS ?newItem2) .
BIND (BNODE() AS ?newItem3) .
BIND (BNODE() AS ?shape1) .
BIND (BNODE() AS ?shape2) .
BIND (BNODE() AS ?shape3) .
}
""" ;
sh:order 5 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:shPropertyShapeCleanUp
a sh:SPARQLRule ;
rdfs:comment "For each value of sh:property, add a rdf:type sh:PropertyShape
triple." ;
rdfs:label "sh:property shape clean up" ;
sh:construct """CONSTRUCT {
?propertyShape a sh:PropertyShape .
}
WHERE {
$this sh:property ?propertyShape .
}""" ;
sh:order "100"^^xsd:decimal ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdLength2shMaxMinLength
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:length to sh:maxLength and sh:minLength" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:minLength ?length .
?propertyShape sh:maxLength ?length .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:length) |
(owl:withRestrictions/rdf:rest*/rdf:first/xsd:length) ?lengthRaw .
BIND (xsd:integer(?lengthRaw) AS ?length) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdMaxExclusive2shMaxExclusive
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:maxExclusive to sh:maxExclusive" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:maxExclusive ?value .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:maxExclusive)
| (owl:withRestrictions/rdf:rest*/rdf:first/xsd:maxExclusive) ?value .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdMaxInclusive2shMaxInclusive
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:maxInclusive to sh:maxInclusive" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:maxInclusive ?value .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:maxInclusive)
| (owl:withRestrictions/rdf:rest*/rdf:first/xsd:maxInclusive) ?value .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdMaxLength2shMaxLength
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:maxLength to sh:maxLength" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:maxLength ?maxLength .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:maxLength) |
(owl:withRestrictions/rdf:rest*/rdf:first/xsd:maxLength) ?maxLengthRaw .
BIND (xsd:integer(?maxLengthRaw) AS ?maxLength) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdMinExclusive2shMinExclusive
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:minExclusive to sh:minExclusive" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:minExclusive ?value .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:minExclusive)
| (owl:withRestrictions/rdf:rest*/rdf:first/xsd:minExclusive) ?value .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdMinInclusive2shMinInclusive
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:minInclusive to sh:minInclusive" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:minInclusive ?value .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:minInclusive)
| (owl:withRestrictions/rdf:rest*/rdf:first/xsd:minInclusive) ?value .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdMinLength2shMinLength
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:minLength to sh:minLength" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:minLength ?minLength .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:minLength) |
(owl:withRestrictions/rdf:rest*/rdf:first/xsd:minLength) ?minLengthRaw .
BIND (xsd:integer(?minLengthRaw) AS ?minLength) .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
owl2shacl:xsdPattern2shPattern
a sh:SPARQLRule ;
rdfs:comment "Copies OWL 2 datatype restrictions into corresponding SHACL
constraints." ;
rdfs:label "xsd:pattern to sh:pattern" ;
sh:construct """
CONSTRUCT {
?propertyShape sh:pattern ?pattern .
}
WHERE {
$this sh:property ?propertyShape .
?propertyShape owl2shacl:mappedFromDatatype ?range .
?range
(owl:equivalentClass/owl:withRestrictions/rdf:rest*/rdf:first/xsd:pattern) |
(owl:withRestrictions/rdf:rest*/rdf:first/xsd:pattern) ?pattern .
}
""" ;
sh:order 6 ;
sh:prefixes <http://datashapes.org/owl2shacl> ;
.
rdf:HTML
a rdfs:Datatype ;
.
rdf:XMLLiteral
a rdfs:Datatype ;
.
xsd:ENTITY
a rdfs:Datatype ;
.
xsd:ID
a rdfs:Datatype ;
.
xsd:IDREF
a rdfs:Datatype ;
.
xsd:NCName
a rdfs:Datatype ;
.
xsd:NMTOKEN
a rdfs:Datatype ;
.
xsd:NOTATION
a rdfs:Datatype ;
.
xsd:Name
a rdfs:Datatype ;
.
xsd:QName
a rdfs:Datatype ;
.
xsd:anySimpleType
a rdfs:Datatype ;
.
xsd:anyURI
a rdfs:Datatype ;
.
xsd:base64Binary
a rdfs:Datatype ;
.
xsd:boolean
a rdfs:Datatype ;
.
xsd:byte
a rdfs:Datatype ;
.
xsd:date
a rdfs:Datatype ;
.
xsd:dateTime
a rdfs:Datatype ;
.
xsd:decimal
a rdfs:Datatype ;
.
xsd:double
a rdfs:Datatype ;
.
xsd:duration
a rdfs:Datatype ;
.
xsd:float
a rdfs:Datatype ;
.
xsd:gDay
a rdfs:Datatype ;
.
xsd:gMonth
a rdfs:Datatype ;
.
xsd:gMonthDay
a rdfs:Datatype ;
.
xsd:gYear
a rdfs:Datatype ;
.
xsd:gYearMonth
a rdfs:Datatype ;
.
xsd:hexBinary
a rdfs:Datatype ;
.
xsd:int
a rdfs:Datatype ;
.
xsd:integer
a rdfs:Datatype ;
.
xsd:language
a rdfs:Datatype ;
.
xsd:long
a rdfs:Datatype ;
.
xsd:negativeInteger
a rdfs:Datatype ;
.
xsd:nonNegativeInteger
a rdfs:Datatype ;
.
xsd:nonPositiveInteger
a rdfs:Datatype ;
.
xsd:normalizedString
a rdfs:Datatype ;
.
xsd:positiveInteger
a rdfs:Datatype ;
.
xsd:short
a rdfs:Datatype ;
.
xsd:string
a rdfs:Datatype ;
.
xsd:time
a rdfs:Datatype ;
.
xsd:token
a rdfs:Datatype ;
.
xsd:unsignedByte
a rdfs:Datatype ;
.
xsd:unsignedInt
a rdfs:Datatype ;
.
xsd:unsignedLong
a rdfs:Datatype ;
.
xsd:unsignedShort
a rdfs:Datatype ;
.