Attributes: type tests

It is possible to test for the type of an element attribute or data attribute. An attribute can be declared with one of the following types:

  • CDATA
  • NAME
  • NAMES
  • NUMBER
  • NUMBERS
  • NMTOKEN
  • NMTOKENS
  • NUTOKEN
  • NUTOKENS
  • ID
  • IDREF
  • IDREFS
  • NOTATION
  • ENTITY
  • ENTITIES

An attribute can also be declared as a name token group. A name token group attribute can only have one of the values specified in the parenthesized list of names. The is group test determines if the attribute is declared in this way.

If the specified attribute was not declared for the qualified element (or entity), or if the qualified element does not exist, then an error message is printed and OmniMark halts. The error message can be avoided by using the is specified, is defaulted, or is implied tests.

Entity and notation attribute tests can be applied directly to attribute values which are declared as ENTITY or NOTATION, or directly to an item of an attribute declared as ENTITIES. It is usually wise to test that the attribute value is an ENTITY, ENTITIES, or NOTATION attribute before applying the entity or notation test. Note that for a data attribute, a test of its type for ID, IDREF, IDREFS, NOTATION, ENTITY, or ENTITIES will always fail, because those types of attributes cannot be associated with a notation.

Attribute type tests can be combined by separating the types with the or keyword or its short form, the | symbol. For example:

  do when attribute id is (idref | idrefs)
  ...
  done