- From: Irene Polikoff <irene@topquadrant.com>
- Date: Tue, 19 Mar 2019 20:52:20 -0400
- To: Gary Murphy <gary@schemaapp.com>
- Cc: public-shacl@w3.org
- Message-Id: <8DEDBE00-4DCB-4D7A-9018-373AFFB7C46A@topquadrant.com>
A PropertyShape must have sh:path - see https://www.w3.org/TR/shacl/#property-shapes <https://www.w3.org/TR/shacl/#property-shapes> If there is no {myshape:DateShape sh:path ?something} triple, you have an invalid shapes graph. You could create a node shape defining conditions on the value. Then, use it like this: myshape:PersonShape a sh:NodeShape ; sh:property [ sh:path ex:birthDate ; sh:node myshape:DateShape; sh:lessThan ex:deathDate ; sh:message "Birth date must be before death date unless time travel is possible” .} In this example, myshape:DateShape is a node shape. For example: myshape:DateShape a sh:NodeShape ; sh:datatype xsd:string ; sh:pattern "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[0-9.+-Z]*$”. You can also use sh:or in the node shape, but your syntax is incorrect. It would be something like myshape:DateShape a sh:NodeShape ; sh:or ( [ sh:datatype xsd:dateTime; ] [ sh:datatype xsd:string ; sh:pattern "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[0-9.+-Z]*$”; ] ) . Although, I think your sh:pattern value may have some syntax issues as well. > On Mar 19, 2019, at 2:17 PM, Gary Murphy <gary@schemaapp.com> wrote: > > Seeking some guidance with a frequent pattern: I have several properties which are all constrained to xsd:dateTime or xsd:string with a regex for ISO dates, but each of these properties also has other constraints such as maxCount = 1 > > So for a familiar example, in Person, for birthDate, I have these alternatives in sh:or clauses, plus I have the maxCount and the sh:lessThan deathDate rules, but when the data value is the wrong type, the violation takes the sh:message for the entire test, reporting only that the sh:OrConstraintComponent was violated and then a second violation for sh:LessThanConstraintComponent. > > I can of course split these into successive sh:property rules for the same sh:path and each with it's own sh:message, but the same datatype constraints apply also to deathDate and every other date value in my graph. I'd far prefer to define the rules for all date-like paths in one place. > > Is it possible to define a generic "value shape" where the rules are applied to the current path rather than to a path defined in the shape itself? > > something like > > myshape:DateShape a sh:PropertyShape ; > [ sh:datatype xsd:dateTime ] > [ sh:datatype xsd:date ] > [ sh:datatype xsd:string ; > sh:pattern > "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[0-9.+-Z]*$" ; > ] > ) ; > sh:name "dateTime" ; > gist:start "2017-12-18T17:00:00Z"^^xsd:dateTime ; > sh:message "Date must be xsd:date xsd:dateTime or string in ISO format, eg 2018-12-18T12:00:00.000+0500" . > > myshape:PersonShape a sh:NodeShape ; > sh:property [ > sh:path ex:birthDate ; > sh:??? myshape:DateShape ; # can this be done? > sh:lessThan ex:deathDate ; > sh:message "Birth date must be before death date unless time travel is possible" . > > Is there any mechanism in shacl to apply a path-agnostic shape? > -- > Gary Lawrence Murphy <gary@schemaapp.com> - Hunch Manifest, 15 Wyndham N 'C', Guelph
Received on Wednesday, 20 March 2019 00:52:00 UTC