W3C home > Mailing lists > Public > public-data-shapes-wg@w3.org > January 2015

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

From: Holger Knublauch <holger@topquadrant.com>
Date: Sat, 24 Jan 2015 19:04:05 +1000
Message-ID: <54C36005.7080802@topquadrant.com>
To: RDF Data Shapes Working Group <public-data-shapes-wg@w3.org>
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

This archive was generated by hypermail 2.3.1 : Saturday, 24 January 2015 09:04:38 UTC