Great. And even a general, non platform-specific message like "Cardinality or type constraint violation" would be helpful. Thanks,
Jeff Work: 314-232-1997 Cell: 636-448-5990 ________________________________ From: Holger Knublauch [mailto:[email protected]] Sent: Thursday, December 03, 2009 1:50 PM To: [email protected] Subject: Re: [tbc-users] [SPIN API] Access SPIN cardinality contraint violation messages Yes this will go into the next release. It's harder to also construct meaningful error messages as triples if you mean that, because this would require string functions that are not native to SPARQL (but for example smf functions). The SPIN standard library SPL is only for functions and templates that do not have any other platform-specific dependencies. Holger On Dec 3, 2009, at 11:09 AM, Schmitz, Jeffrey A wrote: Works great! both in TBC and the SPIN API. I was even able to add a message: _:b0 rdfs:label "Cardinality or type constraint" . Not sure why I couldn't get the UNION's to work in the SPARQL tab, or the ||'s to work in the spin:body, but not too worried at this point. Do you think you will make this change or something like it in future SPIN versions? Would be nice to be able to easily retrieve the cardinality constraint predicate along with a built in message when using the spl:Attribute template :-) Jeff Work: 314-232-1997 Cell: 636-448-5990 ________________________________ From: Holger Knublauch [mailto:[email protected]] Sent: Thursday, December 03, 2009 11:55 AM To: [email protected]<mailto:[email protected]> Subject: Re: [tbc-users] [SPIN API] Access SPIN cardinality contraint violation messages Hi Jeff, I think switching to CONSTRUCT will work fine, and I tried the following CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?this . _:b0 spin:violationPath ?predicate . } WHERE { { FILTER (bound(?minCount) && (spl:objectCount(?this, ?predicate) < ?minCount)) . } UNION { FILTER (bound(?maxCount) && (spl:objectCount(?this, ?predicate) > ?maxCount)) . } UNION { FILTER bound(?valueType) . ?this ?predicate ?value . FILTER (!spl:instanceOf(?value, ?valueType)) . } . } which in TBC works fine for me. On Dec 3, 2009, at 9:40 AM, Schmitz, Jeffrey A wrote: I tried replacing the current spin:body in spl:Attribute with: # Type or Cardinality Constraint CONSTRUCT { _:b0 a spin:Constraint ; spin:violationRoot ?this ; spin:violationPath ?predicate ; } WHERE { ?this ?predicate ?value FILTER (bound(?maxCount) && (spl:objectCount(?this, ?predicate) > ?maxCount) || (bound(?minCount) && (spl:objectCount(?this, ?predicate) < ?minCount)) || (bound(?valueType) && (!spl:instanceOf(?value, ?valueType)))) } limit 1 The line ?this ?predicate ?value is unnecessary and harmful because it would mean that at least one value must exist. But TBC doesn't catch the constraint error after the change, so I'm assuming the spin code (SPINConstraints.check) won't catch it either. A couple of points about the above query: 1. For some reason the UNIONs around the FILTERs wouldn't work for me when I was testing the query, so I had to change it to one big FILTER using ||'s. I don't see why. Works for me as above (and attached). 2. When testing in the SPARQL tab, I pre-filled the variables using LET statements at the start of the WHERE clause, and this did work in that it correclty detected constraint errors in the resource, e.g. # Type or Cardinality Constraint CONSTRUCT { _:b0 a spin:Constraint ; spin:violationRoot ?this ; spin:violationPath ?predicate ; } WHERE { LET (?minCount := 1) LET (?maxCount := 1) LET (?predicate := Neutral:hasActionOutcomeValue) LET (?valueType := Neutral:ActionOutcomeValue) ?this ?predicate ?value FILTER (bound(?maxCount) && (spl:objectCount(?this, ?predicate) > ?maxCount) || (bound(?minCount) && (spl:objectCount(?this, ?predicate) < ?minCount)) || (bound(?valueType) && (!spl:instanceOf(?value, ?valueType)))) } limit 1 Anyway, not that this is a long term solution (can't change the SPIN models), but perhaps it's a step towards a solution if I can get this working. I hate to not be able to use the spl:Attribute template because I currently use it extensively in my models. I will put the construct into the next release of SPL, unless you discover problems. Thanks Holger -- You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group. To post to this group, send email to [email protected]<mailto:[email protected]>. To unsubscribe from this group, send email to [email protected]<mailto:[email protected]>. For more options, visit this group at http://groups.google.com/group/topbraid-composer-users?hl=en. -- You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group. To post to this group, send email to [email protected]<mailto:[email protected]>. To unsubscribe from this group, send email to [email protected]<mailto:[email protected]>. For more options, visit this group at http://groups.google.com/group/topbraid-composer-users?hl=en. -- You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group. 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-composer-users?hl=en. -- You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group. 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-composer-users?hl=en.
