- From: Gary Murphy <gary@schemaapp.com>
- Date: Mon, 10 Sep 2018 10:15:58 -0400
- To: Holger Knublauch <holger@topquadrant.com>
- Cc: public-shacl@w3.org
- Message-ID: <CADnyxpsRKHozQBgeONUn6m0j3YJWCMUsiRDMXoPY-1gY1LYfhA@mail.gmail.com>
Thanks for that tip, and I'm a bit disappointed by xor, it had so nearly
worked ;) I think I entered it by mistake while editing xone and when it
nearly gave nearly the results I expected, I just went with it (even
thought, logically, it's function was already covered by xone)
But inversePath did solve the issue within an xone:
sh:property [
sh:xone (
[ sh:path [ sh:inversePath schema:review ];
sh:minCount 1; ]
[ sh:path schema:itemReviewed ;
sh:minCount 1 ] );
sh:severity sh:Error ;
] .
seems to do what I need!
On Fri, Sep 7, 2018 at 9:02 PM Holger Knublauch <holger@topquadrant.com>
wrote:
> 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 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
>
>
> 1. 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; 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 <martha@schemaapp.com>
> w: https://www.schemaapp.com
>
> --
*Gary Murphy*
Developer, Schema App
e: gary@schemaapp.com <martha@schemaapp.com>
w: https://www.schemaapp.com
Received on Monday, 10 September 2018 14:16:34 UTC