- From: Holger Knublauch <holger@topquadrant.com>
- Date: Sat, 8 Sep 2018 11:02:19 +1000
- To: public-shacl@w3.org
- Message-ID: <ffe9fbdf-7fb6-9d37-9cca-91b11593c3c7@topquadrant.com>
Hi Gary, there is no sh:xor in SHACL, so we can remove that from the discussion. If you had results with this then sh:xor didn't have any effect to the validation. Also you seem to want to use sh:targetXY statements as a validation condition. If I understand what you are trying to express as "not used as a value of schema:review" then sh:not [ sh:targetObjectsOf schema:review ] ; needs to be rewritten using sh:max/minCount, maybe sh:property [ sh:path [ sh:inversePath schema:review ] ; sh:maxCount 1; ] ; The above would walk schema:review "backwards" starting at the focus node (instance of AggregateRating). Maybe this informs your next steps? Holger On 8/09/2018 6:00 AM, Gary Murphy wrote: > I have a novice question about setting alternatives in a NodeShape > using sh:xone, sh:xor and sh:or > > I need to evaluate a property of the targetClass such that, if the > node is targetObjectsOf a property in another node, then a particular > property should not be defined, but if not, then it is -- this pattern > occurs several times in schema.org <http://schema.org> validation rules. > > So for example, here was my naive attempt using sh:xone but also with > sh:xor and sh:or ... > > hmshape:AggregateRatingShape > a sh:NodeShape ; > sh:targetClass schema:AggregateRating ; > sh:property [ > sh:xone ( > [ > sh:not [ sh:targetObjectsOf schema:review ] ; > sh:path schema:itemReviewed ; > sh:minCount 1 ; > sh:severity sh:Error ; > ] > [ > sh:targetObjectsOf schema:review ; > sh:path schema:itemReviewed ; > sh:maxCount 0 ; > sh:severity sh:Warning ; > ] > ) ; > ] ; > . > > > and my graph: > > @prefix ex: <http://example.org/ns#> . > @prefix schema: <http://schema.org/> . > > ex:Bob > a schema:Person ; > schema:review ex:BobsAggregateRating ; > . > ex:BobsAggregateRating > a schema:AggregateRating ; > schema:itemReviewed ex:Bob ; > . > > > 1. When I take the schema:itemReviewed only out of > BobsAggregateRating, the validations passes for all three > xone/xor/or, which is correct. > 2. When I take the schema:review only out of Bob, I > get sh:sourceConstraintComponent sh:XoneConstraintComponent > although I expect it to be valid by the first clause; when I use > sh:xor it works as expected and there is no violation > 3. When I take out both properties, the validation passes with all of > sh:xone, sh:xor, and sh:or, although I expect a violation for the > missing schema:itemReviewed as per the first clause > 4. When I leave them both in, I get two violations, > one sh:MaxCountConstraintComponent warning because of the second > clause, and, with sh:xone or sh:or, I get one generic sh:Violation > because none of clauses fit, which is perhaps expected since > sh:xone/sh:or only need one failure to satisfy, but when I use > sh:xor, I just get the one sh:MaxCountContraintComponent warning.. > > Because of (1) and (4) it appears the (sh:not) sh:targetObjectOf is > working as a selector for each rule, but why do the other two cases > fail with sh:xone? I am testing this using the shacl.org/playground > <http://shacl.org/playground>; I also tried this same pattern using > sh:or with the same results. > > What am I missing here? Is this an appropriate use of > sh:xone/sh:xor/sh:or and/or sh:targetObjectOf? sh:xor gets me three > out of the four cases as expected, but why would it fail (3)? > > Any and all guidance is most welcome :) > > -- > *Gary Murphy* > Developer, Schema App > e: gary@schemaapp.com <mailto:martha@schemaapp.com> > w: https://www.schemaapp.com <https://www.schemaapp.com/> >
Received on Saturday, 8 September 2018 01:02:47 UTC