Interaction between minCount and hasValue

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

Received on Thursday, 5 November 2015 05:48:17 UTC