#494 Add @include and @except to classRef

Lou Burnard

At present if you want to remove from your customisation some of the attributes supplied by a given class you must do it explicitly for each attribute with an <attDef mode="delete">. It would be much simpler to allow for @include or @except on <classRef> : this would be also be clearer and more consistent with how <moduleRef> works. Similarly, to say you dont want all the members of a given model class to feature in a customisation you must delete the elements you don't want one by one (which, if they appear in content models independently of their membership of a class, may not be what you wanted), so I think there is no reason to restrict this enhancement to attribute classes only.


  • this is partially implemented now. ie it works for model classes. Extension to attributes needs more thought, as the innards there dont work in the same way at all

  • James Cummings
    James Cummings

    In updating an ODD today I found exactly the desire to want to use @include on classRef for attributes. So while I don't think it is our highest priority it would seem good parallelism to be able to use on classRef this way.

  • can you give a worked example, please, James? I am little surprised at you saying you want it, as <classRef> only makes any sense in the context of New ODD, and I didn't realize anyone was using this.

  • James Cummings
    James Cummings

    I don't think you need to be using newODD to want this!

    So today I wanted to remove all members of att.global.linking except for @corresp. So I had to do, standard old ODD of:

    <classSpec ident="att.global.linking" mode="change" module="tei" type="atts">
            <attDef ident="synch" mode="delete"/>
            <attDef ident="sameAs" mode="delete"/>
            <attDef ident="copyOf" mode="delete"/>
            <attDef ident="next" mode="delete"/>
            <attDef ident="prev" mode="delete"/>
            <attDef ident="exclude" mode="delete"/>
            <attDef ident="select" mode="delete"/>

    But if instead I could do:

    <classRef ident="att.global.linking" module="tei" type="atts" include="corresp"/>

    Along a similar model of how I already use moduleRef then that would be lots easier... no?


  • I think you misunderstand what <classRef> means. It says "I want to import this <classSpec> from the TEI". You want to combine this functionality with that of <classSpec>, which
    alters the imported element. The <moduleRef> beast is different, I think, because the <moduleSpec> back at base doesn't actually do anything, so can't be changed.

    Also,unless you totally rewrite your ODD to omit the <moduleRef key="linking">, that <classRef> has no effect anyway, as you get the att.global regardless.

    I see that you just want @corresp to come over, but I dont think the syntax you propose makes sense.

    Last edit: Martin Holmes 2014-02-13
  • Lou Burnard
    Lou Burnard

    I think I share James's "misunderstanding", then, though perhaps "feature request" would be a more reasonable name for it, At present, <classRef> is short hand for "all the members of a class" or "all the attributes supplied by a class". The proposal is to permit inclusion/exclusion of specified members. It is exactly analogous to <moduleRef which means "all the objects declared by this module" but which can be tweaked to mean "all bar some" or "only these". In neither case is anything actually being modified: it's just a subsetting operation. When you include the linking module, via a moduleRef, you get the full version of the att.global.linking class. Adding a classRef to the same class, to say you actually only want @corresp, seems a perfectly comprehensible short cut, which ought to have the same effect as deleting the unwanted attributes, Why do you think the syntax makes no sense? what else could it possibly mean?

  • its just not true to say
    <q>At present, <classRef> is short hand for "all the members of a class" or "all the attributes supplied by a class".</q>
    a classRef "points to the specification for an attribute or model class which is to be included in a schema". The use of it in PureODD at the top level is confusing matters considerably, IMHO.

    however, I concede that <classRef key="att.global" exclude="xml:lang"> may well make some sense. Why do I think you'll immediately follow it with <classSpec ident="att.global" mode="change">? bitter experience, I guess. But <classRef key="model.global" exclude="note"> does NOT make sense, because model classes and attribute classes are not the same beast at all.

  • sorry, I mean to say "The use of it in PureODD in the content model is confusing matters considerably, IMHO."

  • James Cummings
    James Cummings

    What if there was a schematron rule for ODD saying you couldn't have a both a classRef/@key='X' and a classSpec/@ident='X'. (i.e. you can use one or the other not both). And yes, I was only thinking of attribute classes. It almost makes you wish we had an attClassRef and modelClassRef for different purposes. I agree they work in fundamentally different ways.

    I wasn't envisioning using classRef in content models at all, simply modifying the class as a whole before any memberships are applied. I can see how using classRef/@key='model.X' in content models with @include or @exclude could be a powerful mechanism to easily remove things from a content model. I recognise that 'here be dragons' sign you are waving.


  • the use of classRef in a stage before classSpec/@mode='change' is not a silly idea, it could work. It just doesnt at the moment, because both are read in the same stage.

    the use of classRef with include/exclude inside content model should be fine, the dragons are not too bothered by that. I am sure there are edge cases which won't work, but the underlying mechanism is quite simple. See Stylesheets/Test/test30.odd for an example of usage.

  • I am closing this ticket now, as I believe that everything which should work does work. you can now use both classRef and classSpec in the same ODD and get the order of results you need.

    • status: open --> closed-fixed