- From: Holger Knublauch <holger@topquadrant.com>
- Date: Tue, 14 Jun 2016 10:18:22 +1000
- To: public-data-shapes-wg@w3.org
- Message-ID: <68867251-d96f-598a-8a9c-07b551de8b34@topquadrant.com>
Hi Dimitris,
the body of this new constraint component would be something like
SELECT $this
WHERE {
?instance rdf:type/rdfs:subClassOf* $this .
} HAVING (COUNT(?instance) > $maxInstanceCount)
The scope is generally binding the values of $this. So in order to make
this work, most people would use sh:scopeNode to link to a class
directly. Use cases for sh:scopeClass would be in the realm of
metaclasses, or custom scopes such as "for all classes that have a given
property" (sh:scopeProperty). (I hope this addresses your other
questions below).
BTW if we merge Shape and NodeConstraint, as suggested, the syntax would
look better:
ex:MyShape
a sh:Shape ;
sh:scopeNode schema:FlightReservation ;
sh:maxInstanceCount 1 ;
sh:minInstanceCount 1 .
The general problem with scope-based constraints is that scopes are only
one way to trigger validation. Other cases include nested shapes
(sh:shape, sh:or etc) and (as in ShEx) to have some dedicated root shape
or (as in Arthur's use cases, if I may speak on his behalf) control the
validation process completely outside of the model, from some
application-specific algorithm. So anything that behaves differently
depending on whether it has a scope or not is bound to fail.
Holger
On 14/06/2016 3:33, Dimitris Kontokostas wrote:
> Hi Holger,
>
> I think there is a typo in your example, it should be sh:scopeClass.
>
> For me it is fine to have this as syntactic sugar for Karen's use case
> but we need to be more precise on how this will work with scoping in
> general.
> Does this constraint apply on the union of all defined scopes or per
> defined scope ?
>
> e.g. consider this example
> ex:MyPersonShape
> a sh:Shape ;
> sh:scopeClass ex:Doctor, ex:Patience ;
> sh:scopeNode ex:DrWho, ex:Bob
> sh:scopeProperty ex:operated
> sh:scopeInverseProperty ex:operated
> sh:constraint [
> sh:minInstanceCount 1 ;
> sh:maxInstanceCount 1 ;
> ] .
>
> do we require 1 doctor, 1 Patience, 1 ...
> or only 1 of all together?
>
> Also, what would be the definition when this constraint is referenced
> from e.g. sh:shape?
> ex:MyHospitalShape
> a sh:Shape
> sh:scopeClass ex:Hospital
> sh:property [
> sh:predicate ex:personStayed
> sh:shape ex:MyPersonShape
> ]
>
> does the constraint apply an all hospitals with a property
> ex:personStayed ( ex:Hospital[ex:stayed]) ?
>
> Best
> Dimitris
>
> On Mon, Jun 13, 2016 at 3:04 PM, RDF Data Shapes Working Group Issue
> Tracker <sysbot+tracker@w3.org <mailto:sysbot+tracker@w3.org>> wrote:
>
> shapes-ISSUE-168 (instance count): How to constrain number of
> instances of a class in a graph [SHACL - Core]
>
> http://www.w3.org/2014/data-shapes/track/issues/168
>
> Raised by: Holger Knublauch
> On product: SHACL - Core
>
> There was recent discussion about how to specify min/max numbers
> of instances in a graph. Off-list I had also received a question
> from schema.org <http://schema.org> people about how to state that
> a graph/message must have exactly one instance of
> schema:FlightReservation, possibly to ensure that a graph has a
> starting point/root for validation.
>
> A possible syntax that would easily work with the current
> architecture could be
>
> ex:MyShape
> a sh:Shape ;
> sh:scopeNode schema:FlightReservation ;
> sh:constraint [
> sh:minInstanceCount 1 ;
> sh:maxInstanceCount 1 ;
> ] .
>
>
>
>
>
>
> --
> Dimitris Kontokostas
> Department of Computer Science, University of Leipzig & DBpedia
> Association
> Projects: http://dbpedia.org, http://rdfunit.aksw.org,
> http://aligned-project.eu
> Homepage: http://aksw.org/DimitrisKontokostas
> Research Group: AKSW/KILT http://aksw.org/Groups/KILT
>
Received on Tuesday, 14 June 2016 00:19:00 UTC