∟Defining Complex Datatypes - "complexType" Element
This section describes a tutorial example on how to define a complex datatype to be used to declare an element that can accept attributes and/or sub elements.
If element is declared with a simple datatype, for example, the "string" built-in datatype,
the element must be "simple" - not allowed to have any attributes and any sub (child) elements.
If you want to declare an element to accept attributes or sub elements, you need to
use the Complex Type Definition Component.
Rule 1. The Complex Type Definition Component allows you to define a new complex datatype,
which can be used to declare elements to accept attributes and/or sub (child) elements.
Rule 2. The XML representation of a Complex Type Definition Component is a "complexType" element.
Rule 3. A "complexType" must have "name" attribute, if it is used to define a named datatype.
Rule 4. A simple way to specify an attribute in a "complexType" is to add an "attribute" component.
Rule 5. A simple way to specify a list of sub elements is to add a "sequence" element component.
Here is an example schema document, term.xsd, that declares element "term" to accept
two sub (child) elements and one attribute: