[SPIN] Overriding spl:Arguments in subclasses

14 views
Skip to first unread message

Martynas Jusevicius

unread,
Aug 28, 2016, 12:06:11 PM8/28/16
to TopBraid Suite Users
Hey,

I have a somewhat artificial use case where both a class and its superclass each have an spl:Argument with the same predicate, but different spl:defaultValue, and possibly other properties:

    :Template a spin:Template ;
        spin:constraint [ a spl:Argument ;
            spl:predicate :property ;
            spl:valueType xsd:long ;
            spl:defaultValue 111
        ] .

    :SubTemplate a spin:Template ;
        rdfs:subClassOf :Template ;
        spin:constraint [ a spl:Argument ;
            spl:predicate :property ;
            spl:valueType xsd:long ;
            spl:defaultValue 999
        # spl:optional true
        ] .

When [ a :SubTemplate ] is instantiated, what will be its :property value (assuming it comes from spl:defaultValue)?

I would think the subclass argument has precedence, but looking at the ModuleImpl code, it seems that a List<Argument> is collected from the class and all its superclasses, ignoring inheritance:
https://github.com/TopQuadrant/shacl/blob/master/src/main/java/org/topbraid/spin/model/impl/ModuleImpl.java

But maybe the inheritance/precedence is handled somewhere else?

Also, would it be illegal for the subclass to define the argument as spl:optional if the superclass does not do so? Wouldn't that break the template contract? I guess the same applies to redefinition of spl:valueType etc.

Thanks,


Martynas
atomgraph.com

Holger Knublauch

unread,
Aug 28, 2016, 8:51:42 PM8/28/16
to topbrai...@googlegroups.com
Hi Martynas,

as you have found out, this scenario is not supported by SPIN. Multiple declarations of the same predicate lead to undefined behavior. I am not particularly keen to touch this area of code, because it is so widely used and I don't want to risk regression bugs or performance degradation at this stage. Given that this doesn't appear to be a common scenario, your work-around is to not declare the argument twice, for example by having an abstract superclass for both templates, where only the subclasses declare :property.

Holger
--
You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include the TopBraid Suite family of products and its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbrai...@googlegroups.com
---
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 topbraid-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martynas Jusevicius

unread,
Aug 29, 2016, 5:06:16 AM8/29/16
to TopBraid Suite Users
Thanks Holger.

I think a solution could be to have 2 sets of arguments: template-local (by default), and inheritable (defined so explicitly), or "tunneled". Subclasses would not see the local arguments of superclasses, and it would be an error to redefine tunneled arguments with a different contract.

This is the idea behind tunnel parameters in XSLT 2.0: https://www.w3.org/TR/xslt20/#tunnel-params
Reply all
Reply to author
Forward
0 new messages