Successfully reported this slideshow.
Your SlideShare is downloading. ×

SHACL shortly (ELAG 2018)

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
SHACL by example
SHACL by example
Loading in …3
×

Check these out next

1 of 14 Ad

More Related Content

Similar to SHACL shortly (ELAG 2018) (20)

More from Péter Király (20)

Advertisement

SHACL shortly (ELAG 2018)

  1. 1. SHACL shortly
  2. 2. prepare > wget https://www.dropbox.com/s/cddlq531xwqfohf/user-with-errors.data.ttl > wget https://www.dropbox.com/s/d6d7iy5rzq4qqpj/user.data.ttl > wget https://www.dropbox.com/s/j7b6w0olf75xk7d/user.shape.ttl
  3. 3. start with a success message > shaclvalidate.sh -datafile user.data.ttl -shapesfile user.shape.ttl [ a sh:ValidationReport ; sh:conforms true ] .
  4. 4. an error message > shaclvalidate.sh -datafile user-with-errors.data.ttl -shapesfile user.shape.ttl [ a sh:ValidationReport ; sh:conforms false ; sh:result [ a sh:ValidationResult ; sh:focusNode :frank ; #1 sh:resultMessage "Less than 1^^http://www.w3.org/2001/ #2 XMLSchema#integer values" ; sh:resultPath schema:name ; #3 sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; sh:sourceShape _:b0 ] ; ] . #1 the problematic statement #2 explanation #3 the problematic property
  5. 5. Check the data - missing schema:name data: :frank a :User ; foaf:name "Frank" ; schema:gender schema:Male . shape: :UserShape a sh:NodeShape; sh:targetClass :User ; sh:property [ sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ; ] ; # …
  6. 6. rules: minCount, maxCount, datatype sh:property [ sh:path schema:name ; #1 sh:minCount 1; #2 sh:maxCount 1; #3 sh:datatype xsd:string ; #4 ] ; #1 The qualified name of the property #2 minimum number of instance #3 maximum number of instance #4 data type (use XML schema’s definition)
  7. 7. rules: or, in sh:property [ sh:path schema:gender ; sh:minCount 1; sh:maxCount 1; sh:or ( # 1 [ sh:in ( # 2 schema:Male schema:Female ) ] [ sh:datatype xsd:string] ) ] ; #1 the value should be either X or Y #2 the value should be one of a set of values Meaning: schema:gender property should be schema:Male, schema:Female or a string
  8. 8. rules: IRI, class sh:property [ sh:path schema:knows ; sh:nodeKind sh:IRI ; #1 sh:class :User ; #2 ] #1 the value must be an IRI #2 the value must be an instance of User Meaning: schema:knows property must be a reference to another user BlankNode, IRI, Literal, BlankNodeOrIRI, BlankNodeOrLiteral, IRIOrLiteral
  9. 9. Defining rules w/ blank nodes or w/ named nodes Blank nodes: :UserShape a sh:NodeShape; sh:targetClass :User ; sh:property [ sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ; ] ; # … Named nodes: :UserShape a sh:NodeShape; sh:targetClass :User ; sh:property :HasName; # … :HasName sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string .
  10. 10. Implicit target class Blank nodes: :UserShape a sh:NodeShape; sh:targetClass :User ; sh:property [ sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ; ] ; # … Named nodes: :User a sh:NodeShape, drfs:Class; sh:property [ sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ] ;
  11. 11. Core constraints Cardinality minCount, maxCount Types of values class, datatype, nodeKind Values node, in, hasValue Range of values minInclusive, maxInclusive, minExclusive, maxExclusive String based minLength, maxLength, pattern, stem, uniqueLang Logical constraints not, and, or, xone Closed shapes closed, ignoredProperties Property pair constraints equals, disjoint, lessThan, lessThanOrEquals Non-validating constraints name, value, defaultValue Qualified shapes qualifiedValueShape, qualifiedMinCount, qualifiedMaxCount
  12. 12. uniqueLang - one literal per language Shape: :Country a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:uniqueLang true ] . # … Data: :spain schema:name "Spain"@en, "España"@es . :france schema:name "France"@en, "Francia"@es . :usa schema:name "USA"@en, "United States"@en.
  13. 13. Closed shapes Shape: :User a sh:NodeShape ; sh:closed true ; sh:ignoredProperties ( rdf:type ); sh:property [ sh:path schema:givenName; ]; sh:property [ sh:path schema:lastName ; ] . Data: :alice schema:givenName "Alice"; schema:lastName "Cooper" . :carol schema:givenName "Carol"; schema:lastName "King" ; rdfs:label "Carol" .
  14. 14. References ★ Shapes Constraint Language (SHACL) W3C Recommendation 20 July 2017 https://www.w3.org/TR/shacl/ ★ Gayo—Prud’hommeaux—Solbrig—Boneva: SHACL by example https://www.slideshare.net/jelabra/shacl-by-example ★ Gayo—Prud’hommeaux—Boneva—Kontokostas: Validating RDF Data. (Morgan & Claypool, 2018) 328 p. /Synthesis Lectures on the Semantic Web: Theory and Technology, Vol. 7, No. 1/) http://book.validatingrdf.com/

×