SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

An Ambitious Wikidata Tutorial
An Ambitious Wikidata TutorialAn Ambitious Wikidata Tutorial
An Ambitious Wikidata Tutorial_Emw
 
RDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data MiningRDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data MiningPetar Ristoski
 
JSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked DataJSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked DataGregg Kellogg
 
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
 
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
 
FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...
FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...
FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...FIWARE
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개Dongbum Kim
 
LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」
LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」
LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」National Institute of Informatics (NII)
 
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 -  NGSI-LD Advanced Operations | Train the Trainers ProgramSession 5 -  NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 - NGSI-LD Advanced Operations | Train the Trainers ProgramFIWARE
 
Rdf In A Nutshell V1
Rdf In A Nutshell V1Rdf In A Nutshell V1
Rdf In A Nutshell V1Fabien Gandon
 
Linked Open Data勉強会2020 前編:LODの基礎・作成・公開
Linked Open Data勉強会2020 前編:LODの基礎・作成・公開Linked Open Data勉強会2020 前編:LODの基礎・作成・公開
Linked Open Data勉強会2020 前編:LODの基礎・作成・公開KnowledgeGraph
 
SPARQL - Basic and Federated Queries
SPARQL - Basic and Federated QueriesSPARQL - Basic and Federated Queries
SPARQL - Basic and Federated QueriesKnud Möller
 
JSON-LD for RESTful services
JSON-LD for RESTful servicesJSON-LD for RESTful services
JSON-LD for RESTful servicesMarkus Lanthaler
 

Tendances (20)

An Ambitious Wikidata Tutorial
An Ambitious Wikidata TutorialAn Ambitious Wikidata Tutorial
An Ambitious Wikidata Tutorial
 
RDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data MiningRDF2Vec: RDF Graph Embeddings for Data Mining
RDF2Vec: RDF Graph Embeddings for Data Mining
 
RDF validation tutorial
RDF validation tutorialRDF validation tutorial
RDF validation tutorial
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
JSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked DataJSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked Data
 
RDF data validation 2017 SHACL
RDF data validation 2017 SHACLRDF data validation 2017 SHACL
RDF data validation 2017 SHACL
 
SPIN in Five Slides
SPIN in Five SlidesSPIN in Five Slides
SPIN in Five Slides
 
Validating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectivesValidating RDF data: Challenges and perspectives
Validating RDF data: Challenges and perspectives
 
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)
 
FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...
FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...
FIWARE Global Summit - The Scorpio NGSI-LD Broker: Features and Supported Arc...
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개
 
RDF Data Model
RDF Data ModelRDF Data Model
RDF Data Model
 
LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」
LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」
LODI/Linked Open Data連続講義 第1回 「オープンデータからLinked Open Dataへ」
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 -  NGSI-LD Advanced Operations | Train the Trainers ProgramSession 5 -  NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
 
Rdf In A Nutshell V1
Rdf In A Nutshell V1Rdf In A Nutshell V1
Rdf In A Nutshell V1
 
Linked Open Data勉強会2020 前編:LODの基礎・作成・公開
Linked Open Data勉強会2020 前編:LODの基礎・作成・公開Linked Open Data勉強会2020 前編:LODの基礎・作成・公開
Linked Open Data勉強会2020 前編:LODの基礎・作成・公開
 
SPARQL - Basic and Federated Queries
SPARQL - Basic and Federated QueriesSPARQL - Basic and Federated Queries
SPARQL - Basic and Federated Queries
 
JSON-LD and SHACL for Knowledge Graphs
JSON-LD and SHACL for Knowledge GraphsJSON-LD and SHACL for Knowledge Graphs
JSON-LD and SHACL for Knowledge Graphs
 
JSON-LD for RESTful services
JSON-LD for RESTful servicesJSON-LD for RESTful services
JSON-LD for RESTful services
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 
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
 
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
 
2015 bogota datos_enlazados
2015 bogota datos_enlazados2015 bogota datos_enlazados
2015 bogota datos_enlazados
 
17 computacion servidor
17 computacion servidor17 computacion servidor
17 computacion servidor
 

Dernier

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptxNikhil Raut
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - GuideGOPINATHS437943
 

Dernier (20)

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Steel Structures - Building technology.pptx
Steel Structures - Building technology.pptxSteel Structures - Building technology.pptx
Steel Structures - Building technology.pptx
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Transport layer issues and challenges - Guide
Transport layer issues and challenges - GuideTransport layer issues and challenges - Guide
Transport layer issues and challenges - Guide
 

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