Is something missing in the shacl spec or just confusing or an error ?

106 views
Skip to first unread message

Maatary Okouya

unread,
Sep 21, 2021, 7:54:58 PM9/21/21
to TopBraid Suite Users

Taken from the specification: 

>>>
A node shape is a shape in the shapes graph that is not the subject of a triple with sh:path as its predicate.  SHACL instances of sh:NodeShape cannot have a value for the property sh:path.
>>>

Yet when talking Or Constraint or And Constraint, that takes list of shapes, we find example like what follow: 

>>>>
ex:SuperShape a sh:NodeShape ;
   sh:property [ sh:path ex:property ; sh:minCount 1 ; ] .

ex:ExampleAndShape a sh:NodeShape ; 
   sh:targetNode ex:ValidInstance, ex:InvalidInstance ; 
   sh:and ( 
                  ex:SuperShape 
                  [ 
                      sh:path ex:property ; 
                      sh:maxCount 1 ; 
                   ] ) .
>>>>

With the following explanation 

>>>
The following example illustrates the use of sh:and in a shape to specify the condition that certain focus nodes have exactly one value of ex:property. This is achieved via the conjunction of a separate named shape (ex:SuperShape) which specifies the minimum count, and a blank node shape that additionally specifies the maximum count. As shown here, sh:and can be used to implement a specialization mechanism between shapes.
>>>>

How on earth is this a Blank Node shape if it is the subject of an sh:path, am I missing something ?

```
 [ 
    sh:path ex:property ; 
     sh:maxCount 1 ; 
  ] 
```

Holger Knublauch

unread,
Sep 21, 2021, 8:01:59 PM9/21/21
to topbrai...@googlegroups.com

It should be a "blank property shape". I have recorded a bug report to the spec's Errata:

    https://github.com/w3c/data-shapes/issues/140

Note the error is in an informative block of text, so it doesn't change implementations.

Thanks for pointing this out
Holger



```
 [ 
    sh:path ex:property ; 
     sh:maxCount 1 ; 
  ] 
```
--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/a36d9325-ff9a-4329-86a3-64a463798b1dn%40googlegroups.com.

Maatary Okouya

unread,
Sep 21, 2021, 8:35:56 PM9/21/21
to TopBraid Suite Users
1 - Does that mean  that fundamentally, the list of shape in an sh:Or or sh:And is heterogenous ? That is, it may contain both propertyShape and NodeShape at the same time ? 

2 - This bring me to  the question of  how to read this ? 


>>>>
ex:ExampleAndShape a sh:NodeShape ; 
   sh:targetNode ex:ValidInstance, ex:InvalidInstance ; 
   sh:and ( 
                  ex:SuperShape 
                  [ 
                      sh:path ex:property ; 
                      sh:maxCount 1 ; 
                   ] ) .
>>>>

2-1 - With respect to s:SuperShape: is it  saying that ex:ExampleAndShap rdfs:SubClassOf ex:SuperShape  ?

2-2 - With respect to 
 [ 
      sh:path ex:property ; 
      sh:maxCount 1 ; 
 ] 

is it saying 
ex:ExampleAndShape  has the propertyshape i.e. sh:property
 [ 
      sh:path ex:property ; 
      sh:maxCount 1 ; 
 ] 

???

Holger Knublauch

unread,
Sep 21, 2021, 8:43:09 PM9/21/21
to topbrai...@googlegroups.com


On 2021-09-22 10:35 am, Maatary Okouya wrote:
1 - Does that mean  that fundamentally, the list of shape in an sh:Or or sh:And is heterogenous ? That is, it may contain both propertyShape and NodeShape at the same time ?
Yes, may contain any shape.


2 - This bring me to  the question of  how to read this ? 

>>>>
ex:ExampleAndShape a sh:NodeShape ; 
   sh:targetNode ex:ValidInstance, ex:InvalidInstance ; 
   sh:and ( 
                  ex:SuperShape 
                  [ 
                      sh:path ex:property ; 
                      sh:maxCount 1 ; 
                   ] ) .
>>>>

2-1 - With respect to s:SuperShape: is it  saying that ex:ExampleAndShap rdfs:SubClassOf ex:SuperShape  ?
No, not rdfs:subClassOf. This is just talking about shapes. But it would be equivalent to using
ex:ExampleAndShape

    sh:node ex:SuperShape ;

In general, sh:and is not needed and can be substituted with multiple sh:node constraints, or sh:property.


2-2 - With respect to 
 [ 
      sh:path ex:property ; 
      sh:maxCount 1 ; 
 ] 

is it saying 
ex:ExampleAndShape  has the propertyshape i.e. sh:property
 [ 
      sh:path ex:property ; 
      sh:maxCount 1 ; 
 ]

It means that the target nodes must conform to the given property shape, i.e. have at most one value of ex:property.

Yes, this could alternatively be written using sh:property, as I mentioned above sh:and is redundant and was only added for symmetry reasons.

There are subtle differences though in how validation errors would be reported between sh:property and sh:and. With sh:and you would only get a single violation, while with sh:property it would report each individual property violation separately.

OTOH sh:or is of course not redundant.

Holger


Maatary Okouya

unread,
Sep 21, 2021, 8:44:32 PM9/21/21
to TopBraid Suite Users
Just to conclude and be complete  about my last question, which is all that sparked the original question actually: 

(Note: I'm using rdfs:subclassOf informally here, just  to express the idea)

When we have 

```
ex:PersonAddressShape a sh:NodeShape ; 
  sh:targetClass ex:Person ; 
 sh:property [                                                //shprop1
   sh:path ex:address ; 
   sh:or ( 
               [                                                        //shprop2
                 sh:datatype xsd:string ;
               ]
               [                                                      //shprop3
                  sh:class ex:Address ; 
               ] 
             ) 
 ] .
```
Are we saying that shProp1 rdfs:subClassOf at least shProp1 or shProp2

Maatary Okouya

unread,
Sep 21, 2021, 8:52:34 PM9/21/21
to TopBraid Suite Users
>>>
No, not rdfs:subClassOf. This is just talking about shapes. But it would be equivalent to using
ex:ExampleAndShape

    sh:node ex:SuperShape ;

In general, sh:and is not needed and can be substituted with multiple sh:node constraints, or sh:property.

>>>
This is clear,  thank you. and yes knew about the about the redundant aspect of sh:And. In fact i am more interested about sh:Or, I just started with the sh:And example, because i was trying to understand what kind of shape are the list, and the sh:And example was the only one being specific about it. 
Sorry for the informal use of sh:subClassOf. Much better to be formal, but i guess i would have not known how to formally express it. So many thanks for this. 

Maatary Okouya

unread,
Sep 21, 2021, 9:01:01 PM9/21/21
to TopBraid Suite Users
I assumed that in my example that the list is made up of blank Property Shape? am i correct ?

```
ex:PersonAddressShape a sh:NodeShape ; 
  sh:targetClass ex:Person ; 
 sh:property [                                                //shprop1
   sh:path ex:address ; 
   sh:or ( 
               [                                                        //shprop2
                 sh:datatype xsd:string ;
               ]
               [                                                      //shprop3
                  sh:class ex:Address ; 
               ] 
             ) 
 ] .
```

 Hence i am interested in how one read this informally as much as formally. I don't think, as in the previous example above, sh:node or sh:property applies. Hence, little confused on this one

Note: I have been  using  all of this thing  in my application without problem, as i had the intuition about how those works and the support of TBC. But recently i have had  to parse shacl, and that is when the issue of what is what exactly,  or what is allowed where comes in. 



Holger Knublauch

unread,
Sep 21, 2021, 9:20:22 PM9/21/21
to topbrai...@googlegroups.com


On 2021-09-22 11:01 am, Maatary Okouya wrote:
I assumed that in my example that the list is made up of blank Property Shape? am i correct ?

```
ex:PersonAddressShape a sh:NodeShape ; 
  sh:targetClass ex:Person ; 
 sh:property [                                                //shprop1
   sh:path ex:address ; 
   sh:or ( 
               [                                                        //shprop2
                 sh:datatype xsd:string ;
               ]
               [                                                      //shprop3
                  sh:class ex:Address ; 
               ] 
             ) 
 ] .
```

The prop2 and prop3 constraints above are node shapes. But they are applied to all value nodes of the surrounding property shape.


 Hence i am interested in how one read this informally as much as formally. I don't think, as in the previous example above, sh:node or sh:property applies. Hence, little confused on this one

In general, both types of shapes apply to a focus node and its value node(s). For node shapes the value node == the focus node. If you would do

ex:PersonAddressShape
    sh:property [
        sh:path ex:address ;
        sh:or (
            [
                sh:path ex:postalCode ;
                sh:maxLength 4 ;
                sh:minCount 1 ;
           ]

...

this would mean that all value nodes of ex:address must have another property ex:postalCode with min length 4.

So basically the terminology "focus node" and "value node" matters a lot. Once this is clear, both types of shapes can be used interchangeably.

In the WG we had long long discussions about whether property shapes and node shapes can be used interchangeably, and I was hesitant and actually actively against too much flexibility here because it would confuse users. Sometimes less is more, and I believe your discussion and input from many other users have confirmed that the current design requires quite a level of abstraction to understand properly.

Holger


Maatary Okouya

unread,
Sep 21, 2021, 9:24:42 PM9/21/21
to TopBraid Suite Users
I guess one way that  would help me to easily answer this, is, someone could help fully expand the example, i.e. without any shortcut or abbreviation

Does

```
ex:PersonAddressShape a sh:NodeShape ; 
  sh:targetClass ex:Person ; 
 sh:property [                                                //shprop1
   sh:path ex:address ; 
   sh:or ( 
               [                                                        //shprop2
                 sh:datatype xsd:string ;
               ]
               [                                                      //shprop3
                  sh:class ex:Address ; 
               ] 
             ) 
 ] .
```

expand to

```
ex:PersonAddressShape a sh:NodeShape ; 
  sh:targetClass ex:Person ; 
 sh:property [                                                //shprop1
   sh:path ex:address ; 
   sh:or ( 
               [ 
                 a sh:PropertyShape ;                                                       //shprop2
                 sh:datatype xsd:string ;
               ]
               [ 
                  a sh:PropertyShape ;                                                     //shprop3
                  sh:class ex:Address ; 
               ] 
             ) 
 ] .
```

If so, then there is a relation between the PropertyShape described in the list and the outer PropertyShape. When i ask about how to read it, i am actually specifically asking, what's the nature, or how to describe,  the relation between the outer shape and the one in the list. 

I understand what the overall shape express here, but it does not help well understand how the language is fundamentally structured. 

This clarification would really help

Maatary Okouya

unread,
Sep 21, 2021, 9:27:27 PM9/21/21
to TopBraid Suite Users
I see, so i was wrong in my interpretation. 

Maatary Okouya

unread,
Sep 21, 2021, 9:31:13 PM9/21/21
to TopBraid Suite Users
Before, i go back and do my due diligence, 

Would be able to expand that into its full form, i mean representing explicitly the NodeShape 

```
ex:PersonAddressShape a sh:NodeShape ; 
  sh:targetClass ex:Person ; 
 sh:property [                                                //shprop1
   sh:path ex:address ; 
   sh:or ( 
               [                                                        //shprop2
                 sh:datatype xsd:string ;
               ]
               [                                                      //shprop3
                  sh:class ex:Address ; 
               ] 
             ) 
 ] .
```
```

Holger Knublauch

unread,
Sep 21, 2021, 9:33:56 PM9/21/21
to topbrai...@googlegroups.com

Modified below

Holger


On 2021-09-22 11:31 am, Maatary Okouya wrote:
Before, i go back and do my due diligence, 

Would be able to expand that into its full form, i mean representing explicitly the NodeShape 

```
ex:PersonAddressShape a sh:NodeShape ; 
  sh:targetClass ex:Person ; 
 sh:property [                                                //shprop1
   a sh:PropertyShape ;
   sh:path ex:address ; 
   sh:or ( 
               [                                                        //shprop2
                 a sh:NodeShape ;
                 sh:datatype xsd:string ;
               ]
               [                                                      //shprop3
                  a sh:NodeShape ;

Maatary Okouya

unread,
Sep 21, 2021, 9:52:18 PM9/21/21
to TopBraid Suite Users
I think I get your point about focus node and value node, and i will wrap my head around that. 

Weird that there is no one example that show that type of construction

ex:X a sh:NodeShape ;
sh:datatype xsd:string ;

But for the little i just understood,  this means that the two are equivalent ?

ex:aNodeSahpe a sh:NodeShape
sh:targetClass ex:Person

ex:aNodeSahpe a sh:NodeShape
sh:class ex:Person

Holger Knublauch

unread,
Sep 22, 2021, 12:10:41 AM9/22/21
to topbrai...@googlegroups.com


On 2021-09-22 11:52 am, Maatary Okouya wrote:
I think I get your point about focus node and value node, and i will wrap my head around that. 

Weird that there is no one example that show that type of construction
ex:X a sh:NodeShape ;
sh:datatype xsd:string ;

But for the little i just understood,  this means that the two are equivalent ?

ex:aNodeShape a sh:NodeShape
  sh:targetClass ex:Person

This means "All constraints defined by aNodeShape apply to all instances of Person".

(But the shape above doesn't define any constraints)


ex:aNodeShape a sh:NodeShape
sh:class ex:Person

This means "The constraints defined by aNodeShape are: - all value nodes must be instances of Person"

(But the shape doesn't define a target so it doesn't apply to anything in the graph).

For something to "happen" you need to have both a target and constraints, but

ex:aNodeShape


    a sh:NodeShape ;
    sh:targetClass ex:Person ;

    sh:class ex:Person ;

would be meaningless because it will only apply to Persons and then verifies that they are in fact Persons which is of course true.

Holger



Maatary Okouya

unread,
Sep 22, 2021, 7:31:53 PM9/22/21
to TopBraid Suite Users
This was helpful. Will keep wrapping my head around the core points you shared. Thanks
Reply all
Reply to author
Forward
0 new messages