- From: David Habgood via GitHub <noreply@w3.org>
- Date: Mon, 04 Aug 2025 11:59:24 +0000
- To: public-shacl@w3.org
recalcitrantsupplant has just created a new issue for https://github.com/w3c/data-shapes: == Filtering on related nodes == I have had this use case come up recently in two different projects. I wish to select focus nodes based on some property value on a related node. For example "people with brown hair" in the example below: The part I am less clear on is how to then select the subgraph which includes both the focus nodes and the related nodes that were used in the filtering. The example below was created by @ashleysommer https://github.com/RDFLib/prez/issues/378#issuecomment-3017909892 Data graph: ```turtle ex:person1 a schema:Person; schema:identifier "person1" ; schema:additionalProperty [ schema:name "hair-colour"; rdf:value "brown"; ] ; schema:additionalProperty [ schema:name "eye-colour"; rdf:value "blue"; ] ; . ex:person2 a schema:Person; schema:identifier "person1" ; schema:additionalProperty [ schema:name "hair-colour"; rdf:value "blonde"; ] ; schema:additionalProperty [ schema:name "eye-colour"; rdf:value "brown"; ] ; . ``` Shapes graph: ```turtle :BrownHairPropertyShape a sh:NodeShape ; sh:property [ sh:path schema:name ; sh:hasValue "hair-colour" ] ; sh:property [ sh:path rdf:value ; sh:hasValue "brown" ] . :PeopleWithBrownHair a sh:NodeShape ; sh:targetNode [ sh:nodes [ sh:instancesOf schema:Person ] ; sh:filterShape [ sh:property [ sh:path schema:additionalProperty ; sh:node :BrownHairPropertyShape ] ] ] ; sh:property [ sh:path :hairColourValue ; sh:values [ sh:nodes [ sh:path schema:additionalProperty ] ; sh:filterShape :BrownHairPropertyShape ; sh:path rdf:value ] ] ; sh:property [ sh:path :hairColourName ; sh:values [ sh:nodes [ sh:path schema:additionalProperty ] ; sh:filterShape :BrownHairPropertyShape ; sh:path schema:name ] ] . ``` Does this look correct? I am wondering if there is a simpler way to express this. Potentially this would be a good example in an appendix (or perhaps it's a good example of when to instead use SHACL SPARQL or inference rules). Please view or discuss this issue at https://github.com/w3c/data-shapes/issues/458 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 4 August 2025 11:59:25 UTC