0% found this document useful (0 votes)
13 views

Content Models

Content models define the structure and composition of elements in an XML document by describing the allowed content and order of elements. DTDs use a closed content model while XML schemas allow open or refinable content models that are more flexible. Special characters are used in schemas to specify the number of occurrences of elements and attributes.

Uploaded by

Boka Hacker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Content Models

Content models define the structure and composition of elements in an XML document by describing the allowed content and order of elements. DTDs use a closed content model while XML schemas allow open or refinable content models that are more flexible. Special characters are used in schemas to specify the number of occurrences of elements and attributes.

Uploaded by

Boka Hacker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

Table 2-4 Occurrence Indicators in Data View Builder


Character Description
Question mark Indicates zero items or one single item. The item is optional and does not
(?) have to be included or mapped.
Asterisk (*) Indicates zero or more items. This item is optional and multiple
occurrences of it are allowed.
Plus sign (+) Indicates one or more items. This is a required element of which multiple
occurrences are allowed.

You might also like