Property groups and Combinations (was: Shapes vs Classes (in LDOM))

On 1/24/15, 3:53 PM, Jose Emilio Labra Gayo wrote:
> 2.- I noticed that you support "orConstraint" which is a step towards 
> ShEx. I wonder if you support cardinalities over different groups and 
> combinations of "orConstraints". The prototypical example is the 
> Person shape which can have: either a foaf:name or a combination of 
> several foaf:givenNames and one foaf:lastName.

(All untested):

ex:Person
     a rdfs:Class ;
     rdfs:subClassOf rdfs:Resource ;
     ldom:constraint [
         a ldom:OrConstraint ;
         ldom:shape1 [
             ldom:property [
                 ldom:predicate foaf:name ;
                 ldom:minCount 1 ;
                 ldom:maxCount 1 ;
             ]
         ] ;
         ldom:shape2 [
             ldom:property [
                 ldom:predicate foaf:givenName ;
                 ldom:minCount 1 ; # ?
             ] ;
             ldom:property [
                 ldom:predicate foaf:lastName ;
                 ldom:minCount 1 ;
                 ldom:maxCount 1 ;
             ]
         ]
     ] .

(If you need XOr, create a new template similar to ldom:OrConstraint).

Or in SPARQL:

ex:Person
     rdfs:subClassOf rdfs:Resource ;
     ldom:constraint [
         ldom:message """A person must either have a name or a
                 combination of given and last names""" ;
         ldom:sparql """
                 ASK {
                     FILTER !(ldom:valueCount(?this, foaf:name) = 1 ||
                          (ldom:valueCount(?this, foaf:givenName) > 0 &&
                          ldom:valueCount(?this, foaf:lastName) = 1))
                 }
             """
     ] .

Does this cover your scenario?

Holger

Received on Saturday, 24 January 2015 09:04:37 UTC