Skip to content

"Multiple top-level property shapes for the same triple" when validating with SHACL #46

@tfrancart

Description

@tfrancart

Contact Details (Optional)

[email protected]

What happened?

I read https://github.com/diggsweden/interoperable-specifications/blob/main/docs/ap.md#multiple-top-level-property-shapes-for-the-same-triple and I don't think it can work this way.

Consider the given SHACL example

ex:ns1 a sh:NodeShape ;
  sh:label "Person" ;
  sh:property ex:ps1, ex:ps2 .
ex:ps1 a sh:PropertyShape ;
  sh:label "Hobbies" ;
  sh:path foaf:topic_interests ;
  sh:nodeKind sh:URI ;
  sh:pattern "^http://example.com/hobbies/.*$";
ex:ps2 a sh:PropertyShape ;
  sh:label "Professional interests in computer science" ;
  sh:path foaf:topic_interests ;
  sh:nodeKind sh:URI ;
  sh:pattern "^http://example.com/computer_science/.*$";

and consider the following 2 triples:

ex:Thomas foaf:topic_interests <http://example.com/hobbies/Cooking> .
ex:Thomas foaf:topic_interests <http://example.com/computer_science/SHACL> .

When validated with the above SHACL spec, the first triple will produce a Violation for ex:ps2, while the second triple will produce a Violation for ex:ps1. Put differently, any triple using a property defined with multiple different structures this way will generate a violation for all other structures that its own.
Or maybe SHACL-INSPEC does not care about its application profiles being used for validating data ?

I think a possible way to encode multiple structurally different usage of the same property is through sh:qualifiedValueShape:

ex:ns1 a sh:NodeShape ;
  sh:label "Person" ;
  sh:property ex:ps1, ex:ps2 .
ex:ps1 a sh:PropertyShape ;
  sh:label "Hobbies" ;
  sh:path foaf:topic_interests ;
  sh:qualifiedValueShape [
    sh:nodeKind sh:URI ;
    sh:pattern "^http://example.com/hobbies/.*$";
  ];
  
ex:ps2 a sh:PropertyShape ;
  sh:label "Professional interests in computer science" ;
  sh:path foaf:topic_interests ;
  sh:qualifiedValueShape [
    sh:nodeKind sh:URI ;
    sh:pattern "^http://example.com/computer_science/.*$";
  ] ;

Or using an sh:or to refer to those different property shapes could maybe be another option

Steps To Reproduce

see above

What did you expect?

I expect to be able to use a SHACL-INSPEC specification, containing multiple top-level property shapes for the same property to correctly validate RDF graphs.

Version (Optional)

No response

Screenshots (Optional)

No response

Relevant log output (Optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions