- From: Holger Knublauch <holger@topquadrant.com>
- Date: Fri, 21 Nov 2014 18:50:46 +1000
- To: public-data-shapes-wg <public-data-shapes-wg@w3.org>
On 11/21/2014 17:54, Dimitris Kontokostas wrote:
> Hi Holger, I am trying to understand the SPIN discovery mechanism a
> little better, sorry if you already answered this earlier but couldn't
> find the answer.
> I can imagine how it works in simple cases but where would you store
> the following two constraints:
> 1) a Person should never be a Place (owl disjoint classes)
Assuming you want to use the triple
ex:Person owl:disjointWith ex:Place
for that, then this constraint could be attached to owl:Class:
ASK WHERE {
?this owl:disjointWith ?other .
?instance a ?this .
?instance a ?other .
}
Since you are basically defining a meta-language (here:
owl:disjointWith), I guess it makes sense to attach the constraint to
the metaclass too.
Alternatively, you could also attach it to rdfs:Resource.
> 2) whenever a resource has property x or/and property y then it should
> have property z
This depends on how you want to model this. We have a SPIN template in
production that ensures that if an instance has a value for ?property
then it must also have a value for ?otherProperty. This can be attached
to the class where those properties occur, e.g. as
ex:Person
spin:constraint [
a spl:ExistencePropertyPairConstraint ;
arg:property ex:firstName ;
arg:otherProperty ex:lastName
]
and the body of that template is
CONSTRUCT {
_:b0 a spin:ConstraintViolation .
_:b0 spin:violationRoot ?this .
_:b0 spin:violationPath ?property .
_:b0 rdfs:label ?message .
}
WHERE {
FILTER EXISTS {
?this ?otherProperty ?someValue .
} .
FILTER NOT EXISTS {
?this ?property ?object .
} .
BIND (CONCAT("Property must have a value because ", ?otherProperty,
" has") AS ?message) .
}
>
> I assume it should be rdfs:Resource, owl:Thing or rdf:Property, right?
> Is it up to the user to decide this and what happens if he chooses to
> attach it in one of the mentioned class / property?
Yes it's up to the user.
> Does this work for all subclasses of the general classes? i.e. can he
> attach a constraint to owl:ObjectProperty?
Yes.
HTH
Holger
Received on Friday, 21 November 2014 08:53:32 UTC