-
Notifications
You must be signed in to change notification settings - Fork 3
(SHACL) Validating RDF data using SHACL
Jose Emilio Labra Gayo edited this page Aug 14, 2024
·
10 revisions
We will make use of the UserShape example in SHACL from the Validating RDF Data book to demonstrate tha capabilities of the SHACL validator we propose.
According to this, an RDF graph conforming to the example above is:
:alice a :User; #Passes as a :UserShape
schema:name "Alice" ;
schema:gender schema:Female ;
schema:knows :bob .
:bob a :User; #Passes as a :UserShape
schema:gender schema:Male ;
schema:name "Robert";
schema:birthDate "1980-03-10"^^xsd:date .
:carol a :User; #Passes as a :UserShape
schema:name "Carol" ;
schema:gender schema:Female ;
foaf:name "Carol" .
For SHACL validation, we can use the generic validate
command and the specific shacl-validate
command.
rudof validate -M shacl -f turtle --schema examples/book.ttl examples/book_conformant.ttl
There is one shacl-validate
command which can also be used. The difference is that instead of schema
, it uses shapes
and it doesn't require to specify a Mode
:
rudof shacl-validate --shapes examples/book.ttl examples/book_conformant.ttl
An example of a non-conforming data graph is the following:
:dave a :User ; #Fails as a :UserShape
schema:name "Dave";
schema:gender :Unknown ;
schema:birthDate 1980 ;
schema:knows :grace .
:emily a :User ; #Fails as a :UserShape
schema:name "Emily", "Emilee";
schema:gender schema:Female .
:frank a :User ; #Fails as a :UserShape
foaf:name "Frank" ;
schema:gender schema:Male .
_:x a :User; #Fails as a :UserShape
schema:name "Unknown" ;
schema:gender schema:Male ;
schema:knows _:x .
And can be run as:
rudof shacl-validate --shapes examples/book.ttl examples/book_non-conformant.ttl
- (RDF) Information about a node in RDF file
- (RDF) Merge several RDF data files
- (RDF/SPARQL) Information about a node in Wikidata
- (ShEx) Show info about a schema
- (ShEx) Validate a specific node with a shape
- (SHACL) Show info about a SHACL schema
- (SHACL) Read a SHACL Shapes graph and convert to some format
- (SHACL) Validating RDF data using SHACL
- (SPARQL) Running SPARQL queries
- (Python) Invoking this library from Python
- (SHACL → ShEx) Convert SHACL shapes graph to ShEx schema
- (ShEx → SVG/PNG/...) Convert a ShEx schema to an UML-like visualization in SVG, PNG, ...
- (ShEx → HTML) Convert ShEx schemas to HTML views
- (ShEx → SPARQL) Convert a simple ShEx schema to SPARQL
- (DCTap → ShEx) Convert a CSV file in DCTap to a ShEx schema
- (DCTap → SVG/PNG/...) Convert a CSV file in DCTap to an UML-like visualization in SVG, PNG, ...