- From: Jakub Moskal <jmoskal@vistology.com>
- Date: Wed, 4 Oct 2017 16:30:24 -0400
- To: public-shacl@w3.org
- Message-ID: <CAOcRyYAJvm2VSWY425sskTHBwnanjG1kbRnt65CTLcQRs90Y5A@mail.gmail.com>
Hi Holger, This is an excellent solution, thank you! I did realize the spec did not specify this as an error. Now with your solution, I can produce warnings to make sure the custom components are properly used - otherwise there is no feedback to the user, as if the data successfully passed the constraint. Thanks! Jakub On Tue, Oct 3, 2017 at 11:40 PM, Holger Knublauch <holger@topquadrant.com> wrote: > Hi Jakub, > > what you describe can be generalized to SHACL shapes graph validation, > i.e. applying SHACL to itself. Constraint component declarations are in > RDF, so we have all data available for what you need. sh:parameter > declarations by default do not test for non-optional values, because the > spec doesn't define this as an error. So that needs to be implemented as an > additional, explicit check. > > I have implemented this as an exercise, using SHACL-SPARQL. The basic > query is > > SELECT $this ?otherPath ?path > WHERE { > { > ?cc a sh:ConstraintComponent . > ?cc sh:parameter ?param . > ?param sh:path ?path . > FILTER NOT EXISTS { ?param sh:optional true } . > FILTER isIRI(?path) . > } > $this ?path ?anyValue . > ?cc sh:parameter ?otherParam . > ?otherParam sh:path ?otherPath . > FILTER (?otherParam != ?param && isIRI(?otherPath)) . > FILTER NOT EXISTS { $this ?otherParam ?anyOther } . > } > > If you include this shape into the data graph (which is your shapes graph) > then it will report the error, e.g. in TopBraid Composer as > > > > (This was a rather quick attempt, I hope there are not too many errors in > the SPARQL query). > > And yes, it may be possible to use something like dash:coExistsWith ( > http://datashapes.org/constraints.html#CoExistsWithConstraintComponent) > but then you'd need to repeat this for every constraint component, while > the solution above applies to all shapes in your graph, and all components. > > HTH > Holger > > > > On 4/10/2017 12:09, Jakub Moskal wrote: > > I defined a SPARQL-based component with two parameters, neither of which > is optional. When I use this component in a shape but provide only one > parameter, the shape is simply ignored by the SHACL API ( > https://github.com/TopQuadrant/shacl). It only works when I provide both > required parameters. > > Is there any mechanism to create a warning when a shape definition > lacks a required parameter? I tried using DASH dash:coExistsWith in a > definition of the component parameters, but it didn't change anything. > > Thanks, > Jakub > > >
Attachments
- image/png attachment: dapnlecaoohobomk.png
Received on Wednesday, 4 October 2017 20:31:28 UTC