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 . The ename
describes what can go inside the
element—attributes, as well as the content
between the start and end tags.
content
attribute aname { content }
The element allows an attribute named whose
value conforms to the given aname.
content
The order of attributes is unimportant. When a given element is shown with multiple attributes, they can occur in any order.
text
Any text is allowed as content.
content?
The given is optional.
content
content*
The given can occur zero or more times.
content
content+
The given must occur at least once, but may be
repeated; that is, it can occur one or more times.
content
C1, C2
Content must be
followed by C1.
C2
C1 & C2
Content and content
C1 must both occur, but can be
in either order.
C2
empty
Used to indicate that an element cannot have any content, and must use the empty-tag format:
<tag-name attrName="attrValue" .../>
xsd:datatype
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:
xsd:nonNegativeInteger
A number greater than or equal to zero.
xsd:positiveInteger
A number greater than zero.
xsd:anyURI
A Universal Resource Identifier.
xsd:ID
A valid XML identifier. See Section 6.2, “The ID datatype”.
xsd:IDREF
A reference to an XML identifier using the same
rules as xsd:ID.
xsd:IDREFS
A list of references to XML identifiers separated by whitespace.
xsd:NMTOKEN
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.
xsd:NMTOKENS
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 }?,
fence,
horse*
}
An example of this element might look like:
<corral corral-name="O. K." mud-type="red-clay"> <fence>6' chain link</fence> <horse>Trigger</horse> <horse>Domino</horse> </corral>
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.