TEIC / Stylesheets

TEI XSL Stylesheets
228 stars 124 forks source link

Applying `@mode='change|replace'` to members of `att.canonical` produces attribute duplicates #600

Closed Bpolitycki closed 1 year ago

Bpolitycki commented 1 year ago

I am trying to change attributes which are members of att.canonical in an elementSpec. So my spec looks like:

<elementSpec xmlns="http://www.tei-c.org/ns/1.0" ident="orgName" module="namesdates" mode="change">
     <classes mode="replace">
        <memberOf key="model.nameLike.agent"/>
        <memberOf key="att.canonical"/>
        <memberOf key="att.naming"/>
    </classes>
   <!-- ... --->
    <attList>
            <attDef ident="ref" mode="change">
                <datatype>
                    <dataRef restriction="test" name="string"/>
                </datatype>
            </attDef>
            <attDef ident="key" mode="change">
                <datatype>
                    <dataRef restriction="test" name="string"/>
                </datatype>
            </attDef>
       </attList>
</elementSpec>

Which produces the following RelaxNG-Output:

<define name="orgName">
      <element name="orgName">
        <!--- ... -->
         <ref name="att.naming.attribute.role"/>
         <optional>
            <attribute name="key">
               <data type="string">
                  <param name="pattern">test</param>
               </data>
            </attribute>
         </optional>
         <optional>
            <attribute name="ref">
              <data type="string">
                  <param name="pattern">test</param>
               </data>
            </attribute>
         </optional>
         <optional>
            <attribute name="key">
               <data type="string">
                  <param name="pattern">test</param>
               </data>
            </attribute>
         </optional>
         <optional>
            <attribute name="ref">
               <data type="string">
                  <param name="pattern">test</param>
               </data>
            </attribute>
         </optional>
         <empty/>
      </element>
   </define>

I would expect, that the attributes don't get duplicated (as all the other attributes changed the same way).

I've used the TEI-Stylesheets Branch release-7.54.0.

ebeshero commented 1 year ago

Hi @Bpolitycki I'm thinking the issue might be the combination of mode="replace" on the classes spec with mode="change" on the <attDef> elements. Replace mode I think suggests you're intending to fully redefine the classes--and I am thinking that is probably more than you need here? If you're going to change the rules for particular attributes in the class, the mode="change" is probably sufficient.

Bpolitycki commented 1 year ago

Thanks @ebeshero for your quick reply. Just some additional thoughts on this:

<elementSpec xmlns="http://www.tei-c.org/ns/1.0" ident="width" module="msdescription" mode="change">
    <!--- ... --->
        <memberOf key="model.dimLike"/>
        <memberOf key="model.measureLike"/>
        <memberOf key="att.dimensions"/>
    </classes>
    <content>
        <empty/>
    </content>
    <attList>
        <attDef ident="unit" mode="change" usage="req">
            <datatype>
                <dataRef name="string"  restriction="test-width"/>
            </datatype>
        </attDef>
        <attDef ident="quantity" mode="change" usage="req"/>
    </attList>
</elementSpec>

For me this problem seems to be somewhat specific to att.canonical and it does not seem possible to make any changes. Any ideas?

sydb commented 1 year ago

I may not have time to dive into this deeply right now, but at first blush this certainly smells somewhat similar to at least TEIC/Stylesheets#237, TEIC/Stylesheets#370, TEIC/Stylesheets#371, and TEIC/Stylesheets#376. There is something screwy going on with definitions of attributes from classes & locally.

sydb commented 1 year ago

Ack! Sorry. False alarm. It is not possible to use both att.naming and att.canonical, because att.naming already includes att.canonical.

Thus just removing the <memeberOf key="att.canonical"/> solves the problem.

Bpolitycki commented 1 year ago

Ack! Sorry. False alarm. It is not possible to use both att.naming and att.canonical, because att.naming already includes att.canonical.

Oh man! Thanks a lot!

Wer lesen kann, ist klar im Vorteil ... ;)