TEIC / TEI

The Text Encoding Initiative Guidelines
https://www.tei-c.org
Other
282 stars 84 forks source link

Define useful constants for classSpecs, e.g. $MEMBERS #1417

Open raffazizzi opened 8 years ago

raffazizzi commented 8 years ago

It would be useful to have some constants that available for use in XPaths within a classSpec. For example "MEMBERS" to get the names of all members of a <classSpec type="atts">.

Example

Create an attribute class that sets schematron rules for the value of @rend. This is were being able to refer the members of the class would be useful! Let's imagine it's called $MEMBERS.

<classSpec ident="att.specialrend" type="atts">
   <constraintSpec ident="rends" scheme="isoschematron">
      <constraint xmlns:sch="http://purl.oclc.org/dsdl/schematron">
         <sch:rule context="*[@rend][local-name()=$MEMBERS]">
            <sch:assert
               test="contains(@rend,'fontType()') and contains(@rend,'color()')">
               Provide font type and color. </sch:assert>
         </sch:rule>
      </constraint>
   </constraintSpec>
</classSpec>

This makes sure that the schematron rule only applies to the members of the class. So if I replaced @rend on a non-member element, the schematron would not apply.

Implementing something like this requires a decision on whether ODD should define constants, which ones, and where they would be documents (possibly in the definition of classSpec). The heavy-lifting however, would happen in the XSLT that processes the ODD.


Below is a full ODD for a working example. The hypothetical constant "MEMBERS" is expanded to ('p','ab').

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_odds.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_odds.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
   <teiHeader>
      <fileDesc>
         <titleStmt>
            <title>Title</title>
         </titleStmt>
         <publicationStmt>
            <p>Publication Information</p>
         </publicationStmt>
         <sourceDesc>
            <p>Information about the source</p>
         </sourceDesc>
      </fileDesc>
   </teiHeader>
   <text>
      <body>
         <div>
            <schemaSpec ident="rend_odd" start="TEI">

               <moduleRef key="tei"/>
               <moduleRef key="header"/>
               <moduleRef key="core"/>
               <moduleRef key="textstructure"/>
               <moduleRef key="linking"/>

               <classSpec ident="att.specialrend" type="atts">
                  <constraintSpec ident="rends" scheme="isoschematron">
                     <constraint xmlns:sch="http://purl.oclc.org/dsdl/schematron">
                        <sch:rule context="*[@rend][local-name()=('p', 'ab')]">
                           <sch:assert
                              test="contains(@rend,'fontType()') and contains(@rend,'color()')">
                              Provide font type and color. </sch:assert>
                        </sch:rule>
                     </constraint>
                  </constraintSpec>
               </classSpec>

               <elementSpec ident="p" module="core" mode="change">
                  <classes mode="change">
                     <memberOf key="att.specialrend"/>
                  </classes>
               </elementSpec>

               <elementSpec ident="ab" module="linking" mode="change">
                  <classes mode="change">
                     <memberOf key="att.specialrend" />
                  </classes>
               </elementSpec>

               <elementSpec ident="add" module="core" mode="change">
                  <attList>
                     <attDef ident="rend" mode="replace" usage="req">
                        <desc>describes whether and how an addition is marked.</desc>
                        <gloss>rendering of addition mark.</gloss>
                        <valList type="closed" mode="replace">
                           <valItem ident="margin-mark"/>
                           <valItem ident="none"/>
                           <valItem ident="other"/>
                        </valList>
                     </attDef>
                  </attList>

               </elementSpec>

            </schemaSpec>
         </div>
      </body>
   </text>
</TEI>
peterstadler commented 8 years ago

Great idea! Two thoughts:

jamescummings commented 8 years ago

Face to Face breakout group (Providence 2016-04) all decide this is a good idea but very low priority.

raffazizzi commented 8 years ago

Instead of a constant / variable there should be a function that returns the members of a given class, e.g.:

teifn:getMembersFor("att.specialrend")

To be implemented in the XSLTs eventually.

martindholmes commented 1 year ago

@raffazizzi proposes two possible ideas at this point: the idea that we should have constants in ODD, and the idea that we should have functions in a teifn namespace which (presumably) ODD-writers could call in their ODDs. I think the intention is that both of these would be used in the context of embedded Schematron. @peterstadler proposes the more generic att.something.members, which seems more widely-useful and more characteristic of current ODD practices, but it would have issues with circularity, presumably.

In all cases, we would need to give some careful thought to how this should be implemented. For example, if element <x> claims membership of att.effable, but then deletes the @eff attribute and modifies the @off attribute, should it still be retrieved as one of the $MEMBERS? How about if the Schematron rule that summons $MEMBERS appears on ODD2 in the chain, while the attributes are deleted/modified in ODD4, further on? What if the ODD4 elementSpec replaces (@mode='replace') the @eff and @off attributes with completely different definitions?