SlideShare a Scribd company logo
1 of 33
ShEx & SHACL compared
RDF Validation tutorial
Eric Prud'hommeaux
World Wide Web Consortium
MIT, Cambridge, MA, USA
Harold Solbrig
Mayo Clinic, USA
Jose Emilio Labra Gayo
WESO Research group
University of Oviedo, Spain
Iovka Boneva
LINKS, INRIA & CNRS
University of Lille, France
Common features
Similar goal: describe and validate RDF graphs
Both employ the word "shape"
Node constraints similar in both languages
Constraints on incoming/outgoing arcs
Cardinalities
RDF syntax
Extension mechanism
Some differences
Underlying philosophy
Syntactic differences
Notion of a shape
Syntactic differences
Default cardinalities
Shapes and Classes
Recursion
Repeated properties
Property pair constraints
Uniqueness
Extension mechanism
Underlying philosophy
ShEx is schema based
Shapes schemas look like RDF grammars
More focus on validation results
After validation, an enriched graph is
usually obtained
It contains valid nodes with their shapes
SHACL is constraint based
Shapes ≈ collections of constraints
Focus mainly on validation errors
Usually, no info about valid nodes
Difficult to distinguish valid nodes from nodes that
haven't been validated
Semantic specification
ShEx semantics is based on mathematical
concepts
It has been proven to be well-founded
Support for recursión and negation
Inspired by type systems and RelaxNG
SHACL semantics = SPARQL + textual description
SHACL terms described in natural language
SPARQL fragments used as helpers
Recursion is implementation dependent
SHACL-SPARQL is based on pre-binding
Syntactic differences
ShEx design focused on human-readability
Followed programming language design
methodology
1. Abstract syntax
2. Different concrete syntaxes
Compact
RDF
...
SHACL design focused on RDF vocabulary
Design centered on RDF terms
Lots of rules to define valid shapes graphs
https://w3c.github.io/data-shapes/shacl/#syntax-rules
Compact syntax added as a WG Note for a
subset of SHACL core
SHACL compact syntax copied from ShEx
Syntactically similar
Semantically different
Compact Syntax
ShEx compact syntax has been designed
along the language
Difficult to create bad shapes
Test-suite contains lots of tests
It is fully round-trippable with ShExJ and
ShExR
SHACL compact syntax was designed
after the language
It covers a subset of SHACL core
Incorrect shapes can be defined that pass the
grammar
One extra-step: After parsing and converting
to RDF, check production rules from RDF
shapes graph
:User {
minLength = :unknown .
maxLength = [ true 1 ] .
}
It parses the gramar but is rejected by production rules
Compact syntax: similar but different meanings
ShEx contains Boolean operators and
grammar based operators
Boolean: AND, OR, NOT
Grammar: grouping (;), alternative (|)
SHACL contains Boolean operators (and,
or, not, xone)
Only top-level expressions
. means conjunction
:Product {
:code IRI ;
:code xsd:integer
}
It means a product with 2 codes
(one IRI, and one integer)
It means the code of a product
must be an IRI and an integer
:p1 :code <http://code.org/P123> ;
:code 123 .  = conforms to Shape
= doesn't conform
:Product {
:code IRI .
:code xsd:integer
}
RDF vocabulary
ShEx vocabulary ≈ abstract syntax
ShEx RDF vocabulary obtained from the
abstract syntax
ShEx RDF serializations typically more verbose
They can be round-tripped to Compact syntax
SHACL is designed as an RDF vocabulary
Some rdf:type declarations can be omitted
SHACL RDF serialization typically more readable
:User a sx:Shape;
sx:expression [ a sx:EachOf ;
sx:expressions (
[ a sx:TripleConstraint ;
sx:predicate schema:name ;
sx:valueExpr [ a sx:NodeConstraint ;
sx:datatype xsd:string ]
]
[ a sx:TripleConstraint ;
sx:predicate schema:birthDate ;
sx:valueExpr [ a sx:NodeConstraint ;
sx:datatype xsd:date ] ;
sx:min 0
] )
].
:User a sh:NodeShape ;
sh:property [ sh:path schema:name ;
sh:minCount 1; sh:maxCount 1;
sh:datatype xsd:string
];
sh:property [ sh:path schema:birthDate ;
sh:maxCount 1;
sh:datatype xsd:date
] .
Notion of Shape
In ShEx, shapes define only structure of
nodes
Selection of focus nodes - shapes is made
by a different mechanism: shapes map
In SHACL, shapes define structure and
can have target declarations
Shapes can be associated with nodes or sets of
nodes through target declarations
:User a sh:NodeShape, rdfs:Class ;
sh:targetClass :Person ;
sh:targetNode :alice ;
sh:nodeKind sh:IRI ;
sh:property [
sh:path schema:name ;
sh:datatype xsd:string
] .
:User IRI {
schema:name xsd:string
}
target
declarations
structure
Triggering validation
ShEx uses Shape maps
Shape maps are external to schemas
Separation of concerns between validation
language and triggering mechanism
Differing possibilities to build the shapes map
can be explored
SHACL uses target declarations
Associate shapes with node sets
Possibilities:
Direct node: targetNode
Instance of some class: targetClass
Subjects of some predicate: targetSubjectsOf
Objects of some predicate: targetSubjectsOf
Target declarations can be part of the
shapes graph
Default cardinalities
ShEx: default = (1,1)
:User {
schema:givenName xsd:string
schema:lastName xsd:string
}
:User a sh:NodeShape ;
sh:property [ sh:path schema:givenName ;
sh:datatype xsd:string ;
];
sh:property [ sh:path schema:lastName ;
sh:datatype xsd:string ;
] .
:alice schema:givenName "Alice" ;
schema:lastName "Cooper" .
:bob schema:givenName "Bob", "Robert" ;
schema:lastName "Smith", "Dylan" .
:carol schema:lastName "King" .
:dave schema:givenName 23;
schema:lastName :Unknown .
SHACL: default = (0,unbounded)
 




  = conforms to Shape
= doesn't conform
Property paths
ShEx shapes describe neighborhood of
focus nodes: direct/inverse properties
Examples with paths can be simulated by
nested shapes
Sometimes requiring auxiliary recursive shapes
SHACL shapes can also describe whole
property paths following SPARQL paths
:GrandSon a sh:NodeShape ;
sh:property [
sh:path (schema:parent schema:parent) ;
sh:minCount 1
];
sh:property [
sh:path [
sh:alternativePath (:father :mother) ]
];
sh:minCount 1
] ;
sh:property [
sh:path [sh:inversePath :knows ] ]
sh:node :Person ;
sh:minCount 1
]
.
:GrandSon {
:parent { :parent . + } + ;
(:father . | :mother .) + ;
^:knows :Person
}
Inference
ShEx doesn't interact with inference
Validation can be invoked before or after
inference
rdf:type is considered an arc as any other
No special meaning
The same for rdfs:Class, rdfs:subClassOf,
rdfs:domain, rdfs:range, ...
Some constructs have special meaning
The following constructs have special
meaning in SHACL
rdf:type
rdfs:Class
rdfs:subClassOf
owl:imports
Other constructs like rdfs:domain,
rdfs:range,... have no special meaning
sh:entailment can be used to indicate that
some inference is required
Inference and triggering mechanism
ShEx has no interaction with inference
It can be used to validate a reasoner
In SHACL, RDF Schema inference can affect
which nodes are validated
:User a sh:NodeShape, rdfs:Class ;
sh:property [ sh:path schema:name ;
sh:datatype xsd:string;
].

RDFS
inference
No RDFS
inference
:Teacher rdfs:subClassOf :User .
:teaches rdfs:domain :Teacher .
:alice a :Teacher ;
schema:name 23 .
:bob :teaches :Algebra ;
schema:name 34 .
:carol :teaches :Logic;
schema:name "King" .
Ignored
Ignored



With or without
RDFS inference
:User {
schema:name xsd:string
}



 = conforms to Shape
= doesn't conform
Some implicit RDFS inference but not all
Repeated properties
ShEx (;) operator handles repeated
properties
SHACL needs qualifiedValueShapes for
repeated properties
Direct approximation (wrong)::Person {
:parent {:gender [:Male ] } ;
:parent {:gender [:Female ] }
}
:Person a sh:NodeShape;
sh:property [ sh:path :parent;
sh:node [ sh:property [ sh:path :gender ;
sh:hasValue :Male ; ]] ;
];
sh:property [ sh:path :parent;
sh:node [ sh:property [ sh:path :gender ;
sh:hasValue :Female ]];
]
.
Exercise: Example. A person must have 2
parents, one male and another female
Repeated properties
ShEx (;) operator handles repeated
properties
SHACL needs qualifiedValueShapes for
repeated properties
Solution with qualifiedValueShapes::Person {
:parent {:gender [:Male ] } ;
:parent {:gender [:Female ] }
}
:Person a sh:NodeShape, rdfs:Class ;
sh:property [ sh:path :parent;
sh:qualifiedValueShape [ sh:property [ sh:path :gender ;
sh:hasValue :Male ] ] ;
sh:qualifiedMinCount 1; sh:qualifiedMaxCount 1
];
sh:property [ sh:path :parent;
sh:qualifiedValueShape [ sh:property [ sh:path :gender ;
sh:hasValue :Female ] ] ;
sh:qualifiedMinCount 1; sh:qualifiedMaxCount 1
] ;
sh:property [ sh:path :parent;
sh:minCount 2; sh:maxCount 2
]
.
Exercise: Example. A person must have 2 parents, one male and another female
It needs to count all
possibilities
Recursion
ShEx handles recursion
Well founded semantics
Recursive shapes are undefined in SHACL
Implementation dependent
Direct translation generates recursive shapes
:Person {
schema:name xsd:string ;
schema:knows @:Person*
}
:Person a sh:NodeShape ;
sh:property [ sh:path schema:name ;
sh:datatype xsd:string
];
sh:property [ sh:path schema:knows ;
sh:node :Person
]
.
Recursion (with target declarations)
ShEx handles recursion
Well founded semantics
Recursive shapes are undefined in SHACL
Implementation dependent
Can be simulated with target declarations
Example with target declatations
It needs discriminating arcs
:Person {
schema:name xsd:string ;
schema:knows @:Person*
}
:Person a sh:NodeShape, rdfs:Class ;
sh:property [ sh:path schema:name ;
sh:datatype xsd:string
];
sh:property [ sh:path schema:knows ;
sh:class :Person
]
. It requires all nodes to have rdf:type Person
Recursion (with property paths)
ShEx handles recursion
Well founded semantics
Recursive shapes are undefined in SHACL
Implementation dependent
Can be simulated property paths
:Person {
schema:name xsd:string ;
schema:knows @:Person*
}
:Person a sh:NodeShape ;
sh:property [
sh:path schema:name ; sh:datatype xsd:string ];
sh:property [
sh:path [sh:zeroOrMorePath schema:knows];
sh:node :PersonAux
].
:PersonAux a sh:NodeShape ;
sh:property [
sh:path schema:name ; sh:datatype xsd:string
].
:Person a sh:NodeShape ;
sh:targetNode :alice ;
sh:closed true ;
sh:or (
[ sh:path schema:name ; sh:datatype xsd:string ]
[ sh:path foaf:name ; sh:datatype xsd:string ]
) .
Closed shapes
In ShEx, closed affects all properties In SHACL, closed only affects properties
declared at top-level
Properties declared inside other shapes
are ignored
:Person CLOSED {
schema:name xsd:string
| foaf:name xsd:string
}
:alice schema:name "Alice" . 
 = conforms to Shape
= doesn't conform
Closed shapes and paths
Closed in ShEx acts on all properties In SHACL, closed ignores properties
mentioned inside paths
:Person a sh:NodeShape ;
sh:closed true ;
sh:property [
sh:path [
sh:alternativePath
( schema:name foaf:name )
] ;
sh:minCount 1; sh:maxCount 1;
sh:datatype xsd:string ] ;
.
:Person CLOSED {
schema:name xsd:string |
foaf:name xsd:string
}
:alice schema:name "Alice".   = conforms to Shape
= doesn't conform
Property pair constraints
This feature was posponed in ShEx 2.0
ShEx 2.1 is expected to add support for
value comparisons
SHACL supports equals, disjoint, lessThan, ...
:UserShape a sh:NodeShape ;
sh:property [
sh:path schema:givenName ;
sh:datatype xsd:string ;
sh:disjoint schema:lastName
] ;
sh:property [
sh:path foaf:firstName ;
sh:equals schema:givenName ;
] ;
sh:property [
sh:path schema:birthDate ;
sh:datatype xsd:date ;
sh:lessThan :loginDate
] .
:UserShape {
$<givenName> schema:givenName xsd:string ;
$<firstName> schema:firstName xsd:string ;
$<birthDate> schema:birthDate xsd:date ;
$<loginDate> :loginDate xsd:date ;
$<givenName> = $<firstName> ;
$<givenName> != $<lastName> ;
$<birthDate> < $<loginDate>
}
Uniqueness (defining unique Keys)
This feature was postponed in ShEx 2.0 No support for generic unique keys
sh:uniqueLang offers partial support for a
very common use case
Uniqueness can be done with SHACL-SPARQL:UserShape {
schema:givenName xsd:string ;
schema:lastName xsd:string ;
UNIQUE(schema:givenName, schema:lastName)
}
:Country a sh:NodeShape ;
sh:property [
sh:path schema:name ;
sh:uniqueLang true
] .
:Country {
schema:name . + ;
UNIQUE(LANGTAG(schema:name))
}
Modularity
ShEx has EXTERNAL keyword
EXTERNAL declares that a shape
definition should be retrieved
elsewhere
No mechanism to import/export
shapes/schemas
SHACL supports owl:imports
SHACL processors follow owl:imports
declarations
<> owl:imports <http://example.org/UserShapes>
:TeacherShape a sh:NodeShape;
sh:node :UserShape ;
sh:property [ sh:path :teaches ;
sh:minCount 1;
] ;
:UserShape a sh:NodeShape ;
sh:property [ sh:path schema:name ;
sh:datatype xsd:string
] .
http://example.org/UserShapes
Reusability - Extending shapes (1)
ShEx shapes can be extended by composition SHACL shapes can be extended by
composition and by leveraging subclasses
:Product a sh:NodeShape, rdfs:Class ;
sh:property [ sh:path schema:productId ;
sh:datatype xsd:string
];
sh:property [ sh:path schema:price ;
sh:datatype xsd:decimal
].
:SoldProduct a sh:NodeShape, rdfs:Class ;
sh:and (
:Product
[ sh:path schema:purchaseDate ;
sh:datatype xsd:date]
[ sh:path schema:productId ;
sh:pattern "^[A-Z]" ]
) .
Extending by composition
:Product {
schema:productId xsd:string
schema:price xsd:decimal
}
:SoldProduct @:Product AND {
schema:purchaseDate xsd:date ;
schema:productId /^[A-Z]/
}
Reusability - Extending shapes (2)
In ShEx, there is no special treatment for
rdfs:Class, rdfs:subClassOf, ...
By design, ShEx has no concept of Class
It is not possible to extend by declaring subClass
relationships
No interaction with inference engines
SHACL shapes can also be extended by
leveraging subclasses
:Product a sh:NodeShape, rdfs:Class ;
...as before...
:SoldProduct a sh:NodeShape, rdfs:Class ;
rdfs:subClassOf :Product ;
sh:property [ sh:path schema:productId ;
sh:pattern "^[A-Z]"
] ;
sh:property [ sh:path schema:purchaseDate ;
sh:datatype xsd:date
] .
Extending by leveraging subclasses
SHACL subclasses may differ from RDFS/OWL subclases
Annotations
ShEx allows annotations but doesn't
have built-in annotations
Annotations can be declared by //
SHACL allows any kind of annotations
and also has built-in annotations
Built-in properties: sh:name, sh:description,
sh:defaultValue, sh:order, sh:group
:Person {
// rdfs:label "Name"
// rdfs:comment "Name of person"
schema:name xsd:string ;
}
:Person a sh:NodeShape ;
sh:property [
sh:path schema:name ;
sh:datatype xsd:string ;
sh:name "Name" ;
sh:description "Name of person"
rdfs:label "Name";
] .
Apart of the built-in annotations,
SHACL can also use any other annotation
Validation report
ShEx 2.0 doesn't define a validation report
Work in progress
SHACL defines a validation report
Describes structure of errors
Some properties can be used to control
which information is shown
sh:message
sh:severity
Extension mechanism
ShEx uses semantic actions
Semantic actions allow any future
processor
They can be used also to transform RDF
SHACL has SHACL-SPARQL
SHACL-SPARQL allows new constraint
components defined in SPARQL
[See example in next slide]
It is possible to define constraint
components in other languages, e.g.
Javascript
Stems
ShEx can describe stems Stems are not built-in
:Employee {
:homePage [ <http://company.com/> ~ ]
}
:StemConstraintComponent
a sh:ConstraintComponent ;
sh:parameter [ sh:path :stem ] ;
sh:validator [ a sh:SPARQLAskValidator ;
sh:message "Value does not have stem {$stem}";
sh:ask """
ASK {
FILTER (!isBlank($value) &&
strstarts(str($value),str($stem)))
}"""
] . :Employee a sh:NodeShape ;
sh:targetClass :Employee ;
sh:property [
sh:path :homePage ;
:stem <http://company.com/>
] .
Stems are built into the language
Example:
The value of :homePage starts by
<http://company.com/>
Can be defined using SHACL-SParql
Further info
Further reading:
• SHACL WG wiki: https://www.w3.org/2014/data-shapes/wiki/SHACL-ShEx-Comparison
• Phd Thesis: Thomas Hartmann, Validation framework of RDF-based constraint
languages. 2016, https://publikationen.bibliothek.kit.edu/1000056458
End
This presentation is part of the set:
https://www.slideshare.net/jelabra/rdf-validation-tutorial

More Related Content

What's hot

SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)Thomas Francart
 
Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Fabien Gandon
 
RDF, SPARQL and Semantic Repositories
RDF, SPARQL and Semantic RepositoriesRDF, SPARQL and Semantic Repositories
RDF, SPARQL and Semantic RepositoriesMarin Dimitrov
 
Semantic Web - Ontologies
Semantic Web - OntologiesSemantic Web - Ontologies
Semantic Web - OntologiesSerge Linckels
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshellFabien Gandon
 
FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout Carole Goble
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQLOpen Data Support
 
RDB2RDF, an overview of R2RML and Direct Mapping
RDB2RDF, an overview of R2RML and Direct MappingRDB2RDF, an overview of R2RML and Direct Mapping
RDB2RDF, an overview of R2RML and Direct MappingBoris Villazón-Terrazas
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraMarkus Lanthaler
 
Validating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesValidating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesJose Emilio Labra Gayo
 
OpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers OverviewOpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers OverviewKingsley Uyi Idehen
 
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODOLinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODOChris Mungall
 
Querying Linked Data with SPARQL
Querying Linked Data with SPARQLQuerying Linked Data with SPARQL
Querying Linked Data with SPARQLOlaf Hartig
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaAleksander Pohl
 

What's hot (20)

SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)
 
RDF data validation 2017 SHACL
RDF data validation 2017 SHACLRDF data validation 2017 SHACL
RDF data validation 2017 SHACL
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)
 
RDF, SPARQL and Semantic Repositories
RDF, SPARQL and Semantic RepositoriesRDF, SPARQL and Semantic Repositories
RDF, SPARQL and Semantic Repositories
 
Semantic Web - Ontologies
Semantic Web - OntologiesSemantic Web - Ontologies
Semantic Web - Ontologies
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshell
 
FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout FAIR Workflows and Research Objects get a Workout
FAIR Workflows and Research Objects get a Workout
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQL
 
RDF and OWL
RDF and OWLRDF and OWL
RDF and OWL
 
RDB2RDF, an overview of R2RML and Direct Mapping
RDB2RDF, an overview of R2RML and Direct MappingRDB2RDF, an overview of R2RML and Direct Mapping
RDB2RDF, an overview of R2RML and Direct Mapping
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and Hydra
 
Validating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesValidating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectives
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
OpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers OverviewOpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers Overview
 
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODOLinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
 
Open Policy Agent
Open Policy AgentOpen Policy Agent
Open Policy Agent
 
Querying Linked Data with SPARQL
Querying Linked Data with SPARQLQuerying Linked Data with SPARQL
Querying Linked Data with SPARQL
 
Mini tutorial rdflib
Mini tutorial rdflibMini tutorial rdflib
Mini tutorial rdflib
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for Java
 

Similar to ShEx vs SHACL

Part04_SHACL By Example presentation.pptx
Part04_SHACL By Example presentation.pptxPart04_SHACL By Example presentation.pptx
Part04_SHACL By Example presentation.pptxvudinhphuong96
 
SPARQL Query Containment with ShEx Constraints
SPARQL Query Containment with ShEx ConstraintsSPARQL Query Containment with ShEx Constraints
SPARQL Query Containment with ShEx ConstraintsAbdullah Abbas
 
Towards an RDF Validation Language based on Regular Expression Derivatives
Towards an RDF Validation Language based on Regular Expression DerivativesTowards an RDF Validation Language based on Regular Expression Derivatives
Towards an RDF Validation Language based on Regular Expression DerivativesJose Emilio Labra Gayo
 
Validating and Describing Linked Data Portals using RDF Shape Expressions
Validating and Describing Linked Data Portals using RDF Shape ExpressionsValidating and Describing Linked Data Portals using RDF Shape Expressions
Validating and Describing Linked Data Portals using RDF Shape ExpressionsJose Emilio Labra Gayo
 
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...Dr.-Ing. Thomas Hartmann
 
Rdf data-model-and-storage
Rdf data-model-and-storageRdf data-model-and-storage
Rdf data-model-and-storage灿辉 葛
 
2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)
2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)
2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)Dr.-Ing. Thomas Hartmann
 
Design patterns through refactoring
Design patterns through refactoringDesign patterns through refactoring
Design patterns through refactoringGanesh Samarthyam
 
Semantic web
Semantic webSemantic web
Semantic webtariq1352
 
EC-WEB: Validator and Preview for the JobPosting Data Model of Schema.org
EC-WEB: Validator and Preview for the JobPosting Data Model of Schema.orgEC-WEB: Validator and Preview for the JobPosting Data Model of Schema.org
EC-WEB: Validator and Preview for the JobPosting Data Model of Schema.orgJindřich Mynarz
 
Challenges and applications of RDF shapes
Challenges and applications of RDF shapesChallenges and applications of RDF shapes
Challenges and applications of RDF shapesJose Emilio Labra Gayo
 
Find your way in Graph labyrinths
Find your way in Graph labyrinthsFind your way in Graph labyrinths
Find your way in Graph labyrinthsDaniel Camarda
 
SHACL shortly (ELAG 2018)
SHACL shortly (ELAG 2018)SHACL shortly (ELAG 2018)
SHACL shortly (ELAG 2018)Péter Király
 
Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)
Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)
Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)Dr.-Ing. Thomas Hartmann
 

Similar to ShEx vs SHACL (20)

Part04_SHACL By Example presentation.pptx
Part04_SHACL By Example presentation.pptxPart04_SHACL By Example presentation.pptx
Part04_SHACL By Example presentation.pptx
 
Presentation shexer
Presentation shexerPresentation shexer
Presentation shexer
 
SHACL Specification Draft
SHACL Specification DraftSHACL Specification Draft
SHACL Specification Draft
 
Optimizing SPARQL Queries with SHACL.pdf
Optimizing SPARQL Queries with SHACL.pdfOptimizing SPARQL Queries with SHACL.pdf
Optimizing SPARQL Queries with SHACL.pdf
 
SPARQL Query Containment with ShEx Constraints
SPARQL Query Containment with ShEx ConstraintsSPARQL Query Containment with ShEx Constraints
SPARQL Query Containment with ShEx Constraints
 
KIT Graduiertenkolloquium 11.05.2016
KIT Graduiertenkolloquium 11.05.2016KIT Graduiertenkolloquium 11.05.2016
KIT Graduiertenkolloquium 11.05.2016
 
Towards an RDF Validation Language based on Regular Expression Derivatives
Towards an RDF Validation Language based on Regular Expression DerivativesTowards an RDF Validation Language based on Regular Expression Derivatives
Towards an RDF Validation Language based on Regular Expression Derivatives
 
Validating and Describing Linked Data Portals using RDF Shape Expressions
Validating and Describing Linked Data Portals using RDF Shape ExpressionsValidating and Describing Linked Data Portals using RDF Shape Expressions
Validating and Describing Linked Data Portals using RDF Shape Expressions
 
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...
 
Rdf data-model-and-storage
Rdf data-model-and-storageRdf data-model-and-storage
Rdf data-model-and-storage
 
2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)
2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)
2015.09. - The Role of Reasoning for RDF Validation (SEMANTiCS 2015)
 
Design patterns through refactoring
Design patterns through refactoringDesign patterns through refactoring
Design patterns through refactoring
 
Semantic web Technology
Semantic web TechnologySemantic web Technology
Semantic web Technology
 
Semantic web
Semantic webSemantic web
Semantic web
 
EC-WEB: Validator and Preview for the JobPosting Data Model of Schema.org
EC-WEB: Validator and Preview for the JobPosting Data Model of Schema.orgEC-WEB: Validator and Preview for the JobPosting Data Model of Schema.org
EC-WEB: Validator and Preview for the JobPosting Data Model of Schema.org
 
Challenges and applications of RDF shapes
Challenges and applications of RDF shapesChallenges and applications of RDF shapes
Challenges and applications of RDF shapes
 
Find your way in Graph labyrinths
Find your way in Graph labyrinthsFind your way in Graph labyrinths
Find your way in Graph labyrinths
 
SHACL shortly (ELAG 2018)
SHACL shortly (ELAG 2018)SHACL shortly (ELAG 2018)
SHACL shortly (ELAG 2018)
 
Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)
Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)
Doctoral Examination at the Karlsruhe Institute of Technology (08.07.2016)
 
JSON-LD Update
JSON-LD UpdateJSON-LD Update
JSON-LD Update
 

More from Jose Emilio Labra Gayo

Introducción a la investigación/doctorado
Introducción a la investigación/doctoradoIntroducción a la investigación/doctorado
Introducción a la investigación/doctoradoJose Emilio Labra Gayo
 
Legislative data portals and linked data quality
Legislative data portals and linked data qualityLegislative data portals and linked data quality
Legislative data portals and linked data qualityJose Emilio Labra Gayo
 
Legislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologiesLegislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologiesJose Emilio Labra Gayo
 
Como publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazadosComo publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazadosJose Emilio Labra Gayo
 
Arquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el ServidorArquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el ServidorJose Emilio Labra Gayo
 
RDF Validation Future work and applications
RDF Validation Future work and applicationsRDF Validation Future work and applications
RDF Validation Future work and applicationsJose Emilio Labra Gayo
 

More from Jose Emilio Labra Gayo (20)

Publicaciones de investigación
Publicaciones de investigaciónPublicaciones de investigación
Publicaciones de investigación
 
Introducción a la investigación/doctorado
Introducción a la investigación/doctoradoIntroducción a la investigación/doctorado
Introducción a la investigación/doctorado
 
Legislative data portals and linked data quality
Legislative data portals and linked data qualityLegislative data portals and linked data quality
Legislative data portals and linked data quality
 
Wikidata
WikidataWikidata
Wikidata
 
Legislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologiesLegislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologies
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Introducción a la Web Semántica
Introducción a la Web SemánticaIntroducción a la Web Semántica
Introducción a la Web Semántica
 
RDF Data Model
RDF Data ModelRDF Data Model
RDF Data Model
 
2017 Tendencias en informática
2017 Tendencias en informática2017 Tendencias en informática
2017 Tendencias en informática
 
RDF, linked data and semantic web
RDF, linked data and semantic webRDF, linked data and semantic web
RDF, linked data and semantic web
 
19 javascript servidor
19 javascript servidor19 javascript servidor
19 javascript servidor
 
Como publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazadosComo publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazados
 
16 Alternativas XML
16 Alternativas XML16 Alternativas XML
16 Alternativas XML
 
XSLT
XSLTXSLT
XSLT
 
XPath
XPathXPath
XPath
 
Arquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el ServidorArquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el Servidor
 
RDF Validation Future work and applications
RDF Validation Future work and applicationsRDF Validation Future work and applications
RDF Validation Future work and applications
 
RDF data model
RDF data modelRDF data model
RDF data model
 
Máster en Ingeniería Web
Máster en Ingeniería WebMáster en Ingeniería Web
Máster en Ingeniería Web
 
2016 temuco tecnologias_websemantica
2016 temuco tecnologias_websemantica2016 temuco tecnologias_websemantica
2016 temuco tecnologias_websemantica
 

Recently uploaded

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 

ShEx vs SHACL

  • 1. ShEx & SHACL compared RDF Validation tutorial Eric Prud'hommeaux World Wide Web Consortium MIT, Cambridge, MA, USA Harold Solbrig Mayo Clinic, USA Jose Emilio Labra Gayo WESO Research group University of Oviedo, Spain Iovka Boneva LINKS, INRIA & CNRS University of Lille, France
  • 2. Common features Similar goal: describe and validate RDF graphs Both employ the word "shape" Node constraints similar in both languages Constraints on incoming/outgoing arcs Cardinalities RDF syntax Extension mechanism
  • 3. Some differences Underlying philosophy Syntactic differences Notion of a shape Syntactic differences Default cardinalities Shapes and Classes Recursion Repeated properties Property pair constraints Uniqueness Extension mechanism
  • 4. Underlying philosophy ShEx is schema based Shapes schemas look like RDF grammars More focus on validation results After validation, an enriched graph is usually obtained It contains valid nodes with their shapes SHACL is constraint based Shapes ≈ collections of constraints Focus mainly on validation errors Usually, no info about valid nodes Difficult to distinguish valid nodes from nodes that haven't been validated
  • 5. Semantic specification ShEx semantics is based on mathematical concepts It has been proven to be well-founded Support for recursión and negation Inspired by type systems and RelaxNG SHACL semantics = SPARQL + textual description SHACL terms described in natural language SPARQL fragments used as helpers Recursion is implementation dependent SHACL-SPARQL is based on pre-binding
  • 6. Syntactic differences ShEx design focused on human-readability Followed programming language design methodology 1. Abstract syntax 2. Different concrete syntaxes Compact RDF ... SHACL design focused on RDF vocabulary Design centered on RDF terms Lots of rules to define valid shapes graphs https://w3c.github.io/data-shapes/shacl/#syntax-rules Compact syntax added as a WG Note for a subset of SHACL core SHACL compact syntax copied from ShEx Syntactically similar Semantically different
  • 7. Compact Syntax ShEx compact syntax has been designed along the language Difficult to create bad shapes Test-suite contains lots of tests It is fully round-trippable with ShExJ and ShExR SHACL compact syntax was designed after the language It covers a subset of SHACL core Incorrect shapes can be defined that pass the grammar One extra-step: After parsing and converting to RDF, check production rules from RDF shapes graph :User { minLength = :unknown . maxLength = [ true 1 ] . } It parses the gramar but is rejected by production rules
  • 8. Compact syntax: similar but different meanings ShEx contains Boolean operators and grammar based operators Boolean: AND, OR, NOT Grammar: grouping (;), alternative (|) SHACL contains Boolean operators (and, or, not, xone) Only top-level expressions . means conjunction :Product { :code IRI ; :code xsd:integer } It means a product with 2 codes (one IRI, and one integer) It means the code of a product must be an IRI and an integer :p1 :code <http://code.org/P123> ; :code 123 .  = conforms to Shape = doesn't conform :Product { :code IRI . :code xsd:integer }
  • 9. RDF vocabulary ShEx vocabulary ≈ abstract syntax ShEx RDF vocabulary obtained from the abstract syntax ShEx RDF serializations typically more verbose They can be round-tripped to Compact syntax SHACL is designed as an RDF vocabulary Some rdf:type declarations can be omitted SHACL RDF serialization typically more readable :User a sx:Shape; sx:expression [ a sx:EachOf ; sx:expressions ( [ a sx:TripleConstraint ; sx:predicate schema:name ; sx:valueExpr [ a sx:NodeConstraint ; sx:datatype xsd:string ] ] [ a sx:TripleConstraint ; sx:predicate schema:birthDate ; sx:valueExpr [ a sx:NodeConstraint ; sx:datatype xsd:date ] ; sx:min 0 ] ) ]. :User a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ]; sh:property [ sh:path schema:birthDate ; sh:maxCount 1; sh:datatype xsd:date ] .
  • 10. Notion of Shape In ShEx, shapes define only structure of nodes Selection of focus nodes - shapes is made by a different mechanism: shapes map In SHACL, shapes define structure and can have target declarations Shapes can be associated with nodes or sets of nodes through target declarations :User a sh:NodeShape, rdfs:Class ; sh:targetClass :Person ; sh:targetNode :alice ; sh:nodeKind sh:IRI ; sh:property [ sh:path schema:name ; sh:datatype xsd:string ] . :User IRI { schema:name xsd:string } target declarations structure
  • 11. Triggering validation ShEx uses Shape maps Shape maps are external to schemas Separation of concerns between validation language and triggering mechanism Differing possibilities to build the shapes map can be explored SHACL uses target declarations Associate shapes with node sets Possibilities: Direct node: targetNode Instance of some class: targetClass Subjects of some predicate: targetSubjectsOf Objects of some predicate: targetSubjectsOf Target declarations can be part of the shapes graph
  • 12. Default cardinalities ShEx: default = (1,1) :User { schema:givenName xsd:string schema:lastName xsd:string } :User a sh:NodeShape ; sh:property [ sh:path schema:givenName ; sh:datatype xsd:string ; ]; sh:property [ sh:path schema:lastName ; sh:datatype xsd:string ; ] . :alice schema:givenName "Alice" ; schema:lastName "Cooper" . :bob schema:givenName "Bob", "Robert" ; schema:lastName "Smith", "Dylan" . :carol schema:lastName "King" . :dave schema:givenName 23; schema:lastName :Unknown . SHACL: default = (0,unbounded)         = conforms to Shape = doesn't conform
  • 13. Property paths ShEx shapes describe neighborhood of focus nodes: direct/inverse properties Examples with paths can be simulated by nested shapes Sometimes requiring auxiliary recursive shapes SHACL shapes can also describe whole property paths following SPARQL paths :GrandSon a sh:NodeShape ; sh:property [ sh:path (schema:parent schema:parent) ; sh:minCount 1 ]; sh:property [ sh:path [ sh:alternativePath (:father :mother) ] ]; sh:minCount 1 ] ; sh:property [ sh:path [sh:inversePath :knows ] ] sh:node :Person ; sh:minCount 1 ] . :GrandSon { :parent { :parent . + } + ; (:father . | :mother .) + ; ^:knows :Person }
  • 14. Inference ShEx doesn't interact with inference Validation can be invoked before or after inference rdf:type is considered an arc as any other No special meaning The same for rdfs:Class, rdfs:subClassOf, rdfs:domain, rdfs:range, ... Some constructs have special meaning The following constructs have special meaning in SHACL rdf:type rdfs:Class rdfs:subClassOf owl:imports Other constructs like rdfs:domain, rdfs:range,... have no special meaning sh:entailment can be used to indicate that some inference is required
  • 15. Inference and triggering mechanism ShEx has no interaction with inference It can be used to validate a reasoner In SHACL, RDF Schema inference can affect which nodes are validated :User a sh:NodeShape, rdfs:Class ; sh:property [ sh:path schema:name ; sh:datatype xsd:string; ].  RDFS inference No RDFS inference :Teacher rdfs:subClassOf :User . :teaches rdfs:domain :Teacher . :alice a :Teacher ; schema:name 23 . :bob :teaches :Algebra ; schema:name 34 . :carol :teaches :Logic; schema:name "King" . Ignored Ignored    With or without RDFS inference :User { schema:name xsd:string }     = conforms to Shape = doesn't conform Some implicit RDFS inference but not all
  • 16. Repeated properties ShEx (;) operator handles repeated properties SHACL needs qualifiedValueShapes for repeated properties Direct approximation (wrong)::Person { :parent {:gender [:Male ] } ; :parent {:gender [:Female ] } } :Person a sh:NodeShape; sh:property [ sh:path :parent; sh:node [ sh:property [ sh:path :gender ; sh:hasValue :Male ; ]] ; ]; sh:property [ sh:path :parent; sh:node [ sh:property [ sh:path :gender ; sh:hasValue :Female ]]; ] . Exercise: Example. A person must have 2 parents, one male and another female
  • 17. Repeated properties ShEx (;) operator handles repeated properties SHACL needs qualifiedValueShapes for repeated properties Solution with qualifiedValueShapes::Person { :parent {:gender [:Male ] } ; :parent {:gender [:Female ] } } :Person a sh:NodeShape, rdfs:Class ; sh:property [ sh:path :parent; sh:qualifiedValueShape [ sh:property [ sh:path :gender ; sh:hasValue :Male ] ] ; sh:qualifiedMinCount 1; sh:qualifiedMaxCount 1 ]; sh:property [ sh:path :parent; sh:qualifiedValueShape [ sh:property [ sh:path :gender ; sh:hasValue :Female ] ] ; sh:qualifiedMinCount 1; sh:qualifiedMaxCount 1 ] ; sh:property [ sh:path :parent; sh:minCount 2; sh:maxCount 2 ] . Exercise: Example. A person must have 2 parents, one male and another female It needs to count all possibilities
  • 18. Recursion ShEx handles recursion Well founded semantics Recursive shapes are undefined in SHACL Implementation dependent Direct translation generates recursive shapes :Person { schema:name xsd:string ; schema:knows @:Person* } :Person a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:datatype xsd:string ]; sh:property [ sh:path schema:knows ; sh:node :Person ] .
  • 19. Recursion (with target declarations) ShEx handles recursion Well founded semantics Recursive shapes are undefined in SHACL Implementation dependent Can be simulated with target declarations Example with target declatations It needs discriminating arcs :Person { schema:name xsd:string ; schema:knows @:Person* } :Person a sh:NodeShape, rdfs:Class ; sh:property [ sh:path schema:name ; sh:datatype xsd:string ]; sh:property [ sh:path schema:knows ; sh:class :Person ] . It requires all nodes to have rdf:type Person
  • 20. Recursion (with property paths) ShEx handles recursion Well founded semantics Recursive shapes are undefined in SHACL Implementation dependent Can be simulated property paths :Person { schema:name xsd:string ; schema:knows @:Person* } :Person a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:datatype xsd:string ]; sh:property [ sh:path [sh:zeroOrMorePath schema:knows]; sh:node :PersonAux ]. :PersonAux a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:datatype xsd:string ].
  • 21. :Person a sh:NodeShape ; sh:targetNode :alice ; sh:closed true ; sh:or ( [ sh:path schema:name ; sh:datatype xsd:string ] [ sh:path foaf:name ; sh:datatype xsd:string ] ) . Closed shapes In ShEx, closed affects all properties In SHACL, closed only affects properties declared at top-level Properties declared inside other shapes are ignored :Person CLOSED { schema:name xsd:string | foaf:name xsd:string } :alice schema:name "Alice" .   = conforms to Shape = doesn't conform
  • 22. Closed shapes and paths Closed in ShEx acts on all properties In SHACL, closed ignores properties mentioned inside paths :Person a sh:NodeShape ; sh:closed true ; sh:property [ sh:path [ sh:alternativePath ( schema:name foaf:name ) ] ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ] ; . :Person CLOSED { schema:name xsd:string | foaf:name xsd:string } :alice schema:name "Alice".   = conforms to Shape = doesn't conform
  • 23. Property pair constraints This feature was posponed in ShEx 2.0 ShEx 2.1 is expected to add support for value comparisons SHACL supports equals, disjoint, lessThan, ... :UserShape a sh:NodeShape ; sh:property [ sh:path schema:givenName ; sh:datatype xsd:string ; sh:disjoint schema:lastName ] ; sh:property [ sh:path foaf:firstName ; sh:equals schema:givenName ; ] ; sh:property [ sh:path schema:birthDate ; sh:datatype xsd:date ; sh:lessThan :loginDate ] . :UserShape { $<givenName> schema:givenName xsd:string ; $<firstName> schema:firstName xsd:string ; $<birthDate> schema:birthDate xsd:date ; $<loginDate> :loginDate xsd:date ; $<givenName> = $<firstName> ; $<givenName> != $<lastName> ; $<birthDate> < $<loginDate> }
  • 24. Uniqueness (defining unique Keys) This feature was postponed in ShEx 2.0 No support for generic unique keys sh:uniqueLang offers partial support for a very common use case Uniqueness can be done with SHACL-SPARQL:UserShape { schema:givenName xsd:string ; schema:lastName xsd:string ; UNIQUE(schema:givenName, schema:lastName) } :Country a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:uniqueLang true ] . :Country { schema:name . + ; UNIQUE(LANGTAG(schema:name)) }
  • 25. Modularity ShEx has EXTERNAL keyword EXTERNAL declares that a shape definition should be retrieved elsewhere No mechanism to import/export shapes/schemas SHACL supports owl:imports SHACL processors follow owl:imports declarations <> owl:imports <http://example.org/UserShapes> :TeacherShape a sh:NodeShape; sh:node :UserShape ; sh:property [ sh:path :teaches ; sh:minCount 1; ] ; :UserShape a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:datatype xsd:string ] . http://example.org/UserShapes
  • 26. Reusability - Extending shapes (1) ShEx shapes can be extended by composition SHACL shapes can be extended by composition and by leveraging subclasses :Product a sh:NodeShape, rdfs:Class ; sh:property [ sh:path schema:productId ; sh:datatype xsd:string ]; sh:property [ sh:path schema:price ; sh:datatype xsd:decimal ]. :SoldProduct a sh:NodeShape, rdfs:Class ; sh:and ( :Product [ sh:path schema:purchaseDate ; sh:datatype xsd:date] [ sh:path schema:productId ; sh:pattern "^[A-Z]" ] ) . Extending by composition :Product { schema:productId xsd:string schema:price xsd:decimal } :SoldProduct @:Product AND { schema:purchaseDate xsd:date ; schema:productId /^[A-Z]/ }
  • 27. Reusability - Extending shapes (2) In ShEx, there is no special treatment for rdfs:Class, rdfs:subClassOf, ... By design, ShEx has no concept of Class It is not possible to extend by declaring subClass relationships No interaction with inference engines SHACL shapes can also be extended by leveraging subclasses :Product a sh:NodeShape, rdfs:Class ; ...as before... :SoldProduct a sh:NodeShape, rdfs:Class ; rdfs:subClassOf :Product ; sh:property [ sh:path schema:productId ; sh:pattern "^[A-Z]" ] ; sh:property [ sh:path schema:purchaseDate ; sh:datatype xsd:date ] . Extending by leveraging subclasses SHACL subclasses may differ from RDFS/OWL subclases
  • 28. Annotations ShEx allows annotations but doesn't have built-in annotations Annotations can be declared by // SHACL allows any kind of annotations and also has built-in annotations Built-in properties: sh:name, sh:description, sh:defaultValue, sh:order, sh:group :Person { // rdfs:label "Name" // rdfs:comment "Name of person" schema:name xsd:string ; } :Person a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:datatype xsd:string ; sh:name "Name" ; sh:description "Name of person" rdfs:label "Name"; ] . Apart of the built-in annotations, SHACL can also use any other annotation
  • 29. Validation report ShEx 2.0 doesn't define a validation report Work in progress SHACL defines a validation report Describes structure of errors Some properties can be used to control which information is shown sh:message sh:severity
  • 30. Extension mechanism ShEx uses semantic actions Semantic actions allow any future processor They can be used also to transform RDF SHACL has SHACL-SPARQL SHACL-SPARQL allows new constraint components defined in SPARQL [See example in next slide] It is possible to define constraint components in other languages, e.g. Javascript
  • 31. Stems ShEx can describe stems Stems are not built-in :Employee { :homePage [ <http://company.com/> ~ ] } :StemConstraintComponent a sh:ConstraintComponent ; sh:parameter [ sh:path :stem ] ; sh:validator [ a sh:SPARQLAskValidator ; sh:message "Value does not have stem {$stem}"; sh:ask """ ASK { FILTER (!isBlank($value) && strstarts(str($value),str($stem))) }""" ] . :Employee a sh:NodeShape ; sh:targetClass :Employee ; sh:property [ sh:path :homePage ; :stem <http://company.com/> ] . Stems are built into the language Example: The value of :homePage starts by <http://company.com/> Can be defined using SHACL-SParql
  • 32. Further info Further reading: • SHACL WG wiki: https://www.w3.org/2014/data-shapes/wiki/SHACL-ShEx-Comparison • Phd Thesis: Thomas Hartmann, Validation framework of RDF-based constraint languages. 2016, https://publikationen.bibliothek.kit.edu/1000056458
  • 33. End This presentation is part of the set: https://www.slideshare.net/jelabra/rdf-validation-tutorial