You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Martynas Jusevičius <ma...@atomgraph.com> on 2023/02/28 12:56:25 UTC
[SHACL] sh:prefixes
Hi,
Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
The following test shape
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
<#ConceptBroaderCycleShape>
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:message "Concept is broader than itself (directly or indirectly)" ;
sh:prefixes skos: ;
sh:select """
SELECT *
{
$this skos:broader+ $this .
}
""" ;
] .
returns an error:
org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
column 23: Unresolved prefixed name: skos:broader
at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
at org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
at org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
at org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
at org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
at org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
at org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
at org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
at org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
at org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
at org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
at org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
at org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
at shacl.shacl_validate.exec(shacl_validate.java:124)
at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
at shacl.shacl_validate.main(shacl_validate.java:60)
at shacl.shacl.main(shacl.java:81)
Martynas
Re: [SHACL] sh:prefixes
Posted by Andy Seaborne <an...@apache.org>.
Is there something in the WG test suite for this?
Andy
On 28/02/2023 12:56, Martynas Jusevičius wrote:
> Hi,
>
> Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
>
> The following test shape
>
> @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
> @prefix sh: <http://www.w3.org/ns/shacl#> .
>
> <#ConceptBroaderCycleShape>
> a sh:NodeShape ;
> sh:targetClass skos:Concept ;
> sh:sparql [
> a sh:SPARQLConstraint ;
> sh:message "Concept is broader than itself (directly or indirectly)" ;
> sh:prefixes skos: ;
> sh:select """
> SELECT *
> {
> $this skos:broader+ $this .
> }
> """ ;
> ] .
>
> returns an error:
>
> org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
> column 23: Unresolved prefixed name: skos:broader
> at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
> at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
> at org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
> at org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
> at org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
> at org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
> at org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
> at org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
> at org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
> at org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
> at org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
> at org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
> at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
> at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
> at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
> at org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
> at org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
> at shacl.shacl_validate.exec(shacl_validate.java:124)
> at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
> at shacl.shacl_validate.main(shacl_validate.java:60)
> at shacl.shacl.main(shacl.java:81)
>
>
> Martynas
Re: [SHACL] sh:prefixes
Posted by Holger Knublauch <ho...@topquadrant.com>.
There was a strongly related ticket that I have now tagged as Errata
https://github.com/w3c/data-shapes/issues/128
Missing prefix in example query · Issue #128 · w3c/data-shapes
github.com
I am certainly curious to see if SHACL can become a living standard. And I'd personally be happy to contribute if that happens.
Holger
> On 1 Mar 2023, at 9:24 pm, Andy Seaborne <an...@apache.org> wrote:
>
> Could you add it to the formal errata list? It does not appear to be listed at
>
> https://github.com/w3c/data-shapes/issues?q=is%3Aissue+is%3Aopen+label%3AErrata
>
> It helps make the case for work to be done.
>
> > go into that document and fix it
>
> The SHACL CG can publish a revised document as a CG report. While this does not replace the REC, it is a way forward - other specs proceed like this.
>
> Part of RDF-star WG charter to update specs and also prepare for "living standards". SHACL is not on the list but _maybe_ ...
>
> * if it is a small amount of work
>
> * if there is a list of errata so any adding SHACL has known costs.
> Anything open-ended is unlikely to get any traction.
> A CG report is evidence of this.
>
> * There needs to be one or more people to do the work.
>
> In theory, changes to documents in-scope for RDF-star WG can be done by by PRs from anyone who is able to sign the necessary IP agreement. It is not necessarily only RDF-star WG members make contributions; someone on the WG could shepherd it.
>
> Andy
>
>
>
> On 28/02/2023 13:26, Holger Knublauch wrote:
>> I know, almost everybody stumbles there. It was bad editing by the editor :)
>> Unfortunately I cannot just go into that document and fix it. That's the bane of these formal specs, and why many people get work done quicker outside of such formal processes.
>> Holger
Re: [SHACL] sh:prefixes
Posted by Andy Seaborne <an...@apache.org>.
Could you add it to the formal errata list? It does not appear to be
listed at
https://github.com/w3c/data-shapes/issues?q=is%3Aissue+is%3Aopen+label%3AErrata
It helps make the case for work to be done.
> go into that document and fix it
The SHACL CG can publish a revised document as a CG report. While this
does not replace the REC, it is a way forward - other specs proceed like
this.
Part of RDF-star WG charter to update specs and also prepare for "living
standards". SHACL is not on the list but _maybe_ ...
* if it is a small amount of work
* if there is a list of errata so any adding SHACL has known costs.
Anything open-ended is unlikely to get any traction.
A CG report is evidence of this.
* There needs to be one or more people to do the work.
In theory, changes to documents in-scope for RDF-star WG can be done by
by PRs from anyone who is able to sign the necessary IP agreement. It is
not necessarily only RDF-star WG members make contributions; someone on
the WG could shepherd it.
Andy
On 28/02/2023 13:26, Holger Knublauch wrote:
> I know, almost everybody stumbles there. It was bad editing by the editor :)
>
> Unfortunately I cannot just go into that document and fix it. That's the bane of these formal specs, and why many people get work done quicker outside of such formal processes.
>
> Holger
>
Re: [SHACL] sh:prefixes
Posted by Holger Knublauch <ho...@topquadrant.com>.
I know, almost everybody stumbles there. It was bad editing by the editor :)
Unfortunately I cannot just go into that document and fix it. That's the bane of these formal specs, and why many people get work done quicker outside of such formal processes.
Holger
> On 28 Feb 2023, at 1:24 pm, Martynas Jusevičius <ma...@atomgraph.com> wrote:
>
> Thanks Holger, that is the case :) The "sh:prefixes ex:" in the SHACL spec was somewhat confusing without context, because it looks like a Turtle prefix declaration.
>
> This works:
>
> :prefixes sh:declare [
> sh:prefix "skos" ;
> sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ;
> ] .
>
> <#ConceptBroaderCycleShape> sh:prefixes :prefixes ;
>
>
> On Tue, Feb 28, 2023 at 2:16 PM Holger Knublauch <holger@topquadrant.com <ma...@topquadrant.com>> wrote:
>> I suspect this is another instance of the common misunderstanding: the @prefix declarations are not mapped to any triples and are only a concept of the serialization. To make them visible to SHACL, you need to declare triples such as in
>>
>> Shapes Constraint Language (SHACL)
>> w3.org
>>
>> <https://www.w3.org/TR/shacl/#sparql-prefixes>Shapes Constraint Language (SHACL) <https://www.w3.org/TR/shacl/#sparql-prefixes>
>> w3.org <https://www.w3.org/TR/shacl/#sparql-prefixes> <https://www.w3.org/TR/shacl/#sparql-prefixes>
>> in your case it would be skos: as subject.
>>
>> Holger
>>
>>
>>> On 28 Feb 2023, at 12:56 pm, Martynas Jusevičius <martynas@atomgraph.com <ma...@atomgraph.com>> wrote:
>>>
>>> Hi,
>>>
>>> Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
>>>
>>> The following test shape
>>>
>>> @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
>>> @prefix sh: <http://www.w3.org/ns/shacl#> .
>>>
>>> <#ConceptBroaderCycleShape>
>>> a sh:NodeShape ;
>>> sh:targetClass skos:Concept ;
>>> sh:sparql [
>>> a sh:SPARQLConstraint ;
>>> sh:message "Concept is broader than itself (directly or indirectly)" ;
>>> sh:prefixes skos: ;
>>> sh:select """
>>> SELECT *
>>> {
>>> $this skos:broader+ $this .
>>> }
>>> """ ;
>>> ] .
>>>
>>> returns an error:
>>>
>>> org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
>>> column 23: Unresolved prefixed name: skos:broader
>>> at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
>>> at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
>>> at org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
>>> at org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
>>> at org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
>>> at org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
>>> at org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
>>> at org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
>>> at org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
>>> at org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
>>> at org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
>>> at org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
>>> at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
>>> at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
>>> at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
>>> at org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
>>> at org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
>>> at shacl.shacl_validate.exec(shacl_validate.java:124)
>>> at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
>>> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
>>> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
>>> at shacl.shacl_validate.main(shacl_validate.java:60)
>>> at shacl.shacl.main(shacl.java:81)
>>>
>>>
>>> Martynas
>>
Re: [SHACL] sh:prefixes
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Thanks Holger, that is the case :) The "sh:prefixes ex:" in the SHACL spec
was somewhat confusing without context, because it looks like a Turtle
prefix declaration.
This works:
:prefixes sh:declare [
sh:prefix "skos" ;
sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ;
] .
<#ConceptBroaderCycleShape> sh:prefixes :prefixes ;
On Tue, Feb 28, 2023 at 2:16 PM Holger Knublauch <ho...@topquadrant.com>
wrote:
> I suspect this is another instance of the common misunderstanding: the
> @prefix declarations are not mapped to any triples and are only a concept
> of the serialization. To make them visible to SHACL, you need to declare
> triples such as in
>
> Shapes Constraint Language (SHACL)
> <https://www.w3.org/TR/shacl/#sparql-prefixes>
> w3.org <https://www.w3.org/TR/shacl/#sparql-prefixes>
> [image: favicon.ico] <https://www.w3.org/TR/shacl/#sparql-prefixes>
> <https://www.w3.org/TR/shacl/#sparql-prefixes>
>
> in your case it would be skos: as subject.
>
> Holger
>
>
> On 28 Feb 2023, at 12:56 pm, Martynas Jusevičius <ma...@atomgraph.com>
> wrote:
>
> Hi,
>
> Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
>
> The following test shape
>
> @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
> @prefix sh: <http://www.w3.org/ns/shacl#> .
>
> <#ConceptBroaderCycleShape>
> a sh:NodeShape ;
> sh:targetClass skos:Concept ;
> sh:sparql [
> a sh:SPARQLConstraint ;
> sh:message "Concept is broader than itself (directly or
> indirectly)" ;
> sh:prefixes skos: ;
> sh:select """
> SELECT *
> {
> $this skos:broader+ $this .
> }
> """ ;
> ] .
>
> returns an error:
>
> org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
> column 23: Unresolved prefixed name: skos:broader
> at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
> at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
> at
> org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
> at
> org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
> at
> org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
> at
> org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
> at
> org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
> at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
> at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
> at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
> at
> org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
> at
> org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
> at shacl.shacl_validate.exec(shacl_validate.java:124)
> at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
> at shacl.shacl_validate.main(shacl_validate.java:60)
> at shacl.shacl.main(shacl.java:81)
>
>
> Martynas
>
>
>
Re: [SHACL] sh:prefixes
Posted by Holger Knublauch <ho...@topquadrant.com>.
I suspect this is another instance of the common misunderstanding: the @prefix declarations are not mapped to any triples and are only a concept of the serialization. To make them visible to SHACL, you need to declare triples such as in
https://www.w3.org/TR/shacl/#sparql-prefixes
in your case it would be skos: as subject.
Holger
> On 28 Feb 2023, at 12:56 pm, Martynas Jusevičius <ma...@atomgraph.com> wrote:
>
> Hi,
>
> Does Jena's SHACL engine support sh:prefixes? Or am I using them wrong?
>
> The following test shape
>
> @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
> @prefix sh: <http://www.w3.org/ns/shacl#> .
>
> <#ConceptBroaderCycleShape>
> a sh:NodeShape ;
> sh:targetClass skos:Concept ;
> sh:sparql [
> a sh:SPARQLConstraint ;
> sh:message "Concept is broader than itself (directly or indirectly)" ;
> sh:prefixes skos: ;
> sh:select """
> SELECT *
> {
> $this skos:broader+ $this .
> }
> """ ;
> ] .
>
> returns an error:
>
> org.apache.jena.shacl.parser.ShaclParseException: Bad query: Line 5,
> column 23: Unresolved prefixed name: skos:broader
> at org.apache.jena.shacl.lib.ShLib.parseQueryString(ShLib.java:262)
> at org.apache.jena.shacl.lib.ShLib.extractSPARQLQuery(ShLib.java:270)
> at org.apache.jena.shacl.engine.SparqlConstraints.parseSparqlConstraint(SparqlConstraints.java:64)
> at org.apache.jena.shacl.parser.Constraints.lambda$static$20(Constraints.java:116)
> at org.apache.jena.shacl.parser.Constraints.parseConstraint(Constraints.java:176)
> at org.apache.jena.shacl.parser.Constraints.parseConstraints(Constraints.java:160)
> at org.apache.jena.shacl.parser.ShapesParser.parseShape$(ShapesParser.java:319)
> at org.apache.jena.shacl.parser.ShapesParser.parseShapeStep(ShapesParser.java:305)
> at org.apache.jena.shacl.parser.ShapesParser.parseShape(ShapesParser.java:236)
> at org.apache.jena.shacl.parser.ShapesParser.parseShapeAcc(ShapesParser.java:221)
> at org.apache.jena.shacl.parser.ShapesParser.parseShapes(ShapesParser.java:163)
> at org.apache.jena.shacl.parser.ShapesParser.parseProcess(ShapesParser.java:100)
> at org.apache.jena.shacl.Shapes.parseProcess(Shapes.java:111)
> at org.apache.jena.shacl.Shapes.parseAll(Shapes.java:106)
> at org.apache.jena.shacl.Shapes.parse(Shapes.java:83)
> at org.apache.jena.shacl.validation.ShaclPlainValidator.parse(ShaclPlainValidator.java:38)
> at org.apache.jena.shacl.validation.ShaclPlainValidator.validate(ShaclPlainValidator.java:90)
> at shacl.shacl_validate.exec(shacl_validate.java:124)
> at org.apache.jena.cmd.CmdMain.mainMethod(CmdMain.java:87)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:56)
> at org.apache.jena.cmd.CmdMain.mainRun(CmdMain.java:43)
> at shacl.shacl_validate.main(shacl_validate.java:60)
> at shacl.shacl.main(shacl.java:81)
>
>
> Martynas