XML technologies / XML Schema / XML Schema element reference / xs:element (within xs:all)
(Excerpt from “XML Schema” by Eric van der Vlist)
Reference to a global element declaration or a local definition; local definitions cannot be referenced. Within xs:all, xs:element may occur only zero or one time.
<xs:element
block = ( "#all" | list of ( "extension" | "restriction" | "substitution" ) )
default = xs:string
fixed = xs:string
form = ( "qualified" | "unqualified" )
id = xs:ID
maxOccurs = ( "0" | "1" ) : "1"
minOccurs = ( "0" | "1" ) : "1"
name = xs:NCName
nillable = xs:boolean : "false"
ref = xs:QName
type = xs:QName
{beliebige Attribute mit einem Nicht-Schema-Namensraum}
>
Content: (xs:annotation?, (xs:simpleType | xs:complexType)?, (xs:unique | xs:key | xs:keyref)*)
</xs:element>May occur within: xs:all (outside a group), xs:all (within a group)
Description
This element has two mutually exclusive purposes with distinct content models: reference to a global element or local element definition.
For an element reference, attribute ref must contain its qualified name, including namespace prefix.
A local definition assigns a simple or complex type, either by reference through attribute type, naming the type by qualified name, or inline by embedding a simple-type definition, element xs:simpleType, or complex-type definition, element xs:complexType, within element xs:element.
Restrictions
Local element definitions or references cannot occur more than once.
Default and fixed values are specified in attributes and therefore apply only to simple-type elements.
W3C XML Schema cannot express mutually exclusive combinations of attributes and elements of xs:element, summarized as follows:
ref-Attribut xor name-Attribut, type-Attribut xor xs:simpleType-Element xor xs:complexType-Element
Example
<xs:all>
<xs:element name="first" type="string32" minOccurs="0"/>
<xs:element name="middle" type="string32" minOccurs="0"/>
<xs:element name="last" type="string32"/>
</xs:all>Attributes
block
Controls whether type or substitution-group substitution may apply to an element. #all blocks all substitutions, substitution blocks substitution groups, and extension and restriction block substitution, through either xsi:type or substitution groups, by elements or types derived by extension or restriction from the element’s type. The default is set by attribute blockDefault of parent element xs:schema.
default
Default element value, necessarily simple content because specified in an attribute. Applies only to empty elements present in the document. Attributes fixed and default are mutually exclusive.
fixed
Fixes a simple-content element’s value. Also used as the default, supplied to the application if the element is empty. Attributes fixed and default are mutually exclusive.
form
Specifies whether instance elements must be namespace-qualified. The default is set by attribute elementFormDefault of parent element xs:schema.
id
Element ID according to W3C XML Schema.
maxOccurs
Maximum element occurrence count; within an xs:all compositor, only 0 or 1 is permitted.
minOccurs
Minimum element occurrence count; within an xs:all compositor, only 0 or 1 is permitted.
name
Element name, mutually exclusive with attribute ref.
nillable
If set to true, the element can be declared nil in instance documents using attribute xsi:nil.
ref
Reference to a global element definition, mutually exclusive with attributes name, block and type and embedded type definitions.
type
Element’s simple or complex type, mutually exclusive with attribute ref and embedded type definitions.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de