Content Models


XML element content is usually guided by content models. They are declarations in a DTD (Document Type Definition) or XML schema that governs what kind of content an element can have. The content model of an element type defines the structure and composition of an element of that type in an XML instance document. Content model constraints describe the order and sequence of elements.

DTDs define a 'closed' content model that describes only what may appear in the content of an element (i.e., no user-defined types). Conforming documents must adhere to the model's rules and may not include information not declared in the DTD. The types of content that can be used in an element are:

Certain XML schema languages provide an extensibility mechanism not present when using Document Type Definitions (DTDs). For example, in XDR - the XML Data (Reduced) subset for Internet Explorer 5 - content models are 'open' by default. An open content model enables additional elements and/or attributes to be present within an element without having to declare each and every element in the XML schema. The content model for an ElementType can be specified by using <element> to reference other ElementTypes. The content attribute is used to specify whether an element will contain "textOnly" (text), "eltOnly" (other elements), "mixed" (mixture of text and elements), or "empty" (nothing at all).

In XSDL - the W3C XML Schema Definition Language - the content model can be 'open' or 'refinable' as well as 'closed'. In an 'open' content model, all required elements must be present, but it is not an error for additional elements to also be present. In a 'refinable' content model, additional elements may be present, but only if the schema defines what they are. Furthermore in XSDL, new complex types can be derived by extending content models. A derived type is identified in the instance document by using the type attribute that is part of the XML Schema instance namespace.

Copyright 2000 Extensibility, Inc.

Suite 250, 200 Franklin Street, Chapel Hill, North Carolina 27516