OK, so it's not a PySHACL issue/limitation. I saved my minimal example to a file named 'ex.ttl' (after adding '<' and '>' around the URLs on the first lines that I'd missed), and:
$ venv-pyshacl/bin/pyshacl ex.ttl Validation Report Conforms: True So the RDF is fine, and PySHACL does not complain. From what you've discovered, maybe it's the translation to JSON-LD that introduces the problem. Since this is not something for email threads, do you mind opening an issue on the spec-parser repo? -- zvr -----Original Message----- From: Joshua Watt <[email protected]> Sent: Thursday, 26 October, 2023 16:57 To: Sean Barnum <[email protected]> Cc: Zavras, Alexios <[email protected]>; Gary O'Neall <[email protected]>; SPDX Technical Mailing List <[email protected]> Subject: Re: [spdx-tech] RDF range problem in SHACL model I couldn't figure out how to get that example to work (because this is all very new to me, and the https://shacl.org/playground/ didn't like it when I just copied and pasted it in there.... however I was looking through the model.jsonld and I think maybe I saw something suspicious. The CreationInfo class is defined as: { "@id": "core:CreationInfo", "@type": [ "owl:Class", "sh:NodeShape" ], "sh:property": [ { "@id": "_:N34622bbc773e4833a8e46851e0ed869c" }, ] }, { "@id": "_:N34622bbc773e4833a8e46851e0ed869c", "sh:class": { "@id": "core:Agent" }, "sh:minCount": 1, "sh:name": "createdBy", "sh:path": { "@id": "core:createdBy" } }, { "@id": "core:createdBy", "@type": "owl:ObjectProperty", "rdfs:domain": { "@id": "core:CreationInfo" }, "rdfs:range": { "@id": "core:Agent" } }, So, based on my reading, is is possible the property (_:N34622bbc773e4833a8e46851e0ed869c) is placing an additional constraint on the property via the "sh:class" that must exactly match "core:Agent". Also, strange to me (but again, I don't understand RDF) why the "rdfs:range" only seems to be linked to the property via "sh:path" instead of being in the "sh:property" itself ? On Thu, Oct 26, 2023 at 8:48 AM Sean Barnum <[email protected]> wrote: > > I agree. > > > > From: [email protected] <[email protected]> on behalf of > Alexios Zavras <[email protected]> > Date: Thursday, October 26, 2023 at 10:32 AM > To: Gary O'Neall <[email protected]>, 'Joshua Watt' > <[email protected]>, 'SPDX Technical Mailing List' > <[email protected]> > Subject: [EXT] Re: [spdx-tech] RDF range problem in SHACL model > > I agree that all instances of a subclass (Organization) are also > instances of the superclass (Agent), so there should not be any issue. > This is not even related to SHACL; it’s simple RDF. Minimal example to > try: @prefix rdfs: http: //www. w3. org/2000/01/rdf-schema# > > I agree that all instances of a subclass (Organization) are also instances of > the superclass (Agent), so there should not be any issue. > > This is not even related to SHACL; it’s simple RDF. > > > > Minimal example to try: > > @prefix rdfs: http://www.w3.org/2000/01/rdf-schema# . > > @prefix owl: http://www.w3.org/2002/07/owl# . > > @prefix ex: http://zvr.invalid/rdf . > > > > ex:CreationInfo a owl:Class . > > ex:createdBy a owl:ObjectProperty ; > > rdfs:domain ex:CreationInfo ; > > rdfs:range ex:Agent . > > ex:Agent a owl:Class . > > ex:Organization a owl:Class ; > > rdfs:subClassOf ex:Agent . > > > > ex:someOrganization a ex:Organization . > > ex:someCreationInfo a ex:CreationInfo . > > ex:someCreationInfo ex:createdBy ex:someOrganization . > > > > > > > > -- > > zvr > > From: [email protected] <[email protected]> On Behalf Of > Gary O'Neall > Sent: Thursday, 26 October, 2023 14:19 > To: 'Joshua Watt' <[email protected]>; 'SPDX Technical Mailing > List' <[email protected]> > Subject: Re: [spdx-tech] RDF range problem in SHACL model > > > > Hi Joshua, > > > > From the RDF spec definition of rdfs:SubclassOf, it looks like subclasses > should be allowed in the range since all instances of the subclass should > also be instances of the class. > > > > We could try a different validator to see if this is an issue with > PySHACL. Here’s an online validator: https://shacl.org/playground/ > > > > If you found any documentation to the contrary, let me know. > > > > Sean, Alexios – any thoughts? > > Gary > > > > > -----Original Message----- > > > From: [email protected] <[email protected]> On Behalf > > Of > > > Joshua Watt > > > Sent: Wednesday, October 25, 2023 12:06 PM > > > To: SPDX Technical Mailing List <[email protected]> > > > Subject: [spdx-tech] RDF range problem in SHACL model > > > > > > I dug further into trying to get my Yocto SPDX output to validate > > against the > > > JSON LD SHACL model. I've made some progress, but I think maybe I've > > come > > > up against a problem that don't know how to solve. > > > > > > Disclaimer: I'm not an SHACL, RDF or ontology expert so please > > excuse my > > > misuse of nomenclature. > > > > > > It looks like there might be a problem in the model in regard to the > > usage of > > > "rdfs:range" to validate the type values of object properties. Based > > on my > > > reading and experiments, it looks like that field requires that the > > referenced > > > object be of _exactly_ one of the listed types, and cannot be a > > subclass > > > derived from that type. As an example, the "createdBy" property of > > > core:CreationInfo has "rdfs:range" of "core:Agent". Practically > > speaking, this > > > means that only an _exact_ core:Agent is allowed in this field, and > > classes > > > derived from that class (such as core:Organization) are not allowed > > (or at > > > least, pyshacl indicates a violation). > > > > > > > > > > > > > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon > Silva Chairperson of the Supervisory Board: Nicole Lau Registered > Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 > > Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#5402): https://lists.spdx.org/g/Spdx-tech/message/5402 Mute This Topic: https://lists.spdx.org/mt/102185295/21656 Group Owner: [email protected] Unsubscribe: https://lists.spdx.org/g/Spdx-tech/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
