To those interested in SPIN (in general), I have just pushed a new
release [1] of the SPIN API that implements a useful tweak for SPIN
templates. I will explain the new feature below. Note that this release
also covers a couple of fixes related to the handling of sp:text
queries, so I would recommend anyone working in that mode to upgrade
(and let me know if there are more issues).
The new feature of SPIN is that when a SPIN template has superclasses
and those superclasses also have spin:bodies, then those body queries
will also be executed whenever the upper SPIN template is called. An
example of this is the OSLC Resource Shapes implementation [2], which
has a class structure which looks as following:
As shown in the diagram, there is a template oslc:Property that is the
"union" of several other constraint templates (including for allowed
values and cardinality). In the old days, it was only possible to use
the latter constraint individually, leading to a syntax such as:
oslc_cm:ChangeRequest
# Constraints on dcterms:title
spin:constraint [
a oslc:Property ;
oslc:propertyDefinition dcterms:title ;
oslc:name "title"^^xsd:string
] ;
spin:constraint [
a oslc:OccursConstraint ;
oslc:propertyDefinition dcterms:title ;
oslc:occurs oslc:Exactly-one
] ;
# Constraints on oslc_cm:status
spin:constraint [
a oslc:Property ;
oslc:name "status"^^xsd:string ;
oslc:propertyDefinition oslc_cm:status
] ;
spin:constraint [
a oslc:OccursConstraint ;
oslc:propertyDefinition oslc_cm:status ;
oslc:occurs oslc:Zero-or-one
] ;
spin:constraint [
a oslc:AllowedValuesConstraint ;
oslc:propertyDefinition oslc_cm:status ;
oslc:allowedValues oslc_cm:status-allowed-values
] .
With the new extension, people can instantiate the shared subclass
oslc:Property, which combines all individual constraint types into a
single node:
oslc_cm:ChangeRequest
spin:constraint [
a oslc:Property ;
oslc:name "title"^^xsd:string ;
oslc:occurs oslc:Exactly-one ;
oslc:propertyDefinition dcterms:title
] ;
spin:constraint [
a oslc:Property ;
oslc:allowedValues oslc_cm:status-allowed-values ;
oslc:name "status"^^xsd:string ;
oslc:occurs oslc:Zero-or-one ;
oslc:propertyDefinition oslc_cm:status
] .
The above is a much more compact notation, and furthermore makes it
possible to share argument values (e.g. all definitions for
oslc_cm:status are under a single blank node versus 3 nodes in the
former syntax).
The semantic impact of this syntactic change is that I had to adjust
constraint checking (the definition of spl:Argument) because at "union"
nodes, not all argument are required. I have introduced a new template
type spl:UnionTemplate that acts as a marker to tell the constraint
checker that the superclass arguments may be optional. See the OSLC file
for an example:
oslc:Property
rdf:type spl:ConstraintTemplate ;
rdf:type spl:UnionTemplate ;
This tells the engine that all inherited arguments are optional.
Templates that do not have all required arguments filled in are not
executed, and this should always have been the case. This makes it
possible to ignore those superclass templates that are not completely
filled in.
I don't think any existing SPIN models are affected by those changes,
because the inheritance of spin:bodies between templates was previously
undefined, so I doubt that people have relied on them being *not*
evaluated. In a sense it is even more correct that if a template defines
a constraint, then all "inherited" constraints should also be executed.
Pending some additional testing, I believe this change will also make it
into the final release of TopBraid 4.5.
Thanks
Holger
[1]
http://www.topquadrant.com/repository/spin/org/topbraid/spin/1.4.0-SNAPSHOT/
[2] http://knublauch.com/oslc/oslc.spin.ttl
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary
Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL
Web Pages 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
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.