You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Florian Kleedorfer <fl...@austria.fm> on 2020/12/10 13:03:30 UTC
SHACL warning about cycle
Hi,
I am not aware of anything in the SHACL specs discouraging cycles in
shapes, but the jena SHACL parser warns about it:
10.12.20 13:53:11.460 [main] WARN SHACL - Cycle detected : node
<https://example.com/test/PersonShape>
for this minimal example:
@prefix ex: <https://example.com/test/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
ex:PersonShape
a sh:NodeShape;
sh:targetClass ex:Person ;
sh:property [ sh:path ex:mother ;
sh:node ex:PersonShape ] .
ex:alice a ex:Person .
ex:bob a ex:Person ;
ex:mother ex:alice .
Is that intended behaviour? Does that mean we should try to get rid of
any cycles?
Or, alternatively, could we lower the loglevel on this one?
Cheers,
Florian
Re: SHACL warning about cycle
Posted by Florian Kleedorfer <fl...@austria.fm>.
Thanks for the explanation!
Best regards,
Florian
Am 2020-12-10 17:59, schrieb Andy Seaborne:
> On 10/12/2020 13:03, Florian Kleedorfer wrote:
>> Hi,
>>
>> I am not aware of anything in the SHACL specs discouraging cycles in
>> shapes, but the jena SHACL parser warns about it:
>>
>> 10.12.20 13:53:11.460 [main] WARN SHACL - Cycle detected : node
>> <https://example.com/test/PersonShape>
>>
>> for this minimal example:
>>
>> @prefix ex: <https://example.com/test/> .
>> @prefix sh: <http://www.w3.org/ns/shacl#> .
>>
>> ex:PersonShape
>> a sh:NodeShape;
>> sh:targetClass ex:Person ;
>> sh:property [ sh:path ex:mother ;
>> sh:node ex:PersonShape ] .
>>
>> ex:alice a ex:Person .
>>
>> ex:bob a ex:Person ;
>> ex:mother ex:alice .
>>
>>
>> Is that intended behaviour?
>
> There are two ways to get to the same data objects.
>
> Via the sh:targetClass and also via the path from another
> ex:PersonShape -- you'll get two violations.
>
> Did you mean:
>
> sh:property [ sh:path ex:mother ;
> sh:class ex:PersonShape ] .
> ^^^^^^^^
>
> because pointing (sh:node) to the shape is also picking up the target.
>
> You'll still get validation of ex:mother-ex:mother-ex:mother because
> the target will trigger on each person.
>
> You can sh:node to a common shape but if that is for reuse of common
> patterns, then don't give that shape a target.
>
> Andy
>
> (See also discussion about cycles on the public-rdf-shapes@w3.org
> mailing list)
>
>> Does that mean we should try to get rid of any cycles?
>> Or, alternatively, could we lower the loglevel on this one?
>>
>> Cheers,
>> Florian
Re: SHACL warning about cycle
Posted by Andy Seaborne <an...@apache.org>.
On 10/12/2020 13:03, Florian Kleedorfer wrote:
> Hi,
>
> I am not aware of anything in the SHACL specs discouraging cycles in
> shapes, but the jena SHACL parser warns about it:
>
> 10.12.20 13:53:11.460 [main] WARN SHACL - Cycle detected : node
> <https://example.com/test/PersonShape>
>
> for this minimal example:
>
> @prefix ex: <https://example.com/test/> .
> @prefix sh: <http://www.w3.org/ns/shacl#> .
>
> ex:PersonShape
> a sh:NodeShape;
> sh:targetClass ex:Person ;
> sh:property [ sh:path ex:mother ;
> sh:node ex:PersonShape ] .
>
> ex:alice a ex:Person .
>
> ex:bob a ex:Person ;
> ex:mother ex:alice .
>
>
> Is that intended behaviour?
There are two ways to get to the same data objects.
Via the sh:targetClass and also via the path from another ex:PersonShape
-- you'll get two violations.
Did you mean:
sh:property [ sh:path ex:mother ;
sh:class ex:PersonShape ] .
^^^^^^^^
because pointing (sh:node) to the shape is also picking up the target.
You'll still get validation of ex:mother-ex:mother-ex:mother because the
target will trigger on each person.
You can sh:node to a common shape but if that is for reuse of common
patterns, then don't give that shape a target.
Andy
(See also discussion about cycles on the public-rdf-shapes@w3.org
mailing list)
> Does that mean we should try to get rid of
> any cycles?
> Or, alternatively, could we lower the loglevel on this one?
>
> Cheers,
> Florian