|
Rodolfo; There may be a couple of SPIN principles
that may be helpful to you. The first is that constraints,
constructors and rules are defined for a class and applied to its
members. The second is that ?this should be used to state that
the query is applied to individual members. I.e. in the following
query: 1) is defined as a spin:constraint property for bad:Device 2) the triple pattern <?dev rdf:type bad:Device> is not necessary because ?this is pre-bound to each member of bad:Device CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?this . _:b0 spin:violationPath bad:deviceIngressProtection . _:b0 rdfs:label "the value should be between 20 and 30" . } WHERE { ?this bad:deviceIngressProtection ?value . FILTER ((?value < 20) || (?value > 30)) . } In this case, I'm using Composer's constraint violation infrastructure to show this, so I'm creating a ConstraintViolation instance and hanging it on the bad:deviceIngressProtection property. I'm attaching a model that demonstrates this. You can try it out in TBC Free/SE/ME. -- Scott On 10/7/10 1:29 AM, dennis wrote: --Hi Rodolfo, could it be that ?value refers to a plain literal? I've realized that arithmetic operations don't work if the literals are not explicitly typed e.g. as xsd:integer or xsd:double, and maybe this holds for < and > comparisons as well...Cheers, Dennis On 7 Okt., 03:37, Holger Knublauch <[email protected]> wrote:Hi Rudolfo, I am not sure where the problem is in your example. I think I need more information - feel free to send me your specific example (off-list). I notice that you are creating the CONSTRUCT query but it is unclear whether this constraint is also attached to the model somehow. Holger On Oct 7, 2010, at 5:00 AM, Rodolfo Rieckhof wrote:Hello Holger, thanks for your quick response. I have downloaded the new API and it works just fine. But i have another question. How can i insert a SPIN constraint dynamically in my ontology ? I have tried the following: I create a constraint, just like in the examples with: You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include TopBraid Composer, TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/topbraid-users?hl=en |
# Saved by TopBraid on Thu Oct 07 09:41:50 CDT 2010 # baseURI: http://support.tq.com/RodolfoCVW # imports: http://spinrdf.org/spin @prefix bad: <http://support.tq.com/RodolfoCVW#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix sp: <http://spinrdf.org/sp#> . @prefix spin: <http://spinrdf.org/spin#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://support.tq.com/RodolfoCVW> rdf:type owl:Ontology ; owl:imports <http://spinrdf.org/spin> ; owl:versionInfo "Created with TopBraid Composer"^^xsd:string . bad:Device rdf:type owl:Class ; rdfs:subClassOf owl:Thing ; spin:constraint [ rdf:type sp:Construct ; sp:templates ([ sp:object spin:ConstraintViolation ; sp:predicate rdf:type ; sp:subject _:b1 ] [ sp:object spin:_this ; sp:predicate spin:violationRoot ; sp:subject _:b1 ] [ sp:object bad:deviceIngressProtection ; sp:predicate spin:violationPath ; sp:subject _:b1 ] [ sp:object "the value should be between 20 and 30" ; sp:predicate rdfs:label ; sp:subject _:b1 ]) ; sp:where ([ sp:object _:b2 ; sp:predicate bad:deviceIngressProtection ; sp:subject spin:_this ] [ rdf:type sp:Filter ; sp:expression [ rdf:type sp:or ; sp:arg1 [ rdf:type sp:lt ; sp:arg1 _:b2 ; sp:arg2 20 ] ; sp:arg2 [ rdf:type sp:gt ; sp:arg1 _:b2 ; sp:arg2 30 ] ] ]) ] . bad:Device_1 rdf:type bad:Device ; bad:deviceIngressProtection 55 . bad:Device_2 rdf:type bad:Device ; bad:deviceIngressProtection 25 . bad:deviceIngressProtection rdf:type owl:DatatypeProperty ; rdfs:range xsd:integer . _:b2 sp:varName "value"^^xsd:string .
