Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample data for SPARQL-based extraction of triples based on a SHACL validation result (here: no errors -> no ValidationResults)
# This example is taken from http://shacl.org/playground and
# transformed to trig, putting shapes, data and validation results in separate graphs
#
# Test case: there is an additional node in the data - ex:Paris - that is not covered by the shape.
# There are no validation results
# Expected result:
# <http://example.org/ns#Bob> schema:address <http://example.org/ns#BobsAddress>
# <http://example.org/ns#Bob> schema:birthDate 1971-07-07
# <http://example.org/ns#Bob> schema:birthPlace <http://example.org/ns#Paris>
# <http://example.org/ns#Bob> schema:deathDate 1998-09-10
# <http://example.org/ns#Bob> schema:familyName Junior
# <http://example.org/ns#Bob> schema:givenName Robert
# <http://example.org/ns#Bob> rdf:type schema:Person
# <http://example.org/ns#BobsAddress> schema:postalCode 19404
# <http://example.org/ns#BobsAddress> schema:streetAddress 1600 Amphitheatre Pkway
@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:shapes {
schema:PersonShape
a sh:NodeShape ;
sh:targetClass schema:Person ;
sh:property [
sh:path schema:givenName ;
sh:datatype xsd:string ;
sh:name "given name" ;
] ;
sh:property [
sh:path schema:birthDate ;
sh:lessThan schema:deathDate ;
sh:maxCount 1 ;
] ;
sh:property [
sh:path schema:gender ;
sh:in ( "female" "male" ) ;
] ;
sh:property [
sh:path schema:address ;
sh:node schema:AddressShape ;
] .
schema:AddressShape
a sh:NodeShape ;
sh:closed true ;
sh:property [
sh:path schema:streetAddress ;
sh:datatype xsd:string ;
] ;
sh:property [
sh:path schema:postalCode ;
sh:or ( [ sh:datatype xsd:string ] [ sh:datatype xsd:integer ] ) ;
sh:minInclusive 10000 ;
sh:maxInclusive 99999 ;
] .
}
ex:data {
ex:Bob
a schema:Person ;
schema:givenName "Robert" ;
schema:familyName "Junior" ;
schema:birthDate "1971-07-07"^^xsd:date ;
schema:deathDate "1998-09-10"^^xsd:date ;
schema:birthPlace ex:Paris ;
schema:address ex:BobsAddress .
ex:BobsAddress
schema:streetAddress "1600 Amphitheatre Pkway" ;
schema:postalCode 19404 .
ex:Paris a schema:Place;
schema:name "Paris"@en;
schema:name "Paris"@fr;
schema:name "Paris"@de.
}
ex:result {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.