Defining Complex Types : complexType « XML Schema « XML Tutorial






An element that can contain other elements or that is allowed to contain attributes is a complex type.
There are four kinds of elements of complex type: 
"element only" contain just other elements or attributes-but no text, 
"empty" elements contain attributes-but never elements or text, 
"mixed content" elements contain a combination of elements, attributes, and/or text-especially elements and text, 
"text only" elements contain only text-and possibly attributes.

Within <complexType> definitions, you can specify the allowable element content for the declaration: 

When we created a local declaration, we did not include a name attribute in our <complexType> definition. 
Local <complexType> definitions are not named, which are called anonymous complex types. 
Global <complexType> definitions are always named, so that they can be identified later. 
<complexType> definitions can also be used to create mixed and empty content models. 
Mixed content models allow you to include both text and element content within a single content model. 

<element name="description"> 
    <complexType mixed="true"> 
        <choice minOccurs="0" maxOccurs="unbounded"> 
            <element name="em" type="string"/> 
            <element name="strong" type="string"/> 
            <element name="br" type="string"/> 
        </choice> 
    </complexType> 
</element>








3.56.complexType
3.56.1.Defining Complex Types
3.56.2.To declare an empty content model in a definition
3.56.3.Content Models
3.56.4.Complex type with sequence
3.56.5.Defining Elements to Contain Only Elements
3.56.6.Defining Elements with Mixed Content
3.56.7.Build complexType with complexType
3.56.8.Complex type for element with child elements and attribute
3.56.9.When an element contains both child elements and character data, it follows the mixed content model