Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SHACL Overview

424 views

Published on

Overview of SHACL - new W3C standard for data validation and more

Published in: Technology

SHACL Overview

  1. 1. © Copyright 2017 TopQuadrant Inc. Slide 1 SHACL  Overview Acknowledgement:  This  presentation  re-­‐uses  some  of  the  examples  and  slides  originally  created  by   Dimitris  Kontokostas’s for  the  SHACL  Tutorial  at  SEMANTiCS 2016  -­‐ while  SHACL  was  still  evolving. Where  we  have  re-­‐used  such  examples,  we  have  updated  them  to  correctly  reflect    SHACL’s  final  syntax
  2. 2. © Copyright 2017 TopQuadrant Inc. Slide 2 SHACL § SHApes Constraint  Language  /  (upcoming)   W3C  recommendation  Language  for  defining   constraints  (+++)   § Validating  RDF  graphs  against  a  set  of  shapes   § Shapes  are  defined  in  an  RDF  graph  called   “Shapes  Graph”   § The  graph  to  be  validated  is  called  “Data   Graph”
  3. 3. © Copyright 2017 TopQuadrant Inc. Slide 3 SHACL  Scope § Validation  (primary)   § Extended  (but  not  limited  to) – interface  building   – data  structure  communication   – code  generation   – data  integration   – ...
  4. 4. © Copyright 2017 TopQuadrant Inc. Slide 4 Motivation  for  SHACL § Until  SHACL,  no  official  W3C  recommendation  for  Validating  RDF   – Since  2001?   § But  RDF  Schema  /  OWL  are  schema  languages...   – Or  NOT?   – #OWA,  #CWA,  #UNA  =>  inferencing  not  validation § Semi-­‐official  specifications  have  been  created  (W3C  member   submissions)   – SPIN   – Resource  Shapes   – ShEx § Other  Standalone  /  ad-­‐hoc  solutions  have  also  evolved – Most  on  top  of  SPARQL  &  RDFS/OWL  e.g.  Stardog DB OWA:  Open  World  Assumption;   CWA:  Closed  World  Assumption;   UNA:  Unique  Name  Assumption
  5. 5. © Copyright 2017 TopQuadrant Inc. Slide 5 Key  Inputs  to  SHACL § SHACL  Core  Vocabulary  and  Syntax:  inspired   mostly  by  IBM  Resource  Shapes   – (with  many  additions  along  the  way  to  address   requirements) § Extension  Mechanism:  inspired  mostly  by  SPIN   – (some  input  from  RDFUnit)   § Compact  syntax:  inspired  by  ShEx
  6. 6. © Copyright 2017 TopQuadrant Inc. Slide 6 SHACL  Terminology § Targets  (of  a  shape) – determine  what  resources  (or,  more  generally,  RDF  graph  nodes)  are  to  be  validated  against  a  shape – during  the  validation,  targets  are  referred  to  as  ”focus  nodes” § Node  Shapes – specify  conditions  a  target  node  itself  must  comply  with – used  to  group  property  shapes § Property  Shapes – specify  conditions  that  related  nodes  (property  values)  must  comply  with – for  example: • target  nodes  are  all  resources  with  type  ex:Person • property  shape  says  that  the  values  of  the  ex:birthDate property  for  these  resources  must  be  dates  that  are  less  than  1/1/2018   and  there  can  be  only  one  birth  date  per  person   § Constraint  Components – predefined  CCs  in  SHACL  Core  form  “SHACL  Core  vocabulary”  e.g.,  sh:minCount,  sh:datatype,  sh:pattern,   etc. – users  can  create  new  CCs  – domain  specific  data  validation  languages § Shapes  Graph,  Data  Graph – These  are  “roles”  – any  graph  can  be  declared  to  be  a  shapes  graph  or  a  data  graph § Validation  Report – RDF  graph  with  validation  results – SHACL  includes  a  vocabulary  for  describing  results
  7. 7. © Copyright 2017 TopQuadrant Inc. Slide 7 Targets  -­‐ 1 § Specified  in  a  shape – for  example,  in  this  case,  only  ex:Alice will  be   evaluated  against  ex:PersonShape § Alternatively,  targets  can  also  be  passed  as  a   parameter  to  a  SHACL  engine – As  a  directive  to  validate  a  given  node  against  a   given  shape ex:PersonShape a  sh:NodeShape ;   sh:targetNode ex:Alice .
  8. 8. © Copyright 2017 TopQuadrant Inc. Slide 8 Targets  -­‐ 2 § Pre-­‐built  vocabulary  for  targets: – sh:targetNode – targets  are  the  specified  resources – sh:targetClass – targets  are  all  resources  that  are  members  of   a  specified  class  (or  one  of  its  sub  classes) – sh:targetSubjectsOf – targets  are  all  subjects  of  triples  with  a   given  predicate – sh:targetObjectsOf – targets  are  all  objects  of  triples  with  a   given  predicate § Implicit  class  targets – If  a  node  shape  is  also  a  class,  it  doesn’t  need  an  explicit   sh:targetClass statement.   § SPARQL-­‐based  targets – Advanced  feature,  WG  Note  only
  9. 9. © Copyright 2017 TopQuadrant Inc. Slide 9 Node  Shapes § Node  shapes  are  used  to: – Specify  constraints  on  the  target  nodes – Group  property  shapes § Best  practice  is  to  declare  the  type  sh:NodeShape.   – However,  SHACL  processors  will  recognize  node  shapes  even  without  a  type  statements.  For   example,  subjects  of  triples  with  sh:property predicate  are  understood  to  be  node  shapes ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ; sh:pattern “^http://mydomain.com/person/”  ; sh:property [  #  _:b1   sh:path ex:firstName ;   sh:minCount 1  ;   sh:datatype xsd:string ;  ]  ; sh:property [  #  _:b2   sh:path ex:lastName ;   sh:minCount 1  ;   sh:maxCount 1  ;   sh:datatype xsd:string ;   sh:maxLength 20  ;]  . Node  Shape Property  Shape Property  Shape
  10. 10. © Copyright 2017 TopQuadrant Inc. Slide 10 Example  Data  Graph @prefix  example:  <http://example.org/>  . @prefix  ex:  < http://mydomain.com/person/>. ex:Alice a  ex:Person .   ex:Bob a  ex:Student . ex:Jack a  ex:Person . ex:Jill a  ex:Teacher . ex:Student rdfs:subClassOf ex:Person . ex:Alice ex:firstName “Alice”; ex:lastName “Jones”; ex:knows example:Bob . example:Bob ex:firstName “Bob”; ex:lastName “Brown”. ex:Jack ex:firstName “Jack”; ex:lastName “Smith”  ; ex:lastName “Jones”. ex:Jill ex:firstName 1  . Will  be  validated   against   ex:PersonShape Will  NOT  be   validated  against   ex:PersonShape valid not  valid,   wrong  URI not  valid,  two   last  names not  validated
  11. 11. © Copyright 2017 TopQuadrant Inc. Slide 11 Closed  Shapes § By  default,  if  we  do  not  say  anything  about  a  property,  then  it  can   have  any  value § But,  if  there  is  sh:closed true,  then  properties  that  are  not  explicitly   mentioned  (except  the  “ignored  properties”)  are  not  allowed ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ; sh:pattern “^http://mydomain.com/person/”  ; sh:closed true;      sh:ignoredProperties (  rdf:type )  ; sh:property [  #  _:b1   sh:path ex:firstName ;   sh:minCount 1  ;   sh:datatype xsd:string ;  ]  ; sh:property [  #  _:b2   sh:path ex:lastName ;   sh:minCount 1  ;   sh:maxCount 1  ;   sh:datatype xsd:string ;   sh:maxLength 20  ;]  .
  12. 12. © Copyright 2017 TopQuadrant Inc. Slide 12 Example  Data  Graph @prefix  example:  <http://example.org/>  . @prefix  ex:  < http://mydomain.com/person/>. ex:Alice a  ex:Person .   ex:Bob a  ex:Student . ex:Jack a  ex:Person . ex:Jill a  ex:Teacher . ex:Student rdfs:subClassOf ex:Person . ex:Alice ex:firstName “Alice”; ex:lastName “Jones”; ex:knows example:Bob . example:Bob ex:firstName “Bob”; ex:lastName “Brown”. ex:Jack ex:firstName “Jack”; ex:lastName “Smith”  ; ex:lastName “Jones”. ex:Jill ex:firstName 1  . not  valid,  ex:knows not  allowed not  valid,  wrong   URI not  valid,  two  last   names not  validated
  13. 13. © Copyright 2017 TopQuadrant Inc. Slide 13 Property  Shapes  -­‐ 1 § Can  be  specified  “in  line”  within  a  node  shape – As  a  blank  node – Or  as  a  resource § Its  focus  nodes  are  values  (objects)  of  the  property  (or  property   path)  specified  by  sh:path – Any  target  statements  within  such  property  shapes  are  ignored ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ; sh:pattern “^http://mydomain.com/person/”; sh:property [  #  _:b1   sh:path ex:firstName ;   sh:minCount 1  ;   sh:datatype xsd:string ;  ]  ; sh:property [  #  _:b2   sh:path ex:lastName ;   sh:minCount 1  ;   sh:maxCount 1  ;   sh:datatype xsd:string ;   sh:maxLength 20  ;]  . Node  Shape Property  Shape Property  Shape
  14. 14. © Copyright 2017 TopQuadrant Inc. Slide 14 Property  Shapes  -­‐ 2 ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ; sh:pattern “^http://mydomain.com/person/”; sh:property ex:Person-­‐firstName ; sh:property ex:Person-­‐lastName . ex:Person-­‐firstName a  sh:PropertyShape ; sh:path ex:firstName ;   sh:minCount 1  ;   sh:datatype xsd:string .   ex:Person-­‐lastName a  sh:PropertyShape ; sh:path ex:lastName ;   sh:minCount 1  ;   sh:maxCount 1  ;   sh:datatype xsd:string ;   sh:maxLength 20  . § Here  we  use  URIs  for  the  property  shapes § URIs  can  be  addressed/extended  from  other  graphs
  15. 15. © Copyright 2017 TopQuadrant Inc. Slide 15 Property  Shapes  -­‐ 3 ex:NameShape a  sh:PropertyShape ;   sh:targetSubjectsOf ex:name ; sh:path ex:name ;   sh:maxLength 20  ;   sh:datatype xsd:string . § Can  be  completely  ”standalone” § In  these  cases,  target  statements  are  taken  into  account § Best  practice  is  to  declare  the  type  sh:PropertyShape.   – However,  SHACL  processors  will  recognize  property  shapes  even  without  a  type   statements.  For  example,  subjects  of  triples  with  sh:path predicate  are   understood  to  be  property  shapes
  16. 16. © Copyright 2017 TopQuadrant Inc. Slide 16 Path  Expressions § The  value  of  sh:path can  be  a  single  predicate § Or  it  can  be  a  property  path § For  example,  anyone  a  person  knows  must  have  a  first  name  that  is  a  string  and  it   must  also  be  a  person  (in  SPARQL  syntax:  ex:knows /  ex:firstName) § SHACL  supports  a  subset  of  SPARQL  property  paths.  Specifically: – PredicatePath, InversePath, SequencePath, AlternativePath, ZeroOrMorePath, OneOrMorePath and ZeroOrOnePath. ex:Person a  sh:NodeShape ;   a  owl:Class ; sh:property [  #  _:b1   sh:path (  ex:knows ex:firstName )  ;   sh:minCount 1  ;   sh:datatype xsd:string ;  ]  ; sh:property [  #  _:b2   sh:path (  ex:knows rdf:type )  ;   sh:class ex:Person ;  ].
  17. 17. © Copyright 2017 TopQuadrant Inc. Slide 17 Conjunction  and  Disjunction  -­‐ 1 § Constraints  are  conjunctive   by  default – All  apply   – sh:or is  used  for  disjunction   – Example   • All  resources  that  are  used  as   objects  of  triples  with   ex:customer predicate  must:   – Have  exactly  one  first  name   – Have  exactly  one  last  name – Be  of  type  Person  and of  type   Customer []  a  sh:NodeShape ;   sh:targetObjectsOf ex:customer ;   sh:property [  sh:path ex:firstName ;   sh:minCount 1  ;  ]  ;   sh:property [  sh:path ex:firstName ;   sh:maxCount 1  ;  ]  ;   sh:property [  sh:path ex:lastName ; sh:minCount 1  ;   sh:maxCount 1  ;  ]  ;   sh:property [  sh:path rdf:type ;   sh:hasValue ex:Customer ; sh:hasValue ex:Person ;  ]  .
  18. 18. © Copyright 2017 TopQuadrant Inc. Slide 18 Conjunction  and  Disjunction  -­‐ 2 – Example   • All  resources  that  are  used  as   objects  of  triples  with   ex:customer predicate  must:   – Have  exactly  one  first  name   – Have  exactly  one  last  name – Be  of  type  Person  or of  type   Customer []  a  sh:NodeShape ;   sh:targetObjectsOf ex:customer ;   sh:property [  sh:path ex:firstName ;   sh:minCount 1  ;  ]  ;   sh:property [  sh:path ex:firstName ;   sh:maxCount 1  ;  ]  ;   sh:property [  sh:path ex:lastName ; sh:minCount 1  ;   sh:maxCount 1  ;  ]  ; sh:property [  sh:path rdf:type ; sh:or ( [  sh:hasValue ex:Customer ] [  sh:hasValue ex:Person ] )  ]  .
  19. 19. © Copyright 2017 TopQuadrant Inc. Slide 19 Shape  re-­‐use § owl:imports – used  to  combine  shape  graphs § sh:deactivated – used  to  disable  shapes   – Supports  re-­‐use  and  is  also  useful  for  testing   during  shapes  development #  baseURI:   http://www.example.org/shapes1/ ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ;   sh:property ex:PersonShape-­‐name .   ex:PersonShape-­‐name a  sh:PropertyShape ;   sh:path ex:name ;   sh:minCount 1. #  baseURI:   http://www.example.org/shapes2/ <http://www.example.org/shapes2/>   owl:imports http://www.example.org/shapes1/ . ex:PersonShape-­‐name sh:deactivated true  .
  20. 20. © Copyright 2016 TopQuadrant Inc. Slide 20 SHACL  Validation  Results
  21. 21. © Copyright 2017 TopQuadrant Inc. Slide 21 Validation  Report  Vocabulary § sh:conforms – true  if  no  validation  results  were  produced § sh:result/sh:ValidationResult § sh:focusNode – identifies  a  node  that  produced  the  results  i.e.,  a   node  that  has  problems § sh:value – identifies  what  value  is  incorrect § sh:resultPath – identifies  how  the  incorrect  value  is  connected  to   the  focus  node § sh:sourceShape – what  shape  has  been  violated § sh:sourceConstraintComponent – what  constraint  component   has  been  violated § sh:detail – further  details § sh:resultMessage – tools  may  use  this  to  return  helpful  messages   to  the  users § sh:resultSeverity
  22. 22. © Copyright 2017 TopQuadrant Inc. Slide 22 Shapes  can  specify  severities § 3  predefined  severities – Violation,  Warning,  Info  -­‐ Default   to  Violation  if  unspecified   – Open  to  extensions,  users  can   specify  their  own  severities § Passed  to  the  violation  results   as  annotation   – Severity  does  not  matter  to  the   validation  result § Example   – Must  have  a  name – Should  have  an  address – Nice-­‐to-­‐have  a  postal  code []  a  sh:NodeShape ;   sh:targetClass ex:Employee ;   sh:property [   sh:path ex:name ;   sh:severity sh:Violation ; sh:minCount 1  ;  ]  ;   sh:property [   sh:path ex:address ; sh:severity sh:Warning ;   sh:minCount 1  ;  ]  ;   sh:property [   sh:path ex:postCode ;   sh:severity sh:Info ;   sh:minCount 1  ;  ]  ;
  23. 23. © Copyright 2016 TopQuadrant Inc. Slide 23 Annotations  – used  for  form  building
  24. 24. © Copyright 2017 TopQuadrant Inc. Slide 24 Shapes  can  specify  severities § sh:name:  a  short  name   § sh:description:  a  short   description   § sh:order:  the  suggested  display   order   § sh:group:  the  suggested  display   group   § sh:defaultValue:  may be  used  by   user  interface  tools  to  pre-­‐ populate  input  widgets.   – The  value  type  of   the sh:defaultValue should  align   with  the   specified sh:datatype or sh:class of   the  same  shape. ex:Employee a  sh:NodeShape ;   a  rdfs:Class; sh:property [   sh:path ex:firstName ;             sh:order 1  ;   sh:group ex:PersonalDetails ;   sh:name “First  Name”  ;   sh:description “First  name  of   the  employee”  ;  ]  ;   sh:property [   sh:path ex:lastName ;   sh:order 2  ;   sh:group ex:PersonalDetails ; sh:name “Last  Name”  ;   sh:description “Last  name  of   the  employee”  ;  ]  ;   ex:PersonalDetails a  sh:PropertyGroup ;   sh:order 0  ;   rdfs:label "Employee  Personal   Details"  .                
  25. 25. © Copyright 2016 TopQuadrant Inc. Slide 25 SHACL  Core  Summary
  26. 26. © Copyright 2017 TopQuadrant Inc. Slide 26 Value  Type  Constraint   Components   § sh:class – The  value  is  of  type  provided  (or  one  of  subclasses) § sh:datatype – The  value  is  of  the  datatype  provided   § sh:nodeKind – The  value  is  one  of: • sh:BlankNode,   • sh:IRI,  sh:Literal • sh:BlankNodeOrIRI • sh:BlankNodeOrLiteral sh:IRIOrLiteral
  27. 27. © Copyright 2017 TopQuadrant Inc. Slide 27 Value  Range  Constraint   Components   § sh:minExclusive /  sh:minInclusive – Value  more  than  (or  equal)  than   § sh:maxExclusive /  sh:maxInclusive – Value  less  than  (or  equal)  than
  28. 28. © Copyright 2017 TopQuadrant Inc. Slide 28 Cardinality  Constraint   Components   § sh:minCount – There  must  be  at  least  the  number  of  values   specified   § sh:maxCount – There  must  be  at  most  the  number  of  values   specified   § Note  Absence  of  cardinality  constraints  assumes   values  are  unbound  [0,  unlimited)
  29. 29. © Copyright 2017 TopQuadrant Inc. Slide 29 String  Values  Constraint   Components   § sh:minLength /  sh:maxLength – Number  of  min/max  characters   § Sh:pattern (+  sh:flags)   – The  value  conforms  to  provided  regular  expression   pattern § sh:languageIn – The  language  of  the  literals  must  be  in  an   enumerated  list  of  language  codes § sh:uniqueLang – At  most  one  value  per  language  (e.g.  only  1  English)
  30. 30. © Copyright 2017 TopQuadrant Inc. Slide 30 Property  Pairs  Constraint   Components   § sh:equals – Values  of  a  property  equals   the  values  of  another   property   § sh:disjoint – No  values  of  a  property  are   equals  to  any  value  of   another  property   § sh:lessThan /   sh:lessThanOrEquals – All  values  of  a  property  are   less  (or  equal)  than  all  values   of  another  property []  a  sh:NodeShape ;   sh:targetClass ex:Person ;   sh:property [   sh:path ex:firstName ;   sh:equals ex:givenName ;  ]  ;   sh:property [   sh:path ex:child ;   sh:disjoint ex:parent ;  ]  ;   sh:property [   sh:path ex:birthDate ;   sh:lessThanOrEquals ex:deathDate ;  ]  .
  31. 31. © Copyright 2017 TopQuadrant Inc. Slide 31 Logical  Expressions  Constraint   Components   § sh:or – disjunction § sh:not – For  example,  no  one  can  be  linked  by  ex:know to   example:Bob § sh:xone – for  example,  must  either  have  a  value  for ex:fullName or   values  for ex:firstName and ex:lastName,  but  not  both § sh:and – necessary  for  “compounding”  of  shapes  and  combining   other  expressions – for  example,  must  satisfy  conditions  in  the  ex:PersonShape plus  some  additional  conditions
  32. 32. © Copyright 2017 TopQuadrant Inc. Slide 32 Shape-­‐based  Constraint   Components   § sh:node – supports  nesting  of  shapes – for  example,  address  of  a   person  must  satisfy   conditions  in  the   ex:AddressShape § sh:property – to  aggregate  property  shapes   within  a  node  shape § Qualified  value  shapes ex:AddressShape a  sh:NodeShape ;   sh:property [   sh:path ex:postalCode ;   sh:datatype xsd:string ;   sh:maxCount 1  ;  ]  .   ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ;   sh:property [  #  _:b1   sh:path ex:address ;   sh:minCount 1  ;   sh:node ex:AddressShape ;  ]  .
  33. 33. © Copyright 2017 TopQuadrant Inc. Slide 33 Qualified  Value  Shapes  Constraint   Component   § Similar  to  the  qualified   cardinality  constraints  in  OWL § For  example,  every  project   team  must  have  at  least  one   member  who  is  a  project   manager § sh:qualifiedValueShape § sh:qualifiedMinCount/   sh:qualifiedMinCount § sh:qualifiedValueShapesDisjoint ex:ProjectTeam a  sh:NodeShape ;   a  owl:Class ; sh:property [   sh:path ex:member ;   sh:minCount 1  ; sh:qualifiedValueShape [   sh:path rdf:type ;   sh:hasValue ex:ProjectManager ;  ]  ;   sh:qualifiedMinCount 1  ;   ]  .
  34. 34. © Copyright 2017 TopQuadrant Inc. Slide 34 Miscellaneous  Constraint   Components   § sh:closed/sh:ignoredProperties – only  explicitly  stated  properties   are  allowed – optional  list  of  properties  to   ignore  when  applying  “closed”   constraint § sh:hasValue § sh:in – List  of  values ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ; sh:stem “http://mydomain.com/person/; sh:closed “true”; Sh:ignoredProperties (rdf:type)  ; sh:property [  #  _:b1   sh:path ex:firstName ;   sh:minCount 1  ;   sh:datatype xsd:string ;  ]  ; sh:property [  #  _:b2   sh:path ex:lastName ;   sh:minCount 1  ;   sh:maxCount 1  ;   sh:datatype xsd:string ;   sh:maxLength 20  ;]  .
  35. 35. © Copyright 2016 TopQuadrant Inc. Slide 35 SHACL-­‐SPARQL
  36. 36. © Copyright 2017 TopQuadrant Inc. Slide 36 SHACL  is  an  Extensible  Language § SHACL  Core  defines  constraint  components  that   most  users  will  need § Design  goal  was  to  cover  80%  of  the  use  cases § It  is  expected  that  most  users  will  also  need  some   ”custom”  constraint  components § Possible  examples  are  endless: – What  if  you  need  to  do  some  calculations  as  part  of  data  validation – What  if  you  need  to  compare  values  of  three  properties  and  not  just   two,  etc. § SHACL  offers: – SPARQL-­‐based  Constraint  Component – a  way  to  declare  new  constraint  components  using  SPARQL • And  other  languages  like  JavaScript
  37. 37. © Copyright 2017 TopQuadrant Inc. Slide 37 SPARQL-­‐based  Constraint   Component § This  component  allows  you  to  specify  a  SPARQL   query  that  will  determine  if  the  focus  nodes  are  valid ex:LanguageExampleShape a  sh:NodeShape ;   sh:targetClass ex:Country ;   sh:sparql [   a  sh:SPARQLConstraint ;  #  This  triple  is  optional   sh:message "Values  are  literals  with  German  language  tag."  ;   sh:prefixes ex:  ;   sh:select """  SELECT  $this  (ex:germanLabel AS  ?path)  ?value   WHERE  {   $this  ex:germanLabel ?value  .   FILTER  (!isLiteral(?value)  ||   !langMatches(lang(?value),  "de"))  }  """  ;  ]  .
  38. 38. © Copyright 2017 TopQuadrant Inc. Slide 38 Vocabulary  for  declaring  new   Constraint  Components § sh:parameter – to  specify  what  are  the   parameters  of  the  component § sh:validator – declarative  template  that   determines  validation  logic
  39. 39. © Copyright 2016 TopQuadrant Inc. Slide 39 Compact  Syntax
  40. 40. © Copyright 2017 TopQuadrant Inc. Slide 40 Motivation  for  the  Compact  Syntax § SHACL  shapes  in  RDF  can  be  verbose § Like  XML  Schema  and  OWL,  they  are  not  intended  to   be  developed  in  a  text  editor,  but  rather  with   specialized  tools.  See: – Using  SHACL  in  TopBraid Composer – Using  SHACL  in  TopBraid EDG  and  TopBraid EVN § Still,  some  potential  users  expressed  a  desire  for  a   more  compact  syntax § Note:  Compact  syntax  is  currently  a  Working  Group   Note,  not  a  W3C  Recommendation.  It  covers  a   (significant)  subset  of  SHACL  Core
  41. 41. © Copyright 2017 TopQuadrant Inc. Slide 41 Compact  Syntax  Example § Targets  are  identified  first  using  “-­‐>” § Statements  about  target  nodes  themselves  follow  directly  after  the  “{“,   separated  by  spaces,  end  with  “;” § In  line  property  shapes  start  with  the  name  of  the  property  (or  a  SPARQL   property  path) ex:PersonShape a  sh:NodeShape ;   sh:targetClass ex:Person ; sh:closed true  ; sh:ignoredProperties (rdf:type)  ; sh:pattern “^http://mydomain.com/person/”; sh:property [  sh:path ex:firstName ;   sh:minCount 1  ;   sh:datatype xsd:string ;  ]  ; sh:property [sh:path ex:lastName ;   sh:minCount 1  ;   sh:maxCount 1  ;   sh:datatype xsd:string ;   sh:maxLength 20  ;]  . ex:PersonShape -­‐>  ex:Person {   closed=true  ignoredProperties=[rdf:type]   pattern=“^http://mydomain.com/person/”;   ex:firstName xsd:string [1..*];   ex:lastName xsd:string [1..1]  maxLength=20  ;   }
  42. 42. © Copyright 2016 TopQuadrant Inc. Slide 42 ENDS

×