User:Realworldobject/SHACLExperiments
Jump to navigation
Jump to search
SHACL mapping test
[edit]The following query uses these:
- Properties: property constraint (P2302) , class (P2308)
PREFIX sh: <http://www.w3.org/ns/shacl#> PREFIX : <http://example.org/#> CONSTRUCT { ?nodeShape a sh:NodeShape ; sh:targetClass ?domain ; sh:property ?wdtShape . ?wdtShape a sh:PropertyShape; sh:path ?wdt ; sh:class (?range) ; sh:nodeKind sh:IRI } WHERE { VALUES ?class { wd:Q7366 } BIND(URI(CONCAT(STR(?class), "#nodeShape")) AS ?nodeShape) BIND(URI(CONCAT(STR(?wdt), "#wdtShape")) AS ?wdtShape) ?prop wikibase:directClaim ?wdt ; p:P2302 [ ps:P2302 wd:Q21503250 ; pq:P2308 ?domain ] ; p:P2302 [ ps:P2302 wd:Q21510865 ; pq:P2308 ?range ] }
SHACL Example shapes graph and Wikibase constraint equivalents
[edit]ex:PersonShape
a sh:NodeShape ;
sh:targetClass ex:Person ; # Applies to all persons
sh:property [ # _:b1
sh:path ex:ssn ; # constrains the values of ex:ssn
sh:maxCount 1 ;
sh:datatype xsd:string ;
sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;
] ;
sh:property [ # _:b2
sh:path ex:worksFor ;
sh:class ex:Company ;
sh:nodeKind sh:IRI ;
] ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) .