Skip to content

Instantly share code, notes, and snippets.

@simonstey
Last active April 18, 2019 04:36
Show Gist options
  • Save simonstey/e3add7ff0740dd95a4c80d26840ca3e3 to your computer and use it in GitHub Desktop.
Save simonstey/e3add7ff0740dd95a4c80d26840ca3e3 to your computer and use it in GitHub Desktop.
Question on value based constraints
@prefix ex: <http://example.org/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:Alice
a ex:Person ;
ex:hasAddress "Street xzy plz 12345 ..." ;
ex:addressType "simpleAddress".
ex:Bob
a ex:Person ;
ex:hasAddress ex:BobsAddress ;
ex:addressType "complexAddress" .
ex:BobsAddress
a ex:complexAddress ;
schema:streetAddress "1600 Amphitheatre Pkway" ;
schema:postalCode 9404 .
ex:Tom
a ex:Person ;
ex:hasAddress "Street xzy plz 12345 ..." ;
ex:addressType "complexAddress".
ex:Claire
a ex:Person ;
ex:hasAddress ex:ClairesAddress ;
ex:addressType "simpleAddress" .
ex:ClairesAddress
a ex:complexAddress ;
schema:streetAddress "1600 Amphitheatre Pkway" ;
schema:postalCode 9404 .
@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.org/ns#> .
ex:PersonShape
a sh:NodeShape ;
sh:targetClass ex:Person ;
sh:xone (
[
sh:property [
sh:path ex:hasAddress ;
sh:datatype xsd:string ;
] ;
sh:property [
sh:path ex:addressType ;
sh:hasValue "simpleAddress" ;
]
]
[
sh:property [
sh:path ex:hasAddress ;
sh:class ex:complexAddress ;
] ;
sh:property [
sh:path ex:addressType ;
sh:hasValue "complexAddress" ;
]
]
) .
[
a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:XoneConstraintComponent ;
sh:sourceShape ex:PersonShape ;
sh:focusNode ex:Tom ;
sh:value ex:Tom ;
] .
[
a sh:ValidationResult ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:XoneConstraintComponent ;
sh:sourceShape ex:PersonShape ;
sh:focusNode ex:Claire ;
sh:value ex:Claire ;
] .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment