This document is also available in these non-normative formats: XML, XHTML with changes since version 1.0 marked, XHTML with changes since previous Working Draft marked, Independent copy of the schema for schema documents, Independent copy of the DTD for schema documents, Independent tabulation of components and microcomponents, and List of translations.
Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
↓XML Schema: Structures↓↑This document↑ specifies the ↓XML Schema definition language↓↑XML Schema Definition Language↑, which offers facilities for describing the structure and constraining the contents of XML↓ 1.0↓ documents, including those which exploit the XML Namespace facility. The schema language, which is itself ↑represented in an↑ XML↓ 1.0↓↑ vocabulary↑ and uses namespaces, substantially reconstructs and considerably extends the capabilities found in XML↓ 1.0↓ document type definitions (DTDs). This specification depends on ↓XML Schema↓↑XML Schema Definition Language 1.1↑ Part 2: Datatypes.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This is a ↑Last Call↑ Public Working Draft of ↓XML Schema 1.1↓↑W3C XML Schema Definition Language (XSD) 1.1↑. It is here made available for review by W3C members and the public. ↓It is intended to give an indication of the W3C XML Schema Working Group's intentions for this new version of the XML Schema language and our progress in achieving them. It attempts to be complete in indicating what will change from version 1.0, but does not specify in all cases how things will change.↓↑XSD 1.1 retains all the essential features of XSD 1.0, but adds several new features to support functionality requested by users, fixes many errors in XSD 1.0, and clarifies wording.↑
For those primarily interested in the changes since version 1.0, the ↑appendix↑ Changes since version 1.0 ↑(non-normative)↑ (§H)↓ appendix, which summarizes both changes already made and also those in prospect, with links to the relevant sections of this draft,↓ is the recommended starting point. ↑It summarizes both changes made since XSD 1.0 and some changes which were expected (and predicted in earlier drafts of this specification) but have not been made after all.↑ Accompanying versions of this document display in color all changes to normative text since version 1.0 and since the previous Working Draft.
Please send comments on this Working Draft to www-xml-schema-comments@w3.org (archive).
The Last Call review period for this document extends until 12 September 2008. Comments on this document should be made in W3C's public installation of Bugzilla, specifying "XML Schema" as the product. Instructions can be found at http://www.w3.org/XML/2006/01/public-bugzilla. If access to Bugzilla is not feasible, please send your comments to the W3C XML Schema comments mailing list, www-xml-schema-comments@w3.org (archive) Each Bugzilla entry and email message should contain only one comment.
Although feedback based on any aspect of this specification is welcome, there are certain aspects of the design presented herein for which the Working Group is particularly interested in feedback. These are designated "priority feedback" aspects of the design, and identified as such in editorial notes at appropriate points in this draft. Any feature mentioned in a priority feedback note should be considered a "feature at risk": the feature may be retained as is, modified, or dropped, depending on the feedback received from readers, schema authors, schema users, and implementors.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document has been produced by the W3C XML Schema Working Group as part of the W3C XML Activity. The goals of ↓the XML Schema language version↓↑XSD↑ 1.1 are discussed in the ↑document↑ Requirements for XML Schema 1.1↓ document↓. The authors of this document are the members of the XML Schema Working Group. Different parts of this specification have different editors.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
The English version of this specification is the only normative version. Information about translations of this document is available at http://www.w3.org/2003/03/Translations/byTechnology?technology=xmlschema.
The presentation of this document has been augmented to
identify changes from a previous version, controlled by dg-statusquo-color-1.0.xml. Three kinds of changes are highlighted:
↑new, added text↑,
↑changed text↓, and
↓deleted text↓.
This document sets out the structural part ↓(XML Schema: Structures)↓ of the ↓XML Schema definition language↓↑XML Schema Definition Language↑.
Chapter 2 presents a Conceptual Framework (§2) for ↓XML Schemas↓↑XSD↑, including an introduction to the nature of ↓XML Schemas↓↑XSD schemas↑ and an introduction to the ↓XML Schema↓↑XSD↑ abstract data model, along with other terminology used throughout this document.
Chapter 3, Schema Component Details (§3), specifies the precise semantics of each component of the abstract model, the representation of each component in XML, with reference to a DTD and ↑an↑ ↓XML Schema↓↑XSD schema↑ for an ↓XML Schema↓↑XSD↑ document type, along with a detailed mapping between the elements and attribute vocabulary of this representation and the components and properties of the abstract model.
Chapter 4 presents Schemas and Namespaces: Access and Composition (§4), including the connection between documents and schemas, the import, inclusion and redefinition of declarations and definitions and the foundations of schema-validity assessment.
Chapter 5 discusses Schemas and Schema-validity Assessment (§5), including the overall approach to schema-validity assessment of documents, and responsibilities of schema-aware processors.
The normative appendices include a Schema for ↓Schemas↓↑Schema Documents (Structures)↑ (normative) (§A) for the XML representation of schemas and References (normative) (§B).
The non-normative appendices include the DTD for Schemas (non-normative) (§L) and a Glossary (non-normative) (§K).
This document is primarily intended as a language definition reference. As such, although it contains a few examples, it is not primarily designed to serve as a motivating introduction to the design and its features, or as a tutorial for new users. Rather it presents a careful and fully explicit definition of that design, suitable for guiding implementations. For those in search of a step-by-step introduction to the design, the non-normative [XML Schema: Primer] is a much better starting point than this document.
The Working Group has three main goals for this version of W3C XML Schema:
These goals are in tension with one another. The Working Group's strategic guidelines for changes between versions 1.0 and 1.1 can be summarized as follows:
The aim with regard to compatibility is that
The purpose of XML Schema↑ Definition Language↑: Structures is to define the nature of ↓XML schemas↓↑XSD schemas↑ and their component parts, provide an inventory of XML markup constructs with which to represent schemas, and define the application of schemas to XML documents.
The purpose of an ↓XML Schema: Structures↓↑XSD↑ schema is to define and describe a class of XML documents by using schema components to constrain and document the meaning, usage and relationships of their constituent parts: datatypes, elements and their content and attributes and their values. Schemas ↓may↓↑can↑ also provide for the specification of additional document information, such as normalization and defaulting of attribute and element values. Schemas have facilities for self-documentation. Thus, XML Schema↑ Definition Language↑: Structures can be used to define, describe and catalogue XML vocabularies for classes of XML documents.
Any application that consumes well-formed XML can use the ↓XML Schema: Structures↓ formalism ↑defined here↑ to express syntactic, structural and value constraints applicable to its document instances. The ↓XML Schema: Structures↓↑XSD↑ formalism allows a useful level of constraint checking to be described and implemented for a wide spectrum of XML applications. However, the language defined by this specification does not attempt to provide all the facilities that might be needed by ↓any application↓↑applications↑. Some applications ↓may↓↑will↑ require constraint capabilities not expressible in this language, and so ↓may↓↑will↑ need to perform their own additional validations.
xs)
The XML representation of schema components uses a vocabulary
identified by the namespace name http://www.w3.org/2001/XMLSchema.
For brevity, the text and examples in this specification use
the prefix xs: to stand for this
namespace; in practice, any prefix can be used.
untyped,
untypedAtomic) which are not defined in this
specification; see the [XDM]
specification for details of those types.
Users of the namespaces defined here should be aware, as a matter of namespace policy, that more names in this namespace may be given definitions in future versions of this or other specifications.
xsi)This specification defines
several attributes for direct use in any XML documents, as
described in Schema-Related Markup in Documents Being Validated (§2.6).
These attributes are in the namespace whose name is http://www.w3.org/2001/XMLSchema-instance.
For brevity, the text and examples in this specification use
the prefix xsi: to stand for this namespace; in
practice, any prefix can be used.
Users of the namespaces defined here should be aware, as a matter of namespace policy, that more names in this namespace may be given definitions in future versions of this or other specifications.
vc)
The pre-processing of schema documents described in
Conditional inclusion (§4.2.1) uses
attributes in the namespace
http://www.w3.org/2007/XMLSchema-versioning.
For brevity, the text and examples in this specification use
the prefix vc: to stand for this
namespace; in practice, any prefix can be used.
Users of the namespaces defined here should be aware, as a matter of namespace policy, that more names in this namespace may be given definitions in future versions of this or other specifications.
http://www.w3.org/XML/1998/namespacehttp://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2007/XMLSchema-versioningComponents and source declarations must not specify
http://www.w3.org/2000/xmlns/ as their
target namespace. If they do, then the schema
and/or schema document is in ·error·.
html bound to
http://www.w3.org/1999/xhtmlmy (in examples) bound to the target namespace
of the example schema documentrddl bound to
http://www.rddl.org/vc bound to
http://www.w3.org/2007/XMLSchema-versioning (defined
in this and related specifications)xhtml bound to
http://www.w3.org/1999/xhtmlxlink bound to
http://www.w3.org/1999/xlinkxs bound to http://www.w3.org/2001/XMLSchema
(defined in this and related specifications)xsi bound to
http://www.w3.org/2001/XMLSchema-instance (defined in this and
related specifications)xsl bound to
http://www.w3.org/1999/XSL/TransformIn practice, any prefix bound to the appropriate namespace
name may be used (unless otherwise specified by the definition
of the namespace in question, as for xml and
xmlns).
Sometimes other specifications or Application Programming Interfaces (APIs) need to refer to the XML Schema Definition Language in general, sometimes they need to refer to a specific version of the language. To make such references easy and enable consistent identifiers to be used, we provide the following URIs to identify these concepts.
http://www.w3.org/XML/XMLSchemahttp://www.w3.org/XML/XMLSchema/vX.Yhttp://www.w3.org/XML/XMLSchema/v1.0 identifies
XSD version 1.0 and http://www.w3.org/XML/XMLSchema/v1.1 identifies
XSD version 1.1.
http://www.w3.org/XML/XMLSchema/vX.Y/NeX.Y of
the XSD specification. For example, http://www.w3.org/XML/XMLSchema/v1.0/2e
identifies the second edition of XSD version 1.0.
http://www.w3.org/XML/XMLSchema/vX.Y/Ne/yyyymmddX.Y of
the XSD specification published on the particular date
yyyy-mm-dd. For example,
http://www.w3.org/XML/XMLSchema/v1.0/1e/20001024
identifies the language
defined in the XSD version 1.0 Candidate
Recommendation (CR) published on 24 October 2000, and
http://www.w3.org/XML/XMLSchema/v1.0/2e/20040318
identifies the language
defined in the XSD version 1.0 Second Edition Proposed
Edited Recommendation (PER)
published on 18 March 2004.
Please see XSD Language Identifiers (non-normative) (§O) for a complete list of XML Schema Definition Language identifiers which exist to date.
The definition of XML Schema↑ Definition Language↑: Structures depends on the following specifications: [XML-Infoset], [XML-Namespaces 1.1], ↓[XPath],↓ ↑[XPath 2.0], ↑and [XML Schema: Datatypes].
See Required Information Set Items and Properties (normative) (§E) for a tabulation of the information items and properties specified in [XML-Infoset] which this specification requires as a precondition to schema-aware processing.
[XML Schema: Datatypes] defines some datatypes which depend on definitions in [XML 1.1] and [XML-Namespaces 1.1]; those definitions, and therefore the datatypes based on them, vary between version 1.0 ([XML 1.0], [XML-Namespaces 1.0]) and version 1.1 ([XML 1.1], [XML-Namespaces 1.1]) of those specifications. In any given schema-validity-·assessment· episode, the choice of the 1.0 or the 1.1 definition of those datatypes is ·implementation-defined·.
Conforming implementations of this specification may provide either the 1.1-based datatypes or the 1.0-based datatypes, or both. If both are supported, the choice of which datatypes to use in a particular assessment episode should be under user control.
The section introduces the highlighting and typography as used in this document to present technical material.
Special terms are defined at their point of introduction in the text. For example [Definition:] a term is something used with a special meaning. The definition is labeled as such and the term it defines is displayed in boldface. The end of the definition is not specially marked in the displayed or printed text. Uses of defined terms are links to their definitions, set off with middle dots, for instance ·term·.
Non-normative examples are set off in boxes and accompanied by a brief explanation:
<schema targetNamespace="http://www.example.com/XMLSchema/1.0/mySchema">
The definition of each kind of schema component consists of a list of its properties and their contents, followed by descriptions of the semantics of the properties:
References to properties of schema components are links to the relevant definition as exemplified above, set off with curly braces, for instance {example property}.
For a given component C, an expression of the form "C.{example property}" denotes the (value of the) property {example property} for component C. The leading "C." (or more) is sometimes omitted, if the identity of the component and any other omitted properties is understood from the context. This "dot operator" is left-associative, so "C.{p1}.{p2}" means the same as "(C.{p1}) . {p2}" and denotes the value of property {p2} within the component or ·property record· which itself is the value of C's {p1} property. White space on either side of the dot operator has no significance and is used (rarely) solely for legibility.
For components C1 and C2, an expression of the form "C1 . {example property 1} = C2 . {example property 2}" means that C1 and C2 have the same value for the property (or properties) in question. Similarly, "C1 = C2" means that C1 and C2 are identical, and "C1.{example property} = C2" that C2 is the value of C1.{example property}.
The correspondence between an element information item which is part of the XML representation of a schema and one or more schema components is presented in a tableau which illustrates the element information item(s) involved. This is followed by a tabulation of the correspondence between properties of the component and properties of the information item. Where context ↓may determine↓↑determines↑ which of several different components ↓may arise↓↑corresponds to the source declaration↑, several tabulations, one per context, are given. The property correspondences are normative, as are the illustrations of the XML representation element information items.
In the XML representation, bold-face attribute names (e.g.
count below) indicate a required attribute
information item, and the rest are optional. Where an attribute
information item has an enumerated type definition, the values
are shown separated by vertical bars, as for size
below; if there is a default value, it is shown following a
colon. Where an attribute information item has a built-in simple
type definition defined in [XML Schema: Datatypes], a hyperlink
to
its definition therein is given.
The allowed content of the information item is shown as a
grammar fragment, using the Kleene operators ?,
* and +. Each element name therein is
a hyperlink to its own illustration.
example Element Information ItemReferences to elements in the text are links to the relevant illustration as exemplified above, set off with angle brackets, for instance <example>.
Unless otherwise specified, references to attribute values
are references to the ·actual value· of the attribute information
item in question, not to its ·normalized value· or to other forms
or varieties of "value" associated with it.
For a given element information item E, expressions of the
form "E has att1 = V"
are short-hand for "there is an attribute information
item named att1 among the [attributes] of E and
its ·actual value·
is V."
If the identity of E is clear from context, expressions
of the form "att1 = V"
are sometimes used.
The form "att1 ≠ V" is also used
to specify that the ·actual value· of att1 is
not V.
References to properties of information items as defined in [XML-Infoset] are notated as links to the relevant section thereof, set off with square brackets, for example [children].
Properties which this specification defines for information items are introduced as follows:
References to properties of information items defined in this specification are notated as links to their introduction as exemplified above, set off with square brackets, for example [new property].
The "dot operator" described above for components and their properties is also used for information items and their properties. For a given information item I, an expression of the form "I . [new property]" denotes the (value of the) property [new property] for item I.
Lists of normative constraints are typically introduced with phrase like "all of the following are true" (or "... apply"), "one of the following is true", "at least one of the following is true", "one or more of the following is true", "the appropriate case among the following is true", etc. The phrase "one of the following is true" is used in cases where the authors believe the items listed to be mutually exclusive (so that the distinction between "exactly one" and "one or more" does not arise). If the items in such a list are not in fact mutually exclusive, the phrase "one of the following" should be interpreted as meaning "one or more of the following". The phrase "the appropriate case among the following" is used only when the cases are thought by the authors to be mutually exclusive; if the cases in such a list are not in fact mutually exclusive, the first applicable case should be taken. Once a case has been encountered with a true condition, subsequent cases must not be tested.
The following highlighting is used for non-normative commentary in this document:
↓Following [XML 1.1], w↓↑W↑ithin normative prose in this specification, the words may↓ and↓↑, should↑↑,↑ must↑ and must not↑ are defined as follows:
These definitions describe in terms specific to this document the meanings assigned to these terms by [IETF RFC 2119]. The specific wording follows that of [XML 1.1].
Where these terms appear without special highlighting, they are used in their ordinary senses and do not express conformance requirements. Where these terms appear highlighted within non-normative material (e.g. notes), they are recapitulating rules normatively stated elsewhere.
↓Note however that this↓↑This↑ specification provides a ↓definition↓ ↑further description↑ of error and of conformant processors' responsibilities with respect to errors ↓(see↓↑in↑ Schemas and Schema-validity Assessment (§5)↓) which is considerably more complex than that of [XML 1.1]↓.
This chapter gives an overview of XML Schema↑ Definition Language↑: Structures at the level of its abstract data model. Schema Component Details (§3) provides details on this model, including a normative representation in XML for the components of the model. Readers interested primarily in learning to write schema documents ↓may wish to first↓↑will find it most useful first to↑ read [XML Schema: Primer] for a tutorial introduction, and only then ↑to↑ consult the sub-sections of Schema Component Details (§3) named XML Representation of ... for the details.
An ↓XML Schema↓↑XSD schema↑ ↓consists↓↑is a set↑ of components such as type definitions and element declarations. These can be used to assess the validity of well-formed element and attribute information items (as defined in [XML-Infoset]), and furthermore ↓may↓↑may↑ specify augmentations to those items and their descendants. This augmentation makes explicit information ↓which may have been↓ implicit in the original document, such as normalized and/or default values for attributes and elements and the types of element and attribute information items. ↑The input information set can also be augmented with information about the validity of the item, or about other properties described in this specification.↑ [Definition:] We refer to the augmented infoset which results from conformant processing as defined in this specification as the post-schema-validation infoset, or PSVI. ↑Conforming processors may provide access to some or all of the PSVI, as described in Subset of the Post-schema-validation Infoset (§D.1). The mechanisms by which processors provide such access to the PSVI are neither defined nor constrained by this specification.↑
Throughout this specification, [Definition:] the word valid and its derivatives are used to refer to clause 1 above, the determination of local schema-validity.
Throughout this specification, [Definition:] the word assessment is used to refer to the overall process of local validation, schema-validity assessment and infoset augmentation.
This specification builds on [XML 1.1] and [XML-Namespaces 1.1]. The concepts and definitions used herein regarding XML are framed at the abstract level of information items as defined in [XML-Infoset]. By definition, this use of the infoset provides a priori guarantees of well-formedness (as defined in [XML 1.1]) and namespace conformance (as defined in [XML-Namespaces 1.1]) for all candidates for ·assessment· and for all ·schema documents·.
Just as [XML 1.1] and [XML-Namespaces 1.1] can be described in terms of information items, ↓XML Schemas↓↑XSD schemas↑ can be described in terms of an abstract data model. In defining ↓XML Schemas↓↑schemas↑ in terms of an abstract data model, this specification rigorously specifies the information which must be available to a conforming ↓XML Schema↓↑XSD↑ processor. The abstract model for schemas is conceptual only, and does not mandate any particular implementation or representation of this information. To facilitate interoperation and sharing of schema information, a normative XML interchange format for schemas is provided.
[Definition:] Schema component is the generic term for the building blocks that ↓comprise↓↑make up↑ the abstract data model of the schema. ↓[Definition:] An XML Schema is a set of ·schema components·↓↑[Definition:] An XSD schema is a set of ·schema components·↑. There are ↓13 kinds of component in all↓↑several kinds of schema component↑, falling into three groups. The primary ↑schema↑ components, which may (type definitions) or must (element and attribute declarations) have names, are as follows:
The secondary ↑schema↑ components, ↓which must have names, ↓are as follows:
Finally, the "helper" ↑schema↑ components provide small parts of other ↑schema↑ components; they are ↓not independent of↓↑dependent on↑ their context:
The name [Definition:] Component covers all the different kinds of component defined in this specification.
The name [Definition:] Component covers all the different kinds of schema component defined in this specification.
During ·validation·, [Definition:] declaration components are associated by (qualified) name to information items being ·validated·.
On the other hand, [Definition:] definition components define internal schema components that can be used in other schema components.
[Definition:] Declarations and definitions ↓may↓↑may↑ ↑and in some cases must↑ have and be identified by names, which are NCNames as defined by [XML-Namespaces 1.1].
[Definition:] Several kinds of component have a target namespace, which is either ·absent· or a namespace name, also as defined by [XML-Namespaces 1.1]. The ·target namespace· serves to identify the namespace within which the association between the component and its name exists. ↓In the case of declarations, this in turn determines the namespace name of, for example, the element information items it may ·validate·.↓
An expanded name, as defined in [XML-Namespaces 1.1], is a pair consisting of a namespace name, which may be ·absent·, and a local name. The expanded name of any component with both a ·target namespace· property and a ·component name· property is the pair consisting of the values of those two properties. The expanded name of a declaration is used to help determine which information items will be ·governed· by the declaration.
·Validation·, defined in detail in Schema Component Details (§3), is a relation between information items and schema components. For example, an attribute information item ↓may ·validate·↓↑is ·validated·↑ with respect to an attribute declaration, a list of element information items ↓may ·validate·↓ with respect to a content model, and so on. The following sections briefly introduce the kinds of components in the schema abstract data model, other major features of the abstract model, and how they contribute to ·validation·.
The abstract model provides two kinds of type definition component: simple and complex.
[Definition:] This specification uses the phrase type definition in cases where no distinction need be made between simple and complex types.
Type definitions form a hierarchy with a single root. The subsections below first describe characteristics of that hierarchy, then provide an introduction to simple and complex type definitions themselves.
[Definition:] Except for ↓a distinguished ·ur-type
definition·,↓ ↑·xs:anyType·,↑ every ·type definition· is, by construction,
either a ·restriction· or an
·extension· of some
other type definition. The graph of these relationships forms
a tree known as the Type Definition
Hierarchy.
[Definition:] ↓A↓↑The↑ type definition used as the basis for an ·extension· or ·restriction· is known as the base type definition of that definition.
[Definition:] ↓A type definition whose declarations or facets are in a one-to-one relation with those of another specified type definition, with each in turn restricting the possibilities of the one it corresponds to,↓↑A type defined with the same constraints as its ·base type definition·, or with more,↑ is said to be a restriction. The ↓specific restrictions↓↑added constraints↑ might include narrowed ranges or reduced alternatives. ↓Members of a type, A, whose definition is a ·restriction· of the definition of another type, B, are always locally valid against type B as well.↓↑Given two types A and B, if the definition of A is a ·restriction· of the definition of B, then members of type A are always locally valid against type B as well.↑
[Definition:] A complex type definition which allows element or attribute content in addition to that allowed by another specified type definition is said to be an extension.
[Definition:] A distinguished complex type definition, the ur-type definition, whose name is anyType in the XML Schema namespace, is present in each ·XML Schema·, serving as the root of the type definition hierarchy for that schema.
[Definition:] A special complex type definition, (referred to in earlier versions of this specification as 'the ur-type definition') whose name is anyType in the XSD namespace, is present in each ·XSD schema·. The definition of anyType serves as default type definition for element declarations whose XML representation does not specify one.
[Definition:] A special simple type
definition, whose name is error in the XSD
namespace, is also present in each ·XSD schema·. The
XSD error type
has no valid instances. It can be used in any place where
other types are normally used; in particular, it can be used
in conditional type assignment to cause elements which satisfy
certain conditions to be invalid.
For brevity, the text and examples in this specification often
use the qualified names xs:anyType and
xs:error for these type definitions. (In
practice, any appropriately declared prefix can be used, as
described in Schema-Related Markup in Documents Being Validated (§2.6).)
[Definition:] A type definition used as the basis for an ·extension· or ·restriction· is known as the base type definition of that definition.
A simple type definition is a set of constraints on strings and information about the values they encode, applicable to the ·normalized value· of an attribute information item or of an element information item with no element children. Informally, it applies to the values of attributes and the text-only content of elements.
Each simple type definition, whether built-in (that is,
defined in [XML Schema: Datatypes]) or user-defined, is a ·restriction· of ↓some particular simple↓↑its↑ ·base type definition·.
↓For the built-in primitive type
definitions, this is ↓↓[Definition:] the simple ur-type
definition, a special ·restriction· of the ·ur-type definition·, whose
name is anySimpleType in the XML Schema
namespace. The ·simple ur-type definition· is
considered to have an unconstrained lexical space, and a value
space consisting of the union of the value spaces of all the
built-in primitive datatypes and the set of all lists of all
members of the value spaces of all the
built-in primitive
datatypes.↓ ↑[Definition:] A
special ·restriction· of
·xs:anyType·, whose name is
anySimpleType in the
XSD namespace, is the root of the ·Type Definition Hierarchy· for all simple type
definitions. ·xs:anySimpleType· has a lexical space containing
all sequences of characters in the Universal Character
Set (UCS) and a value space containing all
atomic values
and all finite-length lists of
atomic values.
As with ·xs:anyType·, this
specification sometimes uses the qualified name
xs:anySimpleType to designate this type
definition.↑ ↑The
built-in list datatypes all have ·xs:anySimpleType· as their
·base type
definition·.↑
[Definition:] There is a further special datatype
called anyAtomicType, a
·restriction· of
·xs:anySimpleType·, which is the ·base type definition·
of all the primitive
datatypes. This type definition is often referred
to simply as "xs:anyAtomicType".
It too is
considered to have an unconstrained lexical space. Its value
space consists of the union of the value spaces of all the
primitive datatypes.
The mapping from lexical space to value space is unspecified
for items whose type definition is ↓the ·simple ur-type definition·↓↑·xs:anySimpleType·↑ ↑or ·xs:anyAtomicType·↑. Accordingly
this specification does not constrain processors'
behavio↓u↓r in areas
where this mapping is implicated, for example checking such
items against enumerations, constructing default attributes or
elements whose declared type definition is ↓the ·simple ur-type definition·↓↑·xs:anySimpleType·↑
↑or ·xs:anyAtomicType·↑,
checking identity constraints involving such items.
↓Simple types may also be
defined↓↑[XML Schema: Datatypes]
provides mechanisms for defining new simple type definitions
by ·restricting·
some primitive
or ordinary datatype. It also
provides mechanisms for constructing new simple type
definitions↑ whose members are lists of items
themselves constrained by some other simple type definition, or
whose membership is the union of the memberships of some other
simple type definitions. Such list and union simple type
definitions are also ·restrictions· of
↓the ·simple ur-type definition·↓↑·xs:anySimpleType·↑.
For detailed information on simple type definitions, see Simple Type Definitions (§3.16) and [XML Schema: Datatypes]. The latter also defines an extensive inventory of pre-defined simple types.
A complex type definition is a set of attribute declarations and a content type, applicable to the [attributes] and [children] of an element information item respectively. The content type ↓may↓↑may↑ require the [children] to contain neither element nor character information items (that is, to be empty), ↑or↑ to be a string which belongs to a particular simple type↑,↑ or to contain a sequence of element information items which conforms to a particular model group, with or without character information items as well.
xs:anyType·↑ is
either
all-groups in ways that do not
guarantee that the new material occurs only at the end of
the content.↑ Future versions may allow more kinds
of extension, requiring more complex transformations to
effect casting.For detailed information on complex type definitions, see Complex Type Definitions (§3.4).
There are three kinds of declaration component: element, attribute, and notation. Each is described in a section below. Also included is a discussion of element substitution groups, which is a feature provided in conjunction with element declarations.
An element declaration is an association of a name with a type definition, either simple or complex, an (optional) default value and a (possibly empty) set of identity-constraint definitions. The association is either global or scoped to a containing complex type definition. A top-level element declaration with name 'A' is broadly comparable to a pair of DTD declarations as follows, where the associated type definition fills in the ellipses:
<!ELEMENT A . . .> <!ATTLIST A . . .>
Element declarations contribute to ·validation· as part of model group ·validation·, when their defaults and type components are checked against an element information item with a matching name and namespace, and by triggering identity-constraint definition ·validation·.
For detailed information on element declarations, see Element Declarations (§3.3).
In XML↓ 1.0↓, the name and content of an element must correspond exactly to the element type referenced in the corresponding content model.
[Definition:] Through the new mechanism of element substitution groups, ↓XML Schemas↓↑XSD↑ provides a more powerful model supporting substitution of one named element for another. Any top-level element declaration can serve as the defining member, or head, for an element ↓substitution group↓↑·substitution group·↑. Other top-level element declarations, regardless of target namespace, can be designated as members of the ↓substitution group↓↑·substitution group·↑ headed by this element. In a suitably enabled content model, a reference to the head ·validates· not just the head itself, but elements corresponding to any other member of the ↓substitution group↓↑·substitution group·↑ as well.
All such members must have type definitions which are either the same as the head's type definition or ↓restrictions or extensions of↓↑derived from↑ it. Therefore, although the names of elements can vary widely as new namespaces and members of the ↓substitution group↓↑·substitution group·↑ are defined, the content of member elements is ↓strictly limited according to↓↑constrained by↑ the type definition of the ↓substitution group↓↑·substitution group·↑ head.
Note that element substitution groups are not represented as separate components. They are specified in the property values for element declarations (see Element Declarations (§3.3)).
An attribute declaration is an association between a name and a simple type definition, together with occurrence information and (optionally) a default value. The association is either global, or local to its containing complex type definition. Attribute declarations contribute to ·validation· as part of complex type definition ·validation·, when their occurrence, defaults and type components are checked against an attribute information item with a matching name and namespace.
For detailed information on attribute declarations, see Attribute Declarations (§3.2).
A notation declaration is an association between a name and
an identifier for a notation. For an attribute ↑or element↑ information item to
be ·valid· with respect to a
NOTATION simple type definition, its value must
have been declared with a notation declaration.
For detailed information on notation declarations, see Notation Declarations (§3.14).
The model group, particle, and wildcard components contribute to the portion of a complex type definition that controls an element information item's content.
A model group is a constraint in the form of a grammar fragment that applies to lists of element information items. It consists of a list of particles, i.e. element declarations, wildcards and model groups. There are three varieties of model group:
Each model group denotes a set of sequences of element information items. Regarding that set of sequences as a language, the set of sequences recognized by a group G may be written L(G). [Definition:] A model group G is said to accept or recognize the members of L(G).
For detailed information on model groups, see Model Groups (§3.8).
A particle is a term in the grammar for element content, consisting of either an element declaration, a wildcard or a model group, together with occurrence constraints. Particles contribute to ·validation· as part of complex type definition ·validation·, when they allow anywhere from zero to many element information items or sequences thereof, depending on their contents and occurrence constraints.
The name [Definition:] Term is used to refer to any of the three kinds of components which can appear in particles. All ·Terms· are themselves ·Annotated Components·. [Definition:] A basic term is an Element Declaration or a Wildcard. [Definition:] A basic particle is a Particle whose {term} is a ·basic term·.
Each content model, indeed each particle and each term, denotes a set of sequences of element information items. Regarding that set of sequences as a language, the set of sequences recognized by a particle P may be written L(P). [Definition:] A particle P is said to accept or recognize the members of L(P). Similarly, a term T accepts or recognizes the members of L(T).
If a sequence S is a member of L(P), then it is necessarily possible to trace a path through the ·basic particles· within P, with each item within S corresponding to a matching particle within P. The sequence of particles within P corresponding to S is called the ·path· of S in P.
For detailed information on particles, see Particles (§3.9).
An attribute use plays a role similar to that of a particle, but for attribute declarations: an attribute declaration within a complex type definition is embedded within an attribute use, which specifies whether the declaration requires or merely allows its attribute, and whether it has a default or fixed value.
A wildcard is a special kind of particle which matches element and attribute information items dependent on their namespace name↑s↑↓,↓ ↓independently of↓↑and optionally on↑ their local names.
For detailed information on wildcards, see Wildcards (§3.10).
An identity-constraint definition is an association between a name and one of several varieties of identity-constraint related to uniqueness and reference. All the varieties use ↓[XPath]↓↑[XPath 2.0]↑ expressions to pick out sets of information items relative to particular target element information items which are unique, or a key, or a ·valid· reference, within a specified scope. An element information item is only ·valid· with respect to an element declaration with identity-constraint definitions if those definitions are all satisfied for all the descendants of that element information item which they pick out.
For detailed information on identity-constraint definitions, see Identity-constraint Definitions (§3.11).
Note:
A type-alternative component (type alternative for short) associates a type definition with a predicate. Type alternatives are used in conditional type assignment, in which the choice of ·governing type definition· for elements governed by a particular element declaration depends on properties of the document instance. An element declaration may have a {type table} which contains a sequence of type alternatives; the predicates on the alternatives are tested, and when a predicate is satisfied, the type definition paired with it is chosen as the element instance's ·governing type definition·.
For detailed information on Type Alternatives, see Type Alternatives (§3.12).
An assertion is a predicate associated with a type, which is checked for each instance of the type. If an element or attribute information item fails to satisfy an assertion associated with a given type, then that information item is not locally ·valid· with respect to that type.
For detailed information on Assertions, see Assertions (§3.13).
Editorial Note: Priority Feedback Request
Assertions are currently only allowed to be specified in complex types. It may be deemed useful also to include assertions in named model group definitions and/or attribute groups, or even simple types. The XML Schema Working Group solicits input from implementors and users of this specification on this question.
There are two kinds of convenience definitions provided to enable the re-use of pieces of complex type definitions: model group definitions and attribute group definitions.
A model group definition is an association between a name and a model group, enabling re-use of the same model group in several complex type definitions.
For detailed information on model group definitions, see Model Group Definitions (§3.7).
An attribute group definition is an association between a name and a set of attribute declarations, enabling re-use of the same set in several complex type definitions.
For detailed information on attribute group definitions, see Attribute Group Definitions (§3.6).
An annotation is information for human and/or mechanical consumers. The interpretation of such information is not defined in this specification.
For detailed information on annotations, see Annotations (§3.15).
The [XML 1.1] specification describes two kinds of constraints on XML documents: well-formedness and validity constraints. Informally, the well-formedness constraints are those imposed by the definition of XML itself (such as the rules for the use of the < and > characters and the rules for proper nesting of elements), while validity constraints are the further constraints on document structure provided by a particular DTD.
The preceding section focused on ·validation·, that is the constraints on information items which schema components supply. In fact however this specification provides four different kinds of normative statements about schema components, their representations in XML and their contribution to the ·validation· of information items:
The last of these, schema information set contributions, are
not as new as they might at first seem. XML↓ 1.0↓ validation augments the XML↓ 1.0↓ information set in similar
ways, for example by providing values for attributes not present
in instances, and by implicitly exploiting type information for
normalization or access. (As an example of the latter case,
consider the effect of NMTOKENS on attribute white
space, and the semantics of ID and
IDREF.) By including schema information set
contributions, this specification makes explicit some features
that XML↓ 1.0↓ ↓left↓↑leaves↑ implicit.
Within the context of this specification, conformance can be claimed for schema documents, for schemas, and for processors.
This specification describes three levels of conformance for schema aware processors. The first is required of all processors. Support for the other two will depend on the application environments for which the processor is intended.
[Definition:] Minimally conforming processors must completely and correctly implement the ·Schema Component Constraints·, ·Validation Rules·, and ·Schema Information Set Contributions· contained in this specification.
[Definition:] ·Minimally conforming· processors which accept schemas represented in the form of XML documents as described in Layer 2: Schema Documents, Namespaces and Composition (§4.2) are additionally said to ↓provide conformance to the XML Representation of Schemas↓↑be schema-document aware↑. Such processors must, when processing schema documents, completely and correctly implement ↑(or enforce)↑ all ·Schema Representation Constraints· in this specification, and must adhere exactly to the specifications in Schema Component Details (§3) for mapping the contents of such documents to ·schema components· for use in ·validation· and ·assessment·.
[Definition:] A ·minimally conforming· processor which is not ·schema-document aware· is said to be a non-schema-document-aware processor.
[Definition:] ↓Fully conforming↓↑Web-aware↑ processors are network-enabled processors which are not only both ·minimally conforming· and ·↓in conformance to the XML Representation of Schemas↓↑schema-document aware↑·, but which additionally must be capable of accessing schema documents from the World Wide Web ↓according to↓↑as described in↑ Representation of Schemas on the World Wide Web (§2.7) and How schema definitions are located on the Web (§4.3.2). .
See Schemas and Namespaces: Access and Composition (§4) for a more detailed explanation of the mechanisms supporting these levels of conformance.
As discussed in ↓XML Schema↓↑XSD↑ Abstract Data Model (§2.2), most schema components (↓may↓↑may↑) have ·names·. If all such names were assigned from the same "pool", then it would be impossible to have, for example, a simple type definition and an element declaration both with the name "title" in a given ·target namespace·.
Therefore [Definition:] this specification introduces the term symbol space to denote a collection of names, each of which is unique with respect to the others. ↓A symbol space is similar to the non-normative concept of namespace partition introduced in [XML-Namespaces 1.1].↓ There is a single distinct symbol space within a given ·target namespace· for each kind of definition and declaration component identified in ↓XML Schema↓↑XSD↑ Abstract Data Model (§2.2), except that within a target namespace, simple type definitions and complex type definitions share a symbol space. Within a given symbol space, names ↓are↓↑must be↑ unique, but the same name may appear in more than one symbol space without conflict. For example, the same name can appear in both a type definition and an element declaration, without conflict or necessary relation between the two.
Locally scoped attribute and element declarations are special with regard to symbol spaces. Every complex type definition defines its own local attribute and element declaration symbol spaces, where these symbol spaces are distinct from each other and from any of the other symbol spaces. So, for example, two complex type definitions having the same target namespace can contain a local attribute declaration for the unqualified name "priority", or contain a local element declaration for the name "address", without conflict or necessary relation between the two.
The XML representation of schema
components uses a vocabulary identified by the namespace name
http://www.w3.org/2001/XMLSchema. For brevity, the text and examples in
this specification use the prefix xs: to stand for
this namespace; in practice, any prefix can be used.
Note:
Note:
XML Schema↑ Definition Language↑: Structures ↓also↓ defines
several attributes for direct use in any XML documents. ↓These attributes are in a different
namespace, which has the namespace name
http://www.w3.org/2001/XMLSchema-instance. For brevity, the text and
examples in this specification use the prefix xsi:
to stand for this latter namespace; in practice, any prefix can
be used.↓↑These
attributes are in the schema instance namespace
(http://www.w3.org/2001/XMLSchema-instance) described in The Schema Instance Namespace (xsi) (§1.3.1.2) above.↑ All schema processors
↑must↑
have appropriate attribute declarations for these attributes
built in, see Attribute Declaration for the 'type' attribute (§3.2.7.1),
Attribute Declaration for the 'nil' attribute (§3.2.7.2), Attribute Declaration for the 'schemaLocation' attribute (§3.2.7.3) and
Attribute Declaration for the 'noNamespaceSchemaLocation' attribute (§3.2.7.4).
xsi:type",
"xsi:nil", etc. This is shorthand for
"an attribute information item whose [namespace
name] is
http://www.w3.org/2001/XMLSchema-instance and whose [local
name] is type" (or
nil, etc.).
Users of the namespaces defined here should be aware, as a matter of namespace policy, that more names may be defined in these namespaces in future versions of this or other specifications.
The Simple Type Definition (§2.2.1.2) or Complex Type Definition (§2.2.1.3) used in ·validation· of an element is usually
determined by reference to the appropriate schema components. An
element information item in an instance may, however,
explicitly assert its type using the attribute
xsi:type. The value of this attribute is a ·QName·; see ↓QName Interpretation (§3.17.3.2)↓ ↑QName resolution (Instance) (§3.17.6.3)↑ for the means by which the ·QName· is associated with a type
definition.
XML Schema↑ Definition Language↑: Structures introduces a mechanism for signaling that an element
↓should↓↑must↑ be accepted as ·valid·
when it has no content despite a content type which does not
require or even necessarily allow empty content. An element
↓may be↓↑can be↑ ·valid·
without content if it has the attribute xsi:nil
with the value true. An element so labeled must
be empty, but can carry attributes if permitted by the
corresponding complex type.
The xsi:schemaLocation and
xsi:noNamespaceSchemaLocation attributes can be
used in a document to provide hints as to the physical location
of schema documents which ↓may↓↑can↑ be used for ·assessment·. See How schema definitions are located on the Web (§4.3.2) for details on the use of these
attributes.
On the World Wide Web, schemas are conventionally represented
as XML documents (preferably of MIME type
application/xml or text/xml, but see
clause 1.1 of Inclusion Constraints and Semantics (§4.2.2)),
conforming to the specifications in Layer 2: Schema Documents, Namespaces and Composition (§4.2). For
more information on the representation and use of schema
documents on the World Wide Web
see Standards for representation of schemas and retrieval of schema documents on the Web (§4.3.1) and
How schema definitions are located on the Web (§4.3.2).
Components are defined in terms of their properties, and each property in turn is defined by giving its range, that is the values it ↓may↓↑may↑ have. This can be understood as defining a schema as a labeled directed graph, where the root is a schema, every other vertex is a schema component or a literal (string, boolean, ↓number↓↑decimal↑) and every labeled edge is a property. The graph is not acyclic: multiple copies of components with the same name in the same ·symbol space· ↓may not↓↑must not↑ exist, so in some cases re-entrant chains of properties ↓must↓↑will↑ exist. Equality of components for the purposes of this specification is always defined as equality of names (including target namespaces) within symbol spaces.
Component properties are simply named values. Most properties have either other components or literals (that is, strings or booleans or enumerated keywords) for values, but in a few cases, where more complex values are involved, [Definition:] a property value may itself be a collection of named values, which we call a property record.
[Definition:] Throughout this specification, the term absent is used as a distinguished property value denoting absence.↑ Again this should not be interpreting as constraining implementations, as for instance between using a null value for such properties or not representing them at all.↑ ↑[Definition:] A property value which is not ·absent· is present.↑
Any property ↓not identified as optional is required to be present↓↑not defined as optional is always present↑; optional properties which are not present are taken to have ·absent· as their value. Any property identified as a having a set, subset or list value ↓may↓↑might↑ have an empty value unless this is explicitly ruled out: this is not the same as ·absent·. Any property value identified as a superset or subset of some set ↓may↓↑might↑ be equal to that set, unless a proper superset or subset is explicitly called for. By 'string' in Part 1 of this specification is meant a sequence of ISO 10646 characters identified as legal XML characters in [XML 1.1].
The principal purpose of XML Schema↑ Definition Language↑: Structures is to define a set of schema
components that constrain the contents of instances and augment
the information sets thereof. Although no external
representation of schemas is required for this purpose, such
representations will obviously be widely used. To provide for
this in an appropriate and interoperable way, this specification
provides a normative XML representation for schemas which makes
provision for every kind of schema component. [Definition:] A document in this
form (i.e. a <schema> element information item)
is a schema document. For the schema
document as a whole, and its constituents, the sections below
define correspondences between element information items (with
declarations in
Schema for ↓Schemas↓↑Schema Documents (Structures)↑ (normative) (§A) and DTD for Schemas (non-normative) (§L)) and schema components. ↓All the↓↑The key↑ element information items in
the XML representation of a schema ↓must be↓↑are↑ in the ↓XML Schema↓↑XSD↑ namespace, that
is their [namespace
name] ↓must
be↓↑is↑
http://www.w3.org/2001/XMLSchema. Although a common way of creating
the XML Infosets which are or contain ·schema documents· will be
using an XML parser, this is not required: any mechanism which
constructs conformant infosets as defined in [XML-Infoset] is a possible starting
point.
A recurrent pattern in the XML
representation of schemas may also be mentioned here. In many
cases, the same element name (e.g. element or
attribute or attributeGroup), serves
both to define a particular schema component and to incorporate
it by reference. In the first case the name
attribute is required, in the second the ref
attribute is required. These
two usages are mutually exclusive, and sometimes also depend on
context.
The descriptions of the XML representation of components, and the ·Schema Representation Constraints·, apply to schema documents after, not before, the conditional-inclusion pre-processing described in Conditional inclusion (§4.2.1).
For each kind of schema component there is a corresponding normative XML representation. The sections below describe the correspondences between the properties of each kind of schema component on the one hand and the properties of information items in that XML representation on the other, together with constraints on that representation above and beyond those ↓implicit↓↑expressed↑ in the Schema for ↓Schemas↓↑Schema Documents (Structures)↑ (normative) (§A).
The language used is as if the correspondences were mappings from XML representation to schema component, but the mapping in the other direction, and therefore the correspondence in the abstract, can always be constructed therefrom.
In discussing the mapping from XML representations to schema components below, the value of a component property is often determined by the value of an attribute information item, one of the [attributes] of an element information item. Since schema documents are constrained by the Schema for ↓Schemas↓↑Schema Documents (Structures)↑ (normative) (§A), there is always a simple type definition associated with any such attribute information item. [Definition:] ↓ The phrase actual value is used to refer to the member of the value space of the simple type definition associated with an attribute information item which corresponds to its ·normalized value·↓↑With reference to any string, interpreted as denoting an instance of a given datatype, the term actual value denotes the value to which the lexical mapping of that datatype maps the string. ↑ ↓.↓↑In the case of attributes in schema documents, the string used as the lexical representation is normally the ·normalized value· of the attribute. The associated datatype is, unless otherwise specified, the one identified in the declaration of the attribute, in the schema for schema documents; in some cases (e.g. the enumeration facet, or fixed and default values for elements and attributes) the associated datatype will be a more specific one, as specified in the appropriate XML mapping rules. The ·actual value·↑ ↓This↓ will often be a string, but ↓may↓↑can↑ also be an integer, a boolean, a URI reference, etc. This term is also occasionally used with respect to element or attribute information items in a document being ·validated·.
Many properties are identified below as having other schema components or sets of components as values. For the purposes of exposition, the definitions in this section assume that (unless the property is explicitly identified as optional) all such values are in fact present. When schema components are constructed from XML representations involving reference by name to other components, this assumption ↓may↓↑will in some cases↑ be violated if one or more references cannot be ↓resolved↓↑·resolved·↑. This specification addresses the matter of missing components in a uniform manner, described in Missing Sub-components (§5.3): no mention of handling missing components will be found in the individual component descriptions below.
Forward reference to named definitions and declarations is allowed, both within and between ·schema documents·. By the time the component corresponding to an XML representation which contains a forward reference is actually needed for ·validation·↑, it is possible that↑ an appropriately-named component ↓may↓↑will↑ have become available to discharge the reference: see Schemas and Namespaces: Access and Composition (§4) for details.
Throughout this specification, [Definition:] the initial value of some attribute information item is the value of the [normalized value] property of that item. Similarly, the initial value of an element information item is the string composed of, in order, the [character code] of each character information item in the [children] of that element information item.
The above definition means that comments and processing instructions, even in the midst of text, are ignored for all ·validation· purposes.
#x9 (tab),
#xA (line feed) and #xD (carriage
return) are replaced with #x20
(space).#x20s are collapsed to a single
#x20, and initial and/or final
#x20s are deleted.When more than one pre-lexical facet applies, the whiteSpace facet is applied first; the order in which ·implementation-defined· facets are applied is ·implementation-defined·.
If the simple type definition used in an item's
·validation· is ↓the ·simple ur-type definition·↓↑·xs:anySimpleType·↑,
↑then ↑the
·normalized value· must be determined
as in the preserve case above.
There are three alternative validation rules which ↓may↓↑help↑ supply the necessary background for the above: Attribute Locally Valid (§3.2.4.1) (clause 3), Element Locally Valid (Type) (§3.3.4.4) (clause 3.1.3) or Element Locally Valid (Complex Type) (§3.4.4.2) (clause 2.2).
These three levels of normalization correspond to the processing mandated in XML↓ 1.0↓ for element content, CDATA attribute content and tokenized attributed content, respectively. See Attribute Value Normalization in [XML 1.1] for the precedent for replace and collapse for attributes. Extending this processing to element content is necessary to ensure ↓a↓ consistent ·validation· semantics for simple types, regardless of whether they are applied to attributes or elements. Performing it twice in the case of attributes whose [normalized value] has already been subject to replacement or collapse on the basis of information in a DTD is necessary to ensure consistent treatment of attributes regardless of the extent to which DTD-based information has been made use of during infoset construction.
Attribute declarations provide for:
<xs:attribute name="age" type="xs:positiveInteger" use="required"/>
The attribute declaration schema component has the following properties:
The {name} property must match the local part of the names of attributes being ·validated·.
The value of ↓the↓ ↑each↑ attribute ↑validated↑ must conform to the supplied {type definition}.
A ↓non-·absent·↓↑·non-absent·↑ value of the {target namespace} property provides for ·validation· of namespace-qualified attribute information items (which must be explicitly prefixed in the character-level form of XML documents). ·Absent· values of {target namespace} ·validate· unqualified (unprefixed) items.
A {scope} of global identifies attribute declarations available for use in complex type definitions throughout the schema. Locally scoped declarations are available for use only within the complex type definition identified by the {scope} property. This property is ·absent· in the case of declarations within attribute group definitions: their scope will be determined when they are used in the construction of complex type definitions.
For an attribute declaration A, if A.{scope}.{variety} = global, then A is available for use throughout the schema. If A.{scope}.{variety} = local, then A is available for use only within (the Complex Type Definition or Attribute Group Definition) A.{scope}.{parent}.
↑The↑
{value constraint} ↑property↑ reproduces the functions of
XML↓ 1.0↓ default and
#FIXED attribute values. ↑A {variety} of
↑default specifies that the attribute is to
appear unconditionally in the ·post-schema-validation infoset·, with ↓the supplied value↓↑{value} and {lexical form}↑ used whenever the attribute is not
actually present; fixed indicates that the attribute
value if present must ↓equal the
supplied constraint value↓↑be equal to {value}↑, and if absent receives ↓the supplied value↓↑{value} and {lexical form}↑ as for default. Note that
it is values that are ↓supplied and/or ↓checked, not
strings↑,
and that the test is for equality, not identity↑.
See Annotations (§3.15) for information on the role of the {annotations} property.
[XML-Infoset] distinguishes attributes with names such as xmlns or xmlns:xsl from
ordinary attributes, identifying them as [namespace attributes]. Accordingly, it is unnecessary and in fact not possible for
schemas to contain attribute declarations corresponding to such
namespace declarations, see xmlns Not Allowed (§3.2.6.3). No means is provided in
this specification to supply a
default value for a namespace declaration.
The XML representation for an attribute declaration schema component is an <attribute> element information item. It specifies a simple type definition for an attribute either by reference or explicitly, and ↓may↓↑may↑ provide default information. The correspondences between the properties of the information item and properties of the component are ↓as follows:↓↑given in this section.↑
Attribute declarations can appear at the top level of a schema
document, or within complex type definitions, either as complete
(local) declarations, or by reference to top-level declarations,
or within attribute group definitions. For complete
declarations, top-level or local, the type
attribute is used when the declaration can use a built-in or
pre-declared simple type definition. Otherwise an anonymous
<simpleType> is provided inline. ↑When no simple type definition is
referenced or provided, the default is ·xs:anySimpleType·, which
imposes no constraints at all.↑
The default when no simple type definition is referenced or provided is the ·simple ur-type definition·, which imposes no constraints at all.
attribute Element Information Item<attribute
default = string
fixed = string
form = (qualified | unqualified)
id = ID
name = NCName
ref = QName
targetNamespace = anyURI
type = QName
use = (optional | prohibited | required) : optional
{any attributes with non-schema namespace . . .}>
Content: (annotation?, simpleType?)
</attribute>
Editorial Note: Priority Feedback Request
Earlier versions of this specification did not
allow a targetNamespace attribute on attribute
declarations; it has been added in this version to make
restriction of complex types easier. The XML Schema Working Group
has designated the targetNamespace attribute
a ‘feature at risk’: it may be dropped from future
drafts of this specification if implementation or usage experience
shows that its costs outweigh its benefits.
The XML Schema Working Group solicits input from implementors and
users of this specification as to whether the addition of this
attribute is desirable and acceptable.
Attribute information items ·validated· by a top-level
declaration must be qualified with the
{target namespace} of that
declaration↓ (if this is ·absent·, the item must be
unqualified).↓↑. If the
{target namespace} is ·absent·, the item must be
unqualified.↑ Control over whether attribute
information items ·validated· by a local declaration must be
similarly qualified or not is provided by the form
[attribute], whose default is provided by the
attributeFormDefault [attribute] on the enclosing
<schema>, via its determination of
{target namespace}.
The names for top-level attribute declarations are in their own ·symbol space·. The names of locally-scoped attribute declarations reside in symbol spaces local to the type definition which contains them.
ref [attribute] is
absent, and the use [attribute] is not
"prohibited", then it maps both to
an Attribute Declaration and to an Attribute Use
component, as described in
Mapping Rules for Local Attribute Declarations (§3.2.2.2).
ref [attribute] is
·present·, and the use [attribute] is not
"prohibited", then it maps to
an Attribute Use
component, as described in
Mapping Rules for References to Top-level Attribute Declarations (§3.2.2.3).
use='prohibited', then it does not map to,
or correspond to, any schema component at all.
use attribute is not allowed on
top-level <attribute> elements, so
this can only happen with <attribute> elements
appearing within a <complexType>
or <attributeGroup> element.
If the <attribute> element information item has <schema> as its parent, the corresponding schema component is as follows:
targetNamespace [attribute] of the parent
<schema> element information item, or ·absent· if there is none.type [attribute], if present, otherwise
↓the ·simple ur-type definition·↓↑·xs:anySimpleType·↑.default or a fixed [attribute],
then ↓a pair consisting
of↓↑a Value Constraint as follows↑, otherwise ·absent·.
↓otherwise if↓↑If↑
the <attribute> element information item has
<complexType> or <attributeGroup> as
an ancestor and the ref [attribute] is absent,
it ↓corresponds↓↑maps↑ ↑both to an attribute
declaration (see below) and↑
to an attribute use with properties as follows
(unless use='prohibited', in which case the item
corresponds to nothing at all):
use
[attribute] is present with ·actual value·
required↓↑the
<attribute> element has use =
required↑, otherwise
false.default or a fixed [attribute],
then a ↓pair consisting of
↓↑Value Constraint
as follows↑, otherwise ·absent·.
The <attribute> element also maps to the {attribute declaration} of the attribute use just described, as follows:
form is present and its ·actual value· is
qualified, or if form is absent and
the ·actual value· of attributeFormDefault on the
<schema> ancestor is qualified, then the
·actual value· of the targetNamespace [attribute] of
the parent
<schema> element information item, or ·absent· if there is none, otherwise
·absent·.targetNamespace is present
, then
its ·actual value·.
targetNamespace is not present and
one of the following is trueform
= qualified
form is absent and the <schema> ancestor has
attributeFormDefault =
qualified
targetNamespace
[attribute] of the ancestor <schema>
element information
item, or ·absent· if there
is none.
type [attribute], if present, otherwise
↓the ·simple ur-type definition·↓↑·xs:anySimpleType·↑.
↓otherwise (↓↑If
↑the
<attribute> element information item has
<complexType> or <attributeGroup> as an
ancestor and the ref [attribute] is
present↓)↓, it
↓corresponds↓↑maps↑ to an attribute use with properties as follows
(unless use='prohibited', in which case the item
corresponds to nothing at all):
use [attribute] is
present with ·actual value· required↓↑use =
required↑, otherwise
false.default or a fixed [attribute],
then a ↓pair consisting of
↓↑Value Constraint
as follows↑, otherwise ·absent·.
default and fixed must not both be present.default and use are both present,
use must have the ·actual value· optional.ref or name ↓must be↓↑is↑ present, but not both.ref is present, then all of <simpleType>,
form and type ↓must be↓↑are↑ absent.type ↑attribute↑ and ↑a↑
<simpleType> ↑child element↑
must not both be present.targetNamespace attribute
is present then
all of the following
↓must↓↑must↑
be true:name attribute
is present.
form attribute
is absent.
targetNamespace [attribute] or its ·actual value·
is different from the ·actual value· of targetNamespace of
<attribute>, then
all of the following are true:base [attribute] of
<restriction> does not
·match· the
name of ·xs:anyType·.
Informally, an attribute in an XML
instance is locally ·valid·
against an attribute declaration if and only if (a)
the name of the attribute matches
the name of the declaration, (b) after
whitespace normalization its ·normalized value· is locally valid
against the type declared for the attribute, and
(c) the
attribute obeys any relevant value constraint. Additionally,
for xsi:type, it is required that the type named
by the attribute be present in the schema.
A logical prerequisite for checking the local validity of an
attribute against an attribute declaration is that the attribute
declaration itself and the type definition it identifies
both be present in the schema.
Note:
Local validity of attributes is tested as part of schema-validity ·assessment· of attributes (and of the elements on which they occur), and the result of the test is exposed in the [validity] property of the ·post-schema-validation infoset·.
A more formal statement is given in the following constraint.
xsi:type
(Attribute Declaration for the 'type' attribute (§3.2.7.1)), then A's ·actual value·
·resolves· to a type definition.
[Definition:] The governing type definition of an attribute, in a given schema-validity ·assessment· episode, is the {type definition} of the ·governing attribute declaration·, unless the processor has stipulated another type definition at the start of ·assessment· (see Assessing Schema-Validity (§5.2)), in which case it is the stipulated type definition.
Schema-validity assessment of an attribute information item involves identifying its ·governing attribute declaration· and checking its local validity against the declaration. If the ·governing type definition· is not present in the schema, then assessment is necessarily incomplete.
[Definition:] For attribute↑ information item↑s, there is no difference between assessment and strict assessment, so ↓if the above holds,↓ the attribute information item has been strictly assessed↑ if and only if its schema-validity has been assessed↑.
See also Attribute Default Value (§3.4.5.1), Match Information (§3.4.5.2) and Schema Information (§3.17.5.1), which describe other information set contributions related to attribute information items.
All attribute declarations (see Attribute Declarations (§3.2)) must satisfy the following constraints.
xsi: Not Allowedhttp://www.w3.org/2001/XMLSchema-instance
(unless it is one of the four built-in declarations given in the next section).xsi:type or xsi:nil, which would be
seriously misleading, as they would have no effect.↓xsi: attributes to specify default or fixed value
constraints (e.g. in a component corresponding to a schema document construct
of the form <xs:attribute ref="xsi:type" default="xs:integer"/>),
but the practice is not recommended; including such attribute uses will tend
to mislead readers of the schema document, because the attribute uses would
have no effect; see Element Locally Valid (Complex Type) (§3.4.4.2) and
Attribute Default Value (§3.4.5.1) for details.There are four attribute declarations present in every schema by definition:
The xsi:type attribute
is used to signal use of a type other than the declared type of
an element. See xsi:type (§2.6.1).
typehttp://www.w3.org/2001/XMLSchema-instanceThe xsi:nil attribute
is used to signal that an element's content is "nil"
(or "null"). See xsi:nil (§2.6.2).
nilhttp://www.w3.org/2001/XMLSchema-instanceThe xsi:schemaLocation attribute
is used to signal possible locations of relevant schema documents.
See xsi:schemaLocation, xsi:noNamespaceSchemaLocation (§2.6.3).
schemaLocationhttp://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2001/XMLSchema-instancexs:anySimpleType·↑The xsi:noNamespaceSchemaLocation attribute
is used to signal possible locations of relevant schema documents.
See xsi:schemaLocation, xsi:noNamespaceSchemaLocation (§2.6.3).
noNamespaceSchemaLocationhttp://www.w3.org/2001/XMLSchema-instanceElement declarations provide for:
<xs:element name="PurchaseOrder" type="PurchaseOrderType"/> <xs:element name="gift"> <xs:complexType> <xs:sequence> <xs:element name="birthday" type="xs:date"/> <xs:element ref="PurchaseOrder"/> </xs:sequence> </xs:complexType> </xs:element>
The element declaration schema component has the following properties:
The {name} property must match the local part of the names of element information items being ·validated·.
A {scope} of global identifies element declarations available for use in content models throughout the schema. Locally scoped declarations are available for use only within the complex type identified by the {scope} property. This property is ·absent· in the case of declarations within named model groups: their scope will be determined when they are used in the construction of complex type definitions.
For an element declaration E, if E.{scope}.{variety} = global, then E is available for use throughout the schema. If E.{scope}.{variety} = local, then E is available for use only within (the Complex Type Definition or Model Group Definition) E.{scope}.{parent}.
A ↓non-·absent·↓↑·non-absent·↑ value of the {target namespace} property provides for ·validation· of namespace-qualified element information items. ·Absent· values of {target namespace} ·validate· unqualified items.
An element information item is ↓·valid· if it
satisfies↓↑normally
required to satisfy↑ the {type definition}. For such an
item, schema information set
contributions appropriate to the {type definition} are added to the
corresponding element information
item in the ·post-schema-validation infoset·. ↑ The type
definition against which an element information item is
validated (its
·governing type definition·) can be different from the
declared {type definition}. The {type table} property of an Element Declaration, which governs conditional type assignment, and
the xsi:type attribute of an element information item
(see xsi:type (§2.6.1)) can cause the ·governing type definition· and the
declared {type definition} to be different. ↑
If {nillable} is true, then
an element ↑with no text or element
content↑ ↓may↓↑can↑ ↓also↓ be ·valid·
↓if it
carries the namespace qualified attribute with [local
name] nil from namespace
http://www.w3.org/2001/XMLSchema-instance and value true
(see xsi:nil (§2.6.2)) even if it has no text or
element content↓ despite a ↓{content type}↓
↑{type definition}↑
which would otherwise require
content↑, if it carries the
attribute xsi:nil with the value
true (see xsi:nil (§2.6.2))↑.
Formal details of element ·validation· are described in
Element Locally Valid (Element) (§3.3.4.3).
xsi:nil = true. {value constraint} establishes a default or fixed value for an element. If ↑a {value constraint} with {variety} = ↑default is ↓specified↓↑present↑, and if the element being ·validated· is empty, then ↓the canonical form of the supplied constraint value becomes the [schema normalized value] of the ·validated· element in the ·post-schema-validation infoset·.↓ ↑the element is treated as if {value constraint}.{lexical form} was used as the content of the element.↑ If fixed is specified, then the element's content must either be empty, in which case fixed behaves as default, or its value must ↓match↓↑be equal to↑ ↓the↓ ↓supplied constraint value↓↑{value constraint}.{value}↑.
{identity-constraint definitions} express constraints establishing uniquenesses and reference relationships among the values of related elements and attributes. See Identity-constraint Definitions (§3.11).
Element declarations are potential members of the ↓substitution group↓↑·substitution groups·↑, if any, identified by ↓{substitution group affiliation}↓↑{substitution group affiliations}↑. Potential membership is transitive but not symmetric; an element declaration is a potential member of any group of which ↑any entry in↑ its ↓{substitution group affiliation}↓↑{substitution group affiliations}↑ is a potential member. Actual membership ↓may↓↑may↑ be blocked by the effects of {substitution group exclusions} or {disallowed substitutions}, see below.
An empty {substitution group exclusions} allows a declaration to be ↓nominated as↓↑named in↑ the ↓{substitution group affiliation}↓↑{substitution group affiliations}↑ of other element declarations having the same ↑declared ↑{type definition} or ↓types↓↑some type↑ derived therefrom. The explicit values of {substitution group exclusions}↑, extension or restriction,↑ rule out element declarations having types ↓which are extensions or restrictions respectively of {type definition}↓↑whose derivation from {type definition} involves any extension steps, or restriction steps, respectively↑ . ↓If both values are specified, then the declaration must not be nominated as the {substitution group affiliation} of any other declaration.↓
The supplied values for {disallowed substitutions} determine whether an element declaration appearing in a ·content model· will be prevented from additionally ·validating· elements (a) with an xsi:type (§2.6.1) that identifies an extension or restriction of the type of the declared element, and/or (b) from ·validating· elements which are in the ↓substitution group↓↑·substitution group·↑ headed by the declared element. If {disallowed substitutions} is empty, then all derived types and ↓substitution group↓↑·substitution group·↑ members are allowed.
Element declarations for which {abstract} is true can appear in content models only when substitution is allowed; such declarations ↓may not↓↑must not↑ themselves ever be used to ·validate· element content.
See Annotations (§3.15) for information on the role of the {annotations} property.
The XML representation for an element declaration schema component is an <element> element information item. It specifies a type definition for an element either by reference or explicitly, and ↓may↓↑may↑ provide occurrence and default information. The correspondences between the properties of the information item and properties of the component(s) it corresponds to are ↓as follows:↓↑given in this section.↑
element Element Information Item<element
abstract = boolean : false
block =
(#all | List of (extension | restriction | substitution))
default = string
final =
(#all | List of (extension | restriction))
fixed = string
form = (qualified | unqualified)
id = ID
maxOccurs =
(nonNegativeInteger | unbounded)
: 1
minOccurs = nonNegativeInteger : 1
name = NCName
nillable = boolean : false
ref = QName
substitutionGroup = List of QName
targetNamespace = anyURI
type = QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, ((simpleType | complexType)?, alternative*, (unique | key | keyref)*))
</element>
Editorial Note: Priority Feedback Request
Earlier versions of this specification did not
allow a targetNamespace attribute on element
declarations; it has been added in this version to make
restriction of complex types easier. The XML Schema Working Group
has designated the targetNamespace attribute
a ‘feature at risk’: it may be dropped from future
drafts of this specification if implementation or usage experience
shows that its costs outweigh its benefits.
The XML Schema Working Group solicits input from implementors and
users of this specification as to whether the addition of this
attribute is desirable and acceptable.
<element> corresponds to an element declaration, and allows the type definition of that declaration to be specified either by reference or by explicit inclusion.
<element>s within <schema> produce
global element declarations; <element>s within <group> or <complexType> produce either particles which contain global element declarations (if there's a ref attribute) or local declarations (otherwise). For complete declarations, top-level or local, the type attribute is used when the declaration can use a
built-in or pre-declared type definition. Otherwise an
anonymous <simpleType> or <complexType> is provided inline.
Element information items ·validated· by a top-level
declaration must be qualified with the
{target namespace} of that
declaration↓ (if this is ·absent·,
the item must be unqualified).↓↑.
If the
{target namespace} is ·absent·,
the item must be unqualified.↑
Control over whether element information items ·validated· by a local declaration must be similarly qualified or not
is provided by the form [attribute], whose default is provided
by the elementFormDefault [attribute] on the enclosing <schema>, via its determination of {target namespace}.
As noted above the names for top-level element declarations are in a separate ·symbol space· from the symbol spaces for the names of type definitions, so there can (but need not be) a simple or complex type definition with the same name as a top-level element. As with attribute names, the names of locally-scoped element declarations with no {target namespace} reside in symbol spaces local to the type definition which contains them.
Note that the above allows for two levels of defaulting for unspecified
type definitions. An <element> with no referenced or included type definition will
correspond to an element declaration which has
↓the
same type definition as the
head of its substitution group if it identifies
one,
↓
↑the
same type definition as the first
substitution-group head named in the
substitutionGroup [attribute], if present,↑
otherwise ↓the ·ur-type definition·↓↑·xs:anyType·↑.
This has the important consequence that the minimum valid element declaration,
that is, one with only a name attribute and no contents,
is also (nearly) the most general, validating any combination of text and
element content and allowing any attributes, and providing for recursive
validation where possible.
See below at XML Representation of Identity-constraint Definition Schema Components (§3.11.2) for <key>, <unique> and <keyref>.
ref [attribute] is absent,
and it does not have minOccurs=maxOccurs=0,
then it maps both to a Particle, as described
in Mapping Rules for Local Element Declarations (§3.3.2.3), and also to an
Element Declaration, using the mappings described in
Common Mapping Rules for Element Declarations (§3.3.2.1) and
Mapping Rules for Local Element Declarations (§3.3.2.3).
ref [attribute] is present,
and it does not have minOccurs=maxOccurs=0,
then it maps to a Particle
as described in References to Top-Level Element Declarations (§3.3.2.4).minOccurs=maxOccurs=0,
then it maps to no component at all.minOccurs and maxOccurs
attributes are not allowed on top-level
<element> elements, so in valid schema
documents this will happen only when the <element> element information item has
<complexType> or <group> as an
ancestor.
The following mapping rules apply in all cases where an <element> element maps to an Element Declaration component.
type [attribute],
otherwise the {type definition} of the element declaration
·resolved· to by the ·actual value· of the
substitutionGroup [attribute], if
present, otherwise the ·ur-type definition·.↓
↑The first of the following
that applies:↑
type [attribute], if it is present.
substitutionGroup [attribute], if present.
xs:anyType·.
test [attribute].
test
[attribute], then a Type Alternative corresponding to the <alternative>.test) a Type Alternative with the following properties: default or a fixed [attribute],
then ↓a pair consisting
of↓↑a Value Constraint as follows↑, otherwise ·absent·. substitutionGroup
[attribute], if present, otherwise ·absent·.substitutionGroup [attribute], if present,
otherwise the empty set.block
[attribute], if present, otherwise on the ·actual value· of the
blockDefault [attribute] of the ancestor
<schema> element information item, if present,
otherwise on the empty string. Call this the
EBV (for effective block value). Then the
value of this property is
the appropriate case among the following:#all, then {extension,
restriction,
substitution};blockDefault [attribute] of
<schema> ↓may↓↑may↑ include values other than
extension, restriction or
substitution, those values are ignored in the
determination of {disallowed substitutions} for element
declarations (they are used elsewhere).final and finalDefault
[attributes] in place of the block and
blockDefault [attributes] and with the relevant
set being {extension,
restriction}.If the <element> element information item has <schema> as its parent, ↓the corresponding schema component is as follows:↓↑it maps to an Element Declaration, using the mapping given in Common Mapping Rules for Element Declarations (§3.3.2.1), supplemented by the following.↑
targetNamespace [attribute] of the parent
<schema> element information item, or ·absent· if there is none.
↓otherwise
if↓↑If↑
the <element> element information
item has
<complexType> or <group> as
an ancestor↑,↑
and the ref [attribute] is absent,
↑and it does not have
minOccurs=maxOccurs=0,↑
↓the
corresponding schema components are as follows (unless
minOccurs=maxOccurs=0, in which case the item
corresponds to no component at all):↓
↑then it maps both to a
Particle and to a local
Element Declaration which is the {term}
of that Particle. The Particle
is as follows:↑
maxOccurs [attribute] equals
unbounded, otherwise the ·actual value· of the
maxOccurs [attribute], if present, otherwise
1.↓An↓↑The <element> element also maps to an↑ element declaration↓ as in the first case above, with the exception of its {target namespace} and {scope} properties, which are as below:↓↑ using the mapping rules given in Common Mapping Rules for Element Declarations (§3.3.2.1), supplemented by those below:↑
form is present
and its ·actual value· is qualified, or if form is
absent and the ·actual value· of
elementFormDefault on the <schema>
ancestor is qualified, then the
·actual value· of the targetNamespace [attribute] of
the parent
<schema> element information item, or ·absent· if there is none, otherwise
·absent·.targetNamespace is present
, then
its ·actual value·.
targetNamespace is not present and
one of the following is trueform
= qualified
form is absent and the <schema>
ancestor
has elementFormDefault =
qualified
targetNamespace [attribute]
of the ancestor <schema> element
information item,
or ·absent· if there is
none.
↓otherwise
(the↓↑If the↑
<element> element information
item has
<complexType> or <group> as an
ancestor↑,↑
and the ref [attribute] is
present↓)↓,
↑and it does not have
minOccurs=maxOccurs=0,↑
↓the corresponding
schema component is as follows (unless
minOccurs=maxOccurs=0, in which case the item
corresponds to no component at all):↓
↑then it maps to
a Particle as follows.↑
maxOccurs [attribute] equals
unbounded, otherwise the ·actual value· of the
maxOccurs [attribute], if present, otherwise
1.<xs:element name="unconstrained"/> <xs:element name="emptyElt"> <xs:complexType> <xs:attribute ...>. . .</xs:attribute> </xs:complexType> </xs:element> <xs:element name="contextOne"> <xs:complexType> <xs:sequence> <xs:element name="myLocalElement" type="myFirstType"/> <xs:element ref="globalElement"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="contextTwo"> <xs:complexType> <xs:sequence> <xs:element name="myLocalElement" type="mySecondType"/> <xs:element ref="globalElement"/> </xs:sequence> </xs:complexType> </xs:element>
xs:anyType·↑
The second uses an embedded anonymous complex
type definition.myLocalElement within
contextOne will be constrained by myFirstType,
while those within contextTwo will be constrained by
mySecondType. <xs:complexType name="facet">
<xs:complexContent>
<xs:extension base="xs:annotated">
<xs:attribute name="value" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="facet" type="xs:facet" abstract="true"/>
<xs:element name="encoding" substitutionGroup="xs:facet">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="xs:facet">
<xs:sequence>
<xs:element ref="annotation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="value" type="xs:encodings"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="period" substitutionGroup="xs:facet">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="xs:facet">
<xs:sequence>
<xs:element ref="annotation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="value" type="xs:duration"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="datatype">
<xs:sequence>
<xs:element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NCName" use="optional"/>
. . .
</xs:complexType>
facet type is defined
and the facet element is declared to use it. The facet element is abstract -- it's
only defined to stand as the head for a ↓substitution group↓↑·substitution group·↑. Two further
elements are declared, each a member of the facet ↓substitution group↓↑·substitution group·↑. Finally a type is defined which refers to facet, thereby
allowing either period or encoding (or
any other member of the group).message element will be
assigned either to type messageType or to a more
specific type derived from it.
messageType accepts any well-formed XML
or character sequence as content, and carries a kind
attribute which can be used to describe the kind or format of
the message. The value of kind is either one of a
few well known keywords or, failing that, any string.<xs:complexType name="messageType" mixed="true">
<xs:sequence>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="kind">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="string"/>
<xs:enumeration value="base64"/>
<xs:enumeration value="binary"/>
<xs:enumeration value="xml"/>
<xs:enumeration value="XML"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
<xs:anyAttribute processContents="skip"/>
</xs:complexType>
messageType are defined, each
corresponding to one of the three well-known formats:
messageTypeString for kind="string",
messageTypeBase64 for kind="base64"
and kind="binary", and
messageTypeXML for kind="xml" or
kind="XML".
<xs:complexType name="messageTypeString">
<xs:simpleContent>
<xs:restriction base="messageType">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="messageTypeBase64">
<xs:simpleContent>
<xs:restriction base="messageType">
<xs:simpleType>
<xs:restriction base="xs:base64Binary"/>
</xs:simpleType>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="messageTypeXML">
<xs:complexContent>
<xs:restriction base="messageType">
<xs:sequence>
<xs:any processContents="strict"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
message element itself uses
messageType both as its declared type and
as its default type, and uses test attributes on its
<alternative> [children] to assign the appropriate
specialized message type to messages with the well known
values for the kind attribute:<xs:element name="message" type="messageType"> <xs:alternative test="@kind='string'" type="messageTypeString"/> <xs:alternative test="@kind='base64'" type="messageTypeBase64"/> <xs:alternative test="@kind='binary'" type="messageTypeBase64"/> <xs:alternative test="@kind='xml'" type="messageTypeXML"/> <xs:alternative test="@kind='XML'" type="messageTypeXML"/> </xs:element>
default and fixed
↓must not both be↓↑are not
both↑ present.ref or name ↓must be↓↑is↑ present, but not both.ref is present, then all of <complexType>,
<simpleType>, <key>, <keyref>,
<unique>, nillable, default,
fixed, form, block and type
↓must be↓↑are↑ absent,
i.e. only minOccurs, maxOccurs, id
↑and <annotation>↑ are
allowed ↓in addition
to↓↑to appear together with↑
ref↓, along with <annotation>↓.type attribute.targetNamespace is present then
all of the following
↓must be↓↑are↑
true:name is present.
form is not present.
targetNamespace [attribute] or its ·actual value·
is different from the ·actual value· of targetNamespace of
<element>, then
all of the following are true:base [attribute] of
<restriction> does not
·match· the
name of ·xs:anyType·.
test [attribute]; the last
<alternative> element may have such an [attribute].↑When an element is ·assessed·, it is first checked against its ·governing element declaration·, if any; this in turn entails checking it against its ·governing type definition·. The second step is recursive: the element's [attributes] and [children] are ·assessed· in turn with respect to the declarations assigned to them by their parent's ·governing type definition·.
The ·governing type definition· of an element is normally the declared {type definition} associated with the ·governing element declaration·, but this may be ·overridden· using conditional type assignment in the Element Declaration or using an ·instance-specified type definition·, or both. When the element is declared with conditional type assignment, the ·selected type definition· is used as the ·governing type definition· unless ·overridden· by an ·instance-specified type definition·.
xs:error·.[Definition:] If the set of keywords controlling whether a type S is ·validly substitutable· for another type T is the empty set, then S is said to be validly substitutable for T without limitation or absolutely. The phrase validly substitutable, without mention of any set of blocking keywords, means "validly substitutable without limitation".
Sometimes one type S is ·validly substitutable· for another type T only if S is derived from T by a chain of restrictions, or if T is a union type and S a member type of the union. The concept of ·valid substitutability· is appealed to often enough in such contexts that it is convenient to define a term to cover this specific case. [Definition:] A type definition S is validly substitutable as a restriction for another type T if and only if S is ·validly substitutable· for T, subject to the blocking keywords {extension, list, union}.
The concept of local validity of an element information item against an element declaration is an important part of the schema-validity ·assessment· of elements. (The other important part is the recursive ·assessment· of attributes and descendant elements.) Local validity partially determines the element information item's [validity] property, and fully determines the [local element validity] property, in the ·post-schema-validation infoset·.
xsi:nil attribute on the element obeys the
rules. The element is allowed to have an xsi:nil
attribute only if the element is declared nillable, and
xsi:nil = 'true' is allowed only if the element
itself is empty. If the element declaration specifies a
fixed value for the element, xsi:nil='true'
will make the element invalid.
xsi:type attribute present names a
type which is ·validly substitutable· for the element's
declared {type definition}.Note:
The following validation rule gives the normative formal definition of local validity of an element against an element declaration.
http://www.w3.org/2001/XMLSchema-instance and whose [local
name] is nil.true
, then
all of the following must be true:xsi:nil attribute.xsi:nil
attribute information item.xsi:nil = false.xsi:nil
= true
(that is, E is ·nilled·), and
all of the following are true:http://www.w3.org/2001/XMLSchema-instance and whose [local
name] is type, then
all of the following
↓must be↓↑are↑
true:xsi:type attribute, then
all of the following
↓must be↓↑are↑
true:Note:
xsi:type attribute whose
value does not ·resolve· to a type definition,
or if
the type definition fails to ·override· the ·selected type definition·, then the ·selected type definition· of its
·governing element declaration· becomes the ·governing type definition·. The local validity of the element
with respect to the ·governing type definition· is recorded in the
[local type validity]
property.The following validation rule specifies formally what it means for an element to be locally valid against a type definition. This concept is appealed to in the course of checking an element's local validity against its element declaration, but it is also part of schema-validity ·assessment· of an element when there is no