element-declaration

built-in data type

Purpose

Every element event in a parsed markup stream is associated with an element-declaration, which contains all information that does not vary from one instance of the same element to the next.

An element-declaration has the following properties:

  • name
  • declared attributes
  • content model

Respectively, these can be obtained using the operators name of element-declaration, attributes of element-declaration, and content of element-declaration.

Every sgml-dtd and xml-dtd instance contains a shelf of type element-declaration, which can be obtained through the declared-elements of operator. This shelf is keyed by element name.

The following example program outputs names of all elements and their attributes declared by an SGML DTD:

  process
     do sgml-parse document creating sgml-dtds{"input"} scan #main-input
        suppress
     done
  
     repeat over declared-elements of sgml-dtds{"input"} as e
        output key of e || "%n"
        repeat over attributes of e as a
           output "  " || key of a || "%n"
        again
     again
          

Element declarations can be stored in shelves and passed to functions as arguments. When combined with the create-element-event operator, this allows for creation of new element events. The operator declaration of performs the inverse operation and returns the original declaration from any markup-element-event.