ISSUE-133

From RDF Data Shapes Working Group
Jump to: navigation, search

This page collects examples of shapes for two syntax variations of SHACL. The first one is the current syntax. The second is based on merging sh:Shape and sh:NodeConstraint into a single class, and dropping sh:constraint.

Example: Closed shape

   ex:ClosedShape
       a sh:Shape ;
       sh:constraint [
           sh:closed true ;
           sh:ignoredProperties ( rdf:type ) ;
       ] ;
       sh:property [
           sh:predicate ex:onlyProperty ;
       ] .
   ex:ClosedShape
       a sh:Shape ;
       sh:closed true ;
       sh:ignoredProperties ( rdf:type ) ;
       sh:property [
           sh:predicate ex:onlyProperty ;
       ] .

Example: Values must be either strings or ex:Addresses

   ex:PersonShape
       a sh:Shape ;
       sh:property [
           sh:predicate ex:address ;
           sh:or (
               [
                   sh:constraint [
                       sh:datatype xsd:string ;
                   ]
               ]
               [
                   sh:constraint [
                       sh:class ex:Address ;
                   ]
               ]
           ) ;
       ] .
   ex:PersonShape
       a sh:Shape ;
       sh:property [
           sh:predicate ex:address ;
           sh:or (
               [
                   sh:datatype xsd:string ;
               ]
               [
                   sh:class ex:Address ;
               ]
           ) ;
       ] .

Example: Rectangle with Area

"A Rectangle must either have width and height, or an area"

   ex:RectangleWithAreaShape
       a sh:Shape ;
       sh:constraint [
           sh:or (
               [
                   sh:property [
                       sh:predicate ex:height ;
                       sh:minCount 1 ;
                   ] ;
                   sh:property [
                       sh:predicate ex:width ;
                       sh:minCount 1 ;
                   ] ;
               ]
               [
                   sh:property [
                       sh:predicate ex:area ;
                       sh:minCount 1 ;
                   ] ;
               ]
           ) ;
       ] .
   ex:RectangleWithAreaShape
       a sh:Shape ;
       sh:or (
           [
               sh:property [
                   sh:predicate ex:height ;
                   sh:minCount 1 ;
               ] ;
               sh:property [
                   sh:predicate ex:width ;
                   sh:minCount 1 ;
               ] ;
           ]
           [
               sh:property [
                   sh:predicate ex:area ;
                   sh:minCount 1 ;
               ] ;
           ]
       ) .