ODD topics – a simple introduction to attribute classes in TEI

Attribute classes have been introduced in the TEI infrastructure in order to declare groups of attributes which are shared across various elements. For instance, the att.timed attribute class contains the declaration of two attributes, @start and @end (see https://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-att.timed.html): the elements whose specification states that they belong to this class will automatically get the two attributes. This is reflected in the generated documentation, as can be seen for the <u> element for instance (see https://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-u.html).

Over the years, it has been a general policy of the TEI technical council to factorise attribute declarations as classes in order to simplify the legibility and management of the guidelines.

When designing a TEI customisation in ODD, it is possible to use attribute classes to make the corresponding attributes available for additional elements. For example, you may want to say that there are several types of formulas in your document model and thus add the <formula> element to the att.typed attribute class.

In ODD specifications, adding an element to an attribute class can be achieved as exemplified below:

<elementSpec ident="formula" mode="change">
   <classes mode="change">
      <memberOf key="att.typed" mode="add"/>
   </classes>
</elementSpec>

The preceding declaration supplies the <formula> element with the two attributes declared in att.typed (see https://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-att.typed.html), namely @type and @subtype.

Conversely, one may want to get rid of some attributes inherited through a class on a specific element. There are actually two ways to do so:

  • Completely deselect the attribute class from the element, which takes out all attributes that were declared in the class;
  • Operates a surgical change by just taking out the intended attributes from the element.

The first method is similar to adding an attribute class to an element with the @mode attribute set to “delete” on <memberOf>. The following example removes the <s> element from the att.typed attribute class, thus depriving it of both @type and @subtype:

<elementSpec ident="s" mode="change">
   <classes mode="change">
      <memberOf key="att.typed" mode="delete"/>
   </classes>
</elementSpec>

The second methods elicits the deletion of the attribute from the element by using an <attDef> declaration. The following snippet deletes the @subtype attribute from the <s> element while keeping @type inherited from att.typed.

<elementSpec ident="s" mode="change">
   <attList>
      <attDef ident="subtype" mode="delete"/>
   </attList>
</elementSpec>

In some situations, when just one attribute from a class is needed, it is possible to combine a class attribution and attribute deletion declarations within the same ODD specification. For instance the following declaring makes <u> member of att.typed, while deleting @subtype:

<elementSpec ident="formula" mode="change">
   <classes mode="change">
      <memberOf key="att.typed" mode="add"/>
   </classes>
   <attList>
      <attDef ident="subtype" mode="delete"/>
   </attList>
</elementSpec>

Note: such a customization is closer to the spirit of the TEI guidelines, than declaring a new @type attribute on the element.

In the same way, it is possible to change the actual declaration of an attribute, in order to associate, for instance, a closed set of values to it.



Cite this blog post
Laurent Romary (2019, April 1). ODD topics – a simple introduction to attribute classes in TEI. Bag of tags. Retrieved March 29, 2024, from https://doi.org/10.58079/unn3

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.