Next / Previous / Contents / TCC Help System / NM Tech homepage

7. Content model notation

We define each element of XHTML by its structure: which attributes are required and allowed, and the element's content.

To specify these things, we use the notation of Relax NG Compact Syntax (RNC). This notation is defined elsewhere in Relax NG Compact Syntax (RNC), but we summarize the relevant parts here.

element ename { content }

Defines an XHTML element called ename. The content describes what can go inside the element—attributes, as well as the content between the start and end tags.

attribute aname { content }

The element allows an attribute named aname whose value conforms to the given content.

The order of attributes is unimportant. When a given element is shown with multiple attributes, they can occur in any order.


Any text is allowed as content.


The given content is optional.


The given content can occur zero or more times.


The given content must occur at least once, but may be repeated; that is, it can occur one or more times.

C1, C2

Content C1 must be followed by C2.

C1 & C2

Content C1 and content C2 must both occur, but can be in either order.


Used to indicate that an element cannot have any content, and must use the empty-tag format:

<tag-name attrName="attrValue" .../>


The content must match one of the standard data types defined in the XML Schema standard. This standard defines a large number of data types, but only a few are used in XHTML:


A number greater than or equal to zero.


A number greater than zero.


A Universal Resource Identifier.


A valid XML identifier. See Section 6.2, “The ID datatype”.


A reference to an XML identifier using the same rules as xsd:ID.


A list of references to XML identifiers separated by whitespace.


A name that conforms to the rules for XML names. For these rules, see Section 6.2, “The ID datatype”. The difference between name tokens and IDs is that IDs must be unique in a document, while name tokens can be used in more than one place.


A list of xsd:NMTOKEN names separated by whitespace.

Here is a small example illustrating several of these features. Suppose we are defining an element called corral. This element has a required attribute called corral-name containing a name. It also allows an optional attribute called mud-type that contains an identifier for the type of mud that it makes when it gets wet. The element content consists of one required fence child followed by zero or more horse children:

element corral
{ attribute corral-name { text },
  attribute mud-type { IDREF }?,

An example of this element might look like:

<corral corral-name="O. K." mud-type="red-clay">
  <fence>6' chain link</fence>

The notation here is adapted from the Relax NG stylesheets provided with James Clark's nxml-emacs editing mode for the emacs text editor. For further information, see James Clark's Thai Open Source pages.