-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request for style guidance on top-level property shapes #172
Comments
Hi @ajnelson-nist Thank you for your well thought out and well written post, you have presented some great arguments to consider. Firstly, I want to state that I am not an authoritative or definitive source on SHACL style. My only experience with writing SHACL shapes and constraints is for the purposes of thoroughly testing PySHACL code paths, I have not used it in the real world personally, though I work with people who do. My advice to you that - you've mentioned above - was drawn only from my experience writing the PySHACL validator and from helping users determine the cause of problems they are facing with PySHACL. All of my knowledge of how to write SHACL shapes and constraints comes from reading the tests and references in the W3C SHACL Test Suite (sht-tests), and the DataShapes org test SHACL test suite (DASH-tests). I admit these are probably not a great set of examples to learn from. In the SHT-test suite core-tests, there are no examples of or tests written for a In my role as PySHACL maintainer, the only times I see examples of users using standalone As I see it, the biggest danger with having standalone
It might not be obvious in this example, the
You can get around this issue by still using reusable named shapes, like this
This gives you re-usability, and Shape identification, without the
Yes, you are right, there is value doing it, if it is your preferred style and fits within the ontology and shapes documents you are building, and if you use it correctly and consistently, it is a perfectly valid method of writing your shapes. The best places to discuss this topic further are the SHACL W3C mailing list, and the SHACL community discord chat server, folks on there will be able to give you much better advice than I can. |
Hello @ashleysommer,
In this comment, you offered some implementation-style guidance that makes me curious for a citable source. The purpose of this Issue is reconciling those recommendations against what I currently find to be benefits of going against the implementation style recommendations you noted.
The SHACL specification does include examples of targeting methods used on named property shapes, e.g. from 4.2.1:
and from 5.1:
So, the specification is permissive of top-level, targeting
sh:PropertyShape
s, and my scan of the document for occurrences of the string "sh:PropertyShape" found no prescriptions against doing so. (I welcome a section reference if I missed such a prescription - completely possible.)I have found some beneficial reasons for doing so. My community is developing an ontology as a mix of OWL and SHACL, and using SHACL for data enforcement rules. I have also been using SHACL to help understand other ontologies that are implemented solely in OWL.
To help verify that our usage of various
rdf:Property
s is conformant with their definitions in our or upstream ontologies and RDF schemas, we have some shapes that are defined solely centered on when the property is used, agnostic to what class is using them.Taking your example about the tally of tabby limbs:
ex:myShape rdf:type sh:PropertyShape ; sh:targetClass ex:Cat ; sh:path ex:numLeg; sh:maxInclusive 4; .
Thanks to wanting to share
numLeg
with other animal classes, I'd prefer to haveex:numLeg
get some prescription about characteristics its usage will always require, and then leave it to classes to make their own inherent, blank-nodesh:PropertyShape
s to spell out their own requirements:(I'll note that this implementation style is my preference, and other members of my community prefer the style that repeats all constraints due to at least some simplified documentation-scripting.)
The other reason I prefer making top-level
sh:PropertyShape
s is to give the shape an IRI so any SHACL violation reports are easier to reference to a specific shape instance in the ontology. Using the always-inlining style you'd suggested, all that gets reported in thesh:sourceShape
is the blank node and its inlined constraints, and there is no hint about what the targeter was, so I would have to do a non-trivial review of the ontology (including SPARQL and mental class resolution) to find thesh:PropertyShape
and its contextualsh:NodeShape
. This problem is also met by following your suggested style of only ever using targeters onsh:NodeShape
s.So, for these reasons concerning constraint scoping and SHACL report usability, I see value in having
sh:PropertyShape
s that are independent ofsh:NodeShape
s. I'm interested in learning more about why you recommended what you did, especially if I'm settling on a practice that is going to be bite me spectacularly for some subtle reason.The text was updated successfully, but these errors were encountered: