Restricting an Element’s Attributes to Specific Ones Only
By default in TEI, elements inherit many attribute classes (att.global, att.datable, etc.), making numerous attributes available. If you want to allow only specific attributes, configure it as follows.
Example: Allowing Only xml:id and corresp on persName
<elementSpec ident="persName" mode="change">
<classes mode="change">
<!-- 属性クラスを削除(モデルクラスは維持) -->
<memberOf key="att.global" mode="delete"/>
<memberOf key="att.cmc" mode="delete"/>
<memberOf key="att.datable" mode="delete"/>
<memberOf key="att.editLike" mode="delete"/>
<memberOf key="att.personal" mode="delete"/>
<memberOf key="att.typed" mode="delete"/>
</classes>
<attList>
<attDef ident="xml:id" mode="add" usage="opt">
<desc>要素の一意な識別子</desc>
<datatype>
<dataRef name="ID"/>
</datatype>
</attDef>
<attDef ident="corresp" mode="add" usage="opt">
<desc>関連する人物情報へのリンク</desc>
<datatype>
<dataRef key="teidata.pointer"/>
</datatype>
</attDef>
</attList>
</elementSpec>
Key Points
- Use
<classes mode="change">: If you usemode="replace"and leave it empty, the model classes will also be deleted, making the element itself unusable - Delete attribute classes individually: Remove unnecessary attribute classes with
<memberOf key="att.xxx" mode="delete"/> - Add required attributes: Define the attributes you want to allow with
<attDef ident="xxx" mode="add">
Notes
- You can check which attribute classes an element belongs to in the TEI Guidelines
- Deleting
att.globalwill also removexml:id,xml:lang, etc., so add them individually as needed
Adding Attributes to an Element
When adding a new attribute while keeping existing attribute classes:
<elementSpec ident="pb" mode="change">
<attList>
<attDef ident="facs" mode="add" usage="opt">
<desc>原本画像へのリンク</desc>
<datatype>
<dataRef key="teidata.pointer"/>
</datatype>
</attDef>
</attList>
</elementSpec>
In this case, the existing attribute classes are maintained as-is, and the facs attribute is added.