Purpose |
This element allows you to define elements. If the If the |
Parent element | xs:all , xs:choice , xs:group ,
xs:sequence ,
xs:schema |
Child elements | xs:annotation ,
xs:complexType ,
xs:key ,
xs:keyref ,
xs:simpleType ,
xs:unique |
Attributes | abstract (global
elements only), default ,
final (global elements only),
fixed , form (only
if not below xs:schema ),
maxOccurs (only if not below
xs:schema ),
minOccurs (only if not below
xs:schema ),
name , nillable ,
ref (only if not below
xs:schema ),
substitutionGroup (global elements only),
type |
Name | Type | Description |
---|---|---|
abstract |
xs:boolean |
If "true", this element declaration must not be used for validation. Typically, another element from the substitution group will be used in an XML document. |
block |
xs:boolean |
This attribute, in conjunction with the schema's
Alternatively, the value "#all" can be specified. This prevents the substitution of an element that is validated against this element declaration. |
default |
xs:string |
Allows you to specify for an element a default value that is inserted if the element occurs with empty content in the XML instance. Note: |
final |
This attribute, in conjunction with the schema's
Alternatively, the special value "#all" can be specified. This also means that no substitution is allowed. |
|
fixed |
xs:string |
Specifies the value that the element that must have if present. This has the following consequences for instances of that schema:
Note: |
form |
xs:NMTOKEN |
Determines whether the occurrence of locally-declared elements in an
instance document must be qualified by a namespace specification. It overrides
the default that is set by the
|
maxOccurs |
xs:nonNegativeInteger or
"unbounded"
|
Together with the |
minOccurs |
xs:nonNegativeInteger |
Together with the |
name |
xs:NCName |
Specifies a name for the element. Note: |
nillable |
xs:boolean |
If "true", an instance to be validated
against this element may have an additional
Tamino-Specific Constraints
An element or a descendant of an element with
|
ref |
xs:QName |
A global element can be referenced in other declarations in the same
schema using the Only the For more information, refer to the subsection 2.2 Complex Type Definitions, Element & Attribute Declarations in W3C´s document XML Schema Part 0: Primer Note: |
substitutionGroup |
xs:QName |
Refers to a global element declaration with a matching QName. The referenced element declaration is called the substitution group head element. This is an element that is valid against the current element declaration (which must be a global declaration), then it is a valid replacement for any element validated against the substitution group head element. See section 4.6 Substitution Groups in the W3C documentation XML Schema Part 0: Primer. |
type |
xs:QName |
Indicates the type of the element to be defined. The type can be any of the predefined types described in section 3 Built-in datatypes of W3C Recommendation, XML Schema Part 2: Datatypes or any user-defined type. The occurrence of the The type can be either a simple or a complex type. Simple types are
defined with the |
This example of an element definition using a complex type definition is
taken from an
XML
Schema for a book store. It describes how an attribute
Category
is defined that can only have the
values:
autobiography
non-fiction
fiction
<xs:element name="Book"> <xs:complexType> <xs:attribute name="Category" use="required"> <xs:restriction> <xs:simpleType base="xs:string"> <xs:enumeration value="autobiography"/> <xs:enumeration value="non-fiction"/> <xs:enumeration value="fiction"/> </xs:simpleType> </xs:restriction> </xs:attribute> <xs:attribute name="InStock" type="xs:boolean" use="optional" default="false"/> <xs:attribute name="Reviewer" type="xs:string" use="optional" default=""/> </xs:complexType> </xs:element>