Skip to content

Instantly share code, notes, and snippets.

@James-Hudson3010
Created March 30, 2020 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save James-Hudson3010/2588d9b17dd33e15922122b8b5cf1bd7 to your computer and use it in GitHub Desktop.
Save James-Hudson3010/2588d9b17dd33e15922122b8b5cf1bd7 to your computer and use it in GitHub Desktop.
Testing pySHACL
@prefix hr: <http://learningsparql.com/ns/humanResources#> .
@prefix d: <http://learningsparql.com/ns/data#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
#### Regular RDFS modeling ####
hr:Employee a rdfs:Class .
hr:name
rdf:type rdf:Property ;
rdfs:domain hr:Employee .
hr:hireDate
rdf:type rdf:Property ;
rdfs:domain hr:Employee ;
rdfs:range xsd:date .
hr:jobGrade
rdf:type rdf:Property ;
rdfs:domain hr:Employee ;
rdfs:range xsd:integer .
#### Additional SHACL modeling ####
hr:Employee
# Following two lines are an alternative to the line above
#hr:EmployeeShape
# sh:targetClass hr:Employee ;
a sh:NodeShape ;
sh:property hr:nameShape ;
sh:property hr:jobGradeShape .
hr:nameShape
sh:path hr:name ;
sh:datatype xsd:string ;
sh:minCount 1 ;
sh:maxCount 1 .
hr:jobGradeShape
sh:path hr:jobGrade ;
sh:datatype xsd:integer ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:minInclusive 1;
sh:maxInclusive 7 .
#### Instance data ####
d:e1
a hr:Employee;
hr:name "Barry Wom" ;
hr:hireDate "2017-06-03" ;
hr:jobGrade 6 .
d:e2
a hr:Employee;
hr:name "Ron Nasty" ;
hr:hireDate "2017-08-11" . # Missing jobGrade
d:e3
a hr:Employee;
hr:name "Stig O'Hara" ;
hr:hireDate "2017-03-14" ;
hr:jobGrade 3.14 .
d:e4
a hr:Employee;
hr:name "Dirk McQuickly" ;
hr:hireDate "2017-01-08" ;
hr:jobGrade 8 .
@prefix hr: <http://learningsparql.com/ns/humanResources#> .
@prefix d: <http://learningsparql.com/ns/data#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
d:e1
a hr:Employee;
hr:name "Barry Wom" ;
hr:hireDate "2017-06-03" ;
hr:jobGrade 6 .
d:e2
a hr:Employee;
hr:name "Ron Nasty" ;
hr:hireDate "2017-08-11" . # Missing jobGrade
d:e3
a hr:Employee;
hr:name "Stig O'Hara" ;
hr:hireDate "2017-03-14" ;
hr:jobGrade 3.14 .
d:e4
a hr:Employee;
hr:name "Dirk McQuickly" ;
hr:hireDate "2017-01-08" ;
hr:jobGrade 8 .
@prefix hr: <http://learningsparql.com/ns/humanResources#> .
@prefix d: <http://learningsparql.com/ns/data#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
#### Regular RDFS modeling ####
hr:Employee a rdfs:Class .
hr:name
rdf:type rdf:Property ;
rdfs:domain hr:Employee .
hr:hireDate
rdf:type rdf:Property ;
rdfs:domain hr:Employee ;
rdfs:range xsd:date .
hr:jobGrade
rdf:type rdf:Property ;
rdfs:domain hr:Employee ;
rdfs:range xsd:integer .
@prefix hr: <http://learningsparql.com/ns/humanResources#> .
@prefix d: <http://learningsparql.com/ns/data#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
#### Additional SHACL modeling ####
hr:Employee
a sh:NodeShape ;
sh:property hr:nameShape ;
sh:property hr:jobGradeShape .
hr:nameShape
sh:path hr:name ;
sh:datatype xsd:string ;
sh:minCount 1 ;
sh:maxCount 1 .
hr:jobGradeShape
sh:path hr:jobGrade ;
sh:datatype xsd:integer ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:minInclusive 1;
sh:maxInclusive 7 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment