- From: Holger Knublauch <holger@topquadrant.com>
- Date: Wed, 4 Oct 2017 13:40:49 +1000
- To: public-shacl@w3.org
- Message-ID: <3e903343-c887-9eaf-88cc-b0e7a5ddee4c@topquadrant.com>
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) > <https://github.com/TopQuadrant/shacl%29>. 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
- text/plain attachment: cc.shapes.ttl
Received on Wednesday, 4 October 2017 03:41:15 UTC