Content Models
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:
EMPTY - an empty element doesn't contain any content or data. It may contain only properties,
represented by attributes, that help to characterize what the element is about or reference other
files.
ANY - allows either an element or parsed character data as content for the element. This gives the
document author more leeway in creating the element, but may lead to loss of structure.
Mixed - the element can consist of a mix of other elements and parsed character data.
Element - any element content must contain another element; these elements must be
descendents of the containing element. The content model dictates that specific elements must be
nested within the element.
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.
Special Characters: Occurrence Indicators
The Data View Builder uses a set of special characters (occurrence indicators) to
indicate the number of items in a sequence. Occurrence indicators are generally used
to specify characteristics for elements or attributes in schemas, but are also found
elsewhere in the Builder user interface (UI) where they are needed to specify
occurrence characteristics. You can apply these characteristics to elements and
attributes of schemas that you build or modify by accessing the right-mouse click pop-
up menu on schema nodes.