- From: Jose Emilio Labra Gayo <jelabra@gmail.com>
- Date: Thu, 5 Nov 2015 09:45:46 +0100
- To: Holger Knublauch <holger@topquadrant.com>
- Cc: RDF Data Shapes Working Group <public-data-shapes-wg@w3.org>
- Message-ID: <CAJadXXLsVOxZ+=zJUamYczDzvWE0JZ6+iw2SY8QAZ-8PuOffDA@mail.gmail.com>
Thanks, however, although the previous example can be defined using
filterShape, the question remains about what is the expected behaviour of a
SHACL processor that encounters "sh:minCount 0" and "sh:hasValue" at the
same time.
For example, if we have:
:UserShape
a sh:Shape ;
sh:property [
sh:predicate :role ;
sh:hasValue :User ;
sh:minCount 0 ;
sh:maxCount 1 ;
] .
:u1 sh:nodeShape :UserShape ; :role :User .
:u2 sh:nodeShape :UserShape.
What should a SHACL processor do?
1.- Validate the graph because both :u1 and :u2 satisfy the :UserShape
constraints
2.- Complain that :u2 doesn't satisfy the sh:hasValue constraint
3.- Raise an error because the :UserShape is not well formed
Best regards, Jose Labra
On Thu, Nov 5, 2015 at 6:55 AM, Holger Knublauch <holger@topquadrant.com>
wrote:
> Hi Jose,
>
> I think you can use a sh:filterShape to limit when your constraint applies.
>
> Untested:
>
> :UserShape
> a sh:Shape ;
> sh:property [
> sh:predicate :role ;
> sh:hasValue :User ;
> sh:filterShape [
> sh:property [
> sh:predicate :role ;
> sh:minCount 1 ;
> ] ;
> ]
> ] .
>
> The intention of the above is to say that the hasValue constraint only
> applies to instances where :role has at least one value.
>
> Holger
>
>
>
> On 11/5/2015 15:47, Jose Emilio Labra Gayo wrote:
>
> I would like to model optional properties which can appear or not, but in
> case that they appear have a fixed value.
>
> For example, in ShEx, I can define the following shape:
>
> <UserShape> {
> rdfs:label xsd:string,
> ex:role ex:User ?
> }
>
> where ex:role is an optional property with a fixed value. If it appears,
> it must be ex:User.
>
> My first thought is that the previous example could be represented in
> Shacl as:
>
> :UserShape
> a sh:Shape ;
> sh:property [
> sh:predicate rdfs:label ;
> sh:datatype xsd:string ;
> sh:minCount 1 ;
> sh:maxCount 1 ;
> ] ;
> sh:property [
> sh:predicate :role ;
> sh:hasValue :User ;
> sh:minCount 0 ;
> sh:maxCount 1 ;
> ] .
>
> However,reading the spec, I am not sure about the interaction between
> sh:minCount and sh:hasValue.
>
> It appears that if we include sh:minCount 0, the spec says: "If the value
> is 0 then this constraint is always satisfied and so may be omitted."
>
> However, the definition of sh:hasValue says: "A validation result must be
> produced if there is no triple that has the focus node as its subject,
> the sh:predicate as its predicate and the sh:hasValue as its object." and
> the SPARQL query seems to raise an error in that case, which means that the
> following instance data woud not be valid:
>
> :user1 rdfs:label "Student 2" .
>
> Is is possible to combine optional properties with fixed values as in the
> previous example or is there another way to define it?
>
> --
> -- Jose Labra
>
>
>
--
-- Jose Labra
Received on Thursday, 5 November 2015 08:46:34 UTC