Defines an element type for use within the Schema element.
Syntax
<ElementType content="{empty | textOnly | eltOnly | mixed}" dt:type="datatype" model="{open | closed}" name="idref" order="{one | seq | many}" >
Attributes
- content
- Indicator of whether the content must be empty, or can contain text, elements, or both. The following values can be assigned to this attribute.
empty The element cannot contain content. textOnly The element can contain only text, not elements. Note that if the model attribute is set to "open," the element can contain text and other unnamed elements. eltOnly The element can contain only the specified elements. It cannot contain any free text. mixed The element can contain a mix of named elements and text. <ElementType name="x" content="empty"/> <ElementType name="x" content="textOnly"/> <ElementType name="x" content="eltOnly"> <element type="y"> </ElementType> <ElementType name="x" content="mixed"> <element type="q"> <element type="r"> </ElementType>The document type definition (DTD) equivalent is as follows:
empty: <!ELEMENT x EMPTY> textOnly: <!ELEMENT x (#PCDATA)> eltOnly: <!ELEMENT x y> mixed: <!ELEMENT x (#PCDATA | q | r)*>- dt:type
- Data type of the element. The valid data types are defined in the XML Data Types Preview.
- model
- Indicator of whether the content can include only what is defined in the content model, or can contain content not specified in the model.
<ElementType name="x" model="open"/>When the model is defined as open, the element can include ElementType elements, AttributeType elements, and mixed content not specified in the content model. When the model is defined as closed, the element cannot include elements and cannot include mixed content not specified in the content model. The document type definition (DTD) uses a closed model.
- name
- Name of the element. This attribute is required. If this element type is declared as a valid child of another element type, this name is specified within an element element.
<ElementType name="x"> </ElementType>The DTD equivalent is as follows:
<!ELEMENT x EMPTY>- order
- The following values can be assigned to this attribute.
one Permits only one of a set of elements. seq Requires the elements to appear in the specified sequence. many Permits the elements to appear (or not appear) in any order. The "seq" setting is needed to specify valid sequences. For example, it can be used to specify when a particular sequence such as "x1,y1" or "x2,y2" is valid but no other possible combinations are valid. The "seq" value serves the same role as parentheses in a DTD.
The following example demonstrates the "one" setting:
<ElementType name="z" order="one"> <element type="x"> <element type="y"> </ElementType>The following example demonstrates the "seq" setting:
<ElementType name="x" order="one"> <group order="seq"> <element type="x1"> <element type="y1"> </group> <group order="seq"> <element type="x2"> <element type="y2"> </group> </ElementType>The following example demonstrates the "many" setting:
<ElementType name="x" content="eltOnly" order="many"> <element type="q"> <element type="r"> </ElementType>
Element Information
Number of occurrences Unlimited Parent elements Schema Child elements Attribute, AttributeType, datatype, description, element, group Requires closing tag Yes. XML Schema is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed.
Remarks
The term "element type" refers to the element type of which all elements sharing a name are instances. Element types are declared in schemas; elements occur in documents. Element types are declared with the ElementType element type.
Example
<ElementType name="x"> <!-- element content declarations go here --> </ElementType>