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 © 2011 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
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 member-only review version which will in due course be published as a↑ W3C Proposed Recommendation ↓specifies↓ ↑specifying↑ the W3C XML Schema Definition Language (XSD) 1.1. It ↑has no formal standing within W3C; it↑ is here made available for review by W3C members↓ and the public↓. 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. ↑ This draft was created on 1 March 2011. It reflects (unless otherwise noted elsewhere) all decisions on this document made by the Working Group through 4 February 2011. The document thus incorporates all decisions made by the Working Group to date. ↑
xsi:type attributes
and their effect has been clarified in
Element Locally Valid (Element) (§3.3.4.3). In particular, the
revisions attempt to make clearer just what happens
in cases where the xsi:type
attribute in the document instance cannot be used
(because the type named is unknown, or otherwise
not usable). This resolves issue 11219 Editorial revision of Element Locally Valid (Element).
inheritable attribute of
the xs:attribute element
(resolving issue
11070
DTD for schema documents: inheritable declared as %URIref).
xs:group within the named model group xs:allModel
has been corrected to make the type of xs:all a legal
restriction of its base type and make the schema for schema documents
conformant to this specification. This resolves issue
11092
Error in S4SD: complexType name="all" is not a valid restriction.For those primarily interested in the changes since version 1.0, the appendix Changes since version 1.0 (non-normative) (§G) 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.
The Last Call review period for this document extends until 31 December 2009. 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 is a "feature at risk": the feature may be retained as is or dropped, depending on the feedback received from readers, schema authors, schema users, and implementors.
Publication as a ↓Proposed Recommendation↓↑Editors' 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 XSD 1.1 are discussed in the document Requirements for XML Schema 1.1. 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-b11179.xml. Three kinds of changes are highlighted:
↑new, added text↑,
↑changed text↓, and
↓deleted text↓.
1 Introduction
1.1 Introduction to Version 1.1
1.2 Purpose
1.3 Namespaces and Language Identifiers
A Schema for Schema Documents (Structures) (normative)
B Outcome Tabulations (normative)
B.1 Validation Rules
B.2 Contributions to the post-schema-validation infoset
B.3 Schema Representation Constraints
B.4 Schema Component Constraints
C Terminology for implementation-defined features (normative)
C.1 Subset of the Post-schema-validation Infoset
C.2
Terminology of schema construction
Within the context of this specification, conformance can be claimed for schema documents, for schemas, and for processors.
A schema conforms to this specification if and only if it consists of components which individually and collectively satisfy all the relevant constraints specified in this document, including but not limited to all the ·Schema Component Constraints·.
This specification distinguishes several classes of conforming processors, which are defined in terms of the following concepts.
[Definition:] A validator (or instance validator) is a processor which ·validates· an XML instance document against a conforming schema and distinguishes between valid documents and others, for one or more of the definitions of validity (·root-validity·, ·deep validity·, or ·uniform validity·) defined below in section Schema-validity and documents (§2.5). Conforming validators may additionally support other definitions of validity defined in terms of the ·post-schema-validation infoset·.
[Definition:] A schema-validity assessor (or just assessor) is a processor which performs full or partial ·schema-validity assessment· of an XML instance document, element information item, or attribute information item, with reference to a conforming schema, and provides access to the entirety of the resulting ·post-schema-validation infoset·. The means by which an ·assessor· provides access to the ·post-schema-validation infoset· is ·implementation-defined·.
[Definition:] A general-purpose processor is a ·validator· or ·assessor· which accepts schemas represented in the form of XML documents as described in Layer 2: Schema Documents, Namespaces and Composition (§4.2).
<override>) (§4.2.5), and the
·chameleon pre-processing·
described in Assembling a schema for a single target namespace from
multiple schema definition documents
(<include>) (§4.2.3)↑.
[Definition:] A schema processor which is not a ·general-purpose· processor is a special-purpose processor.
[Definition:] Web-aware processors are network-enabled processors which are not only ·general-purpose· but which additionally must be capable of accessing schema documents from the World Wide Web as described in Representation of Schemas on the World Wide Web (§2.8) and How schema definitions are located on the Web (§4.3.2). .
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 Schema Documents (Structures) (normative) (§A) and DTD for Schemas (non-normative) (§J)) and schema components. The key element information items in
the XML representation of a schema are in the XSD namespace, that
is their [namespace
name] 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↓↑·conditional-inclusion pre-processing·↑
described in Conditional inclusion (§4.2.2)↑,
the ·override pre-processing· described
in Overriding component definitions (<override>) (§4.2.5), and the
·chameleon pre-processing·
described in Assembling a schema for a single target namespace from
multiple schema definition documents
(<include>) (§4.2.3)↑.
Attribute declarations provide for:
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 provide default information. The correspondences between the properties of the information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component are 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 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 provide occurrence and default information. The correspondences between the properties of the information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component(s) it corresponds to are 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>
...
The XML representation for a complex type definition schema component is a <complexType> element information item.
The XML representation for complex type definitions with a {content type} with {variety} simple is significantly different from that of those with other {content type}s, and this is reflected in the presentation below, which describes the mappings for the two cases in separate subsections. Common mapping rules are factored out and given in separate sections. ↑As always, the mapping rules given here apply after, not before, the appropriate ·pre-processing·.↑
complexType Element Information Item<complexType
abstract = boolean : false
block =
(#all | List of (extension | restriction))
final =
(#all | List of (extension | restriction))
id = ID
mixed = boolean
name = NCName
defaultAttributesApply = boolean : true
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (simpleContent | complexContent | (openContent?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), assert*)))
</complexType>
<complexType name="anyThing"/> is allowed.
...
The XML representation for an attribute group definition schema component is an <attributeGroup> element information item. It provides for naming a group of attribute declarations and an attribute wildcard for use by reference in the XML representation of complex type definitions and other attribute group definitions. The correspondences between the properties of the information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component it corresponds to are given in this section.
attributeGroup Element Information Item<attributeGroup
id = ID
name = NCName
ref = QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
</attributeGroup>
The XML representation for a model group definition schema component is a <group> element information item. It provides for naming a model group for use by reference in the XML representation of complex type definitions and model groups. The correspondences between the properties of the information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component it corresponds to are given in this section.
group Element Information Item<group
id = ID
maxOccurs =
(nonNegativeInteger | unbounded)
: 1
minOccurs = nonNegativeInteger : 1
name = NCName
ref = QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (all | choice | sequence)?)
</group>
The XML representation for a model group schema component is either an <all>, a <choice> or a <sequence> element information item. The correspondences between the properties of those information items ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component they correspond to are given in this section.
all Element Information Item et al.<all
id = ID
maxOccurs = 1 : 1
minOccurs = (0 | 1) : 1
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (element | any | group)*)
</all>
<choice
id = ID
maxOccurs =
(nonNegativeInteger | unbounded)
: 1
minOccurs = nonNegativeInteger : 1
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (element | group | choice | sequence | any)*)
</choice>
<sequence
id = ID
maxOccurs =
(nonNegativeInteger | unbounded)
: 1
minOccurs = nonNegativeInteger : 1
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (element | group | choice | sequence | any)*)
</sequence>
...
The XML representation for a wildcard schema component is an <any> or <anyAttribute> element information item.
any Element Information Item<any
id = ID
maxOccurs =
(nonNegativeInteger | unbounded)
: 1
minOccurs = nonNegativeInteger : 1
namespace =
((##any | ##other) | List of
(anyURI | (##targetNamespace | ##local))
)
notNamespace = List of
(anyURI | (##targetNamespace | ##local))
notQName = List of
(QName | (##defined | ##definedSibling))
processContents = (lax | skip | strict) : strict
{any attributes with non-schema namespace . . .}>
Content: (annotation?)
</any>
anyAttribute Element Information Item<anyAttribute
id = ID
namespace =
((##any | ##other) | List of
(anyURI | (##targetNamespace | ##local))
)
notNamespace = List of
(anyURI | (##targetNamespace | ##local))
notQName = List of
(QName | ##defined)
processContents = (lax | skip | strict) : strict
{any attributes with non-schema namespace . . .}>
Content: (annotation?)
</anyAttribute>
An <any> information item
corresponds both to a wildcard component and to
a particle containing that wildcard
(unless minOccurs=maxOccurs=0, in which case the
item corresponds to no component at
all).
The mapping rules are given in the following two subsections.
↑As always, the mapping rules
given here apply after, not before, the appropriate
·pre-processing·.↑
...
The XML representation for an identity-constraint definition schema component is either a <key>, a <keyref> or a <unique> element information item. The correspondences between the properties of those information items ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component they correspond to are as follows:
unique Element Information Item et al.<unique
id = ID
name = NCName
ref = QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (selector, field+)?)
</unique>
<key
id = ID
name = NCName
ref = QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (selector, field+)?)
</key>
<keyref
id = ID
name = NCName
ref = QName
refer = QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (selector, field+)?)
</keyref>
<selector
id = ID
xpath = a subset of XPath expression, see below
xpathDefaultNamespace =
(anyURI | (##defaultNamespace | ##targetNamespace | ##local))
{any attributes with non-schema namespace . . .}>
Content: (annotation?)
</selector>
<field
id = ID
xpath = a subset of XPath expression, see below
xpathDefaultNamespace =
(anyURI | (##defaultNamespace | ##targetNamespace | ##local))
{any attributes with non-schema namespace . . .}>
Content: (annotation?)
</field>
Type Alternative components provide associations between boolean conditions (as XPath expressions) and Type Definitions. They are used in conditional type assignment.
The XML representation for a type alternative schema component is an <alternative> element information item. The correspondences between the properties of that information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component it corresponds to are as follows:
alternative Element Information Item<alternative
id = ID
test = an XPath expression
type = QName
xpathDefaultNamespace =
(anyURI | (##defaultNamespace | ##targetNamespace | ##local))
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (simpleType | complexType)?)
</alternative>
Each <alternative> element maps to a Type Alternative component as follows.
test [attribute] is not present, then ·absent·;
otherwise an XPath Expression property record, as described in
section
XML Representation of Assertion Schema Components (§3.13.2), with
<alternative> as the "host element"
and test as the designated expression [attribute].
type
[attribute], if one is present, otherwise the type definition corresponding
to the complexType or simpleType among the
[children] of the <alternative> element.
Assertion components constrain the existence and values of related elements and attributes.
The XML representation for an assertion schema component is an <assert> element information item. The correspondences between the properties of that information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component it corresponds to are as follows:
assert Element Information Item<assert
id = ID
test = an XPath expression
xpathDefaultNamespace =
(anyURI | (##defaultNamespace | ##targetNamespace | ##local))
{any attributes with non-schema namespace . . .}>
Content: (annotation?)
</assert>
The XML representation for a notation declaration schema component is a <notation> element information item. The correspondences between the properties of that information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component it corresponds to are as follows:
Annotations provide for human- and machine-targeted annotations of schema components.
Annotation of schemas and schema components, with material for human or computer consumption, is provided for by allowing application information and human information at the beginning of most major schema elements, and anywhere at the top level of schemas. The XML representation for an annotation schema component is an <annotation> element information item. The correspondences between the properties of that information item ↑after the appropriate ·pre-processing·↑ and ↑the↑ properties of the component it corresponds to are as follows:
annotation Element Information Item et al.<annotation
id = ID
{any attributes with non-schema namespace . . .}>
Content: (appinfo | documentation)*
</annotation>
<appinfo
source = anyURI
{any attributes with non-schema namespace . . .}>
Content: ({any})*
</appinfo>
<documentation
source = anyURI
xml:lang = language
{any attributes with non-schema namespace . . .}>
Content: ({any})*
</documentation>
As always, the mapping rules given in this section apply after, not before, the appropriate ·pre-processing·.
simpleType Element Information Item et al.<simpleType
final =
(#all | List of (list | union | restriction | extension))
id = ID
name = NCName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (restriction | list | union))
</simpleType>
<restriction
base = QName
id = ID
{any attributes with non-schema namespace . . .}>
Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | maxScale | minScale | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion | explicitTimezone | {any with namespace: ##other})*))
</restriction>
<list
id = ID
itemType = QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, simpleType?)
</list>
<union
id = ID
memberTypes = List of QName
{any attributes with non-schema namespace . . .}>
Content: (annotation?, simpleType*)
</union>
...
A schema consists of a set of schema components.
A schema is represented in XML by one or more ·schema documents·, that is, one or more <schema> element information items. A ·schema document· contains representations for a collection of schema components, e.g. type definitions and element declarations, which have a common {target namespace}. A ·schema document· which has one or more <import> element information items corresponds to a schema with components with more than one {target namespace}, see Import Constraints and Semantics (§4.2.6.2).
As always, the mapping rules given in this section apply after, not before, the appropriate ·pre-processing·.
schema Element Information Item et al.<schema
attributeFormDefault = (qualified | unqualified) : unqualified
blockDefault =
(#all | List of (extension | restriction | substitution))
: ''
defaultAttributes = QName
xpathDefaultNamespace =
(anyURI | (##defaultNamespace | ##targetNamespace | ##local))
: ##local
elementFormDefault = (qualified | unqualified) : unqualified
finalDefault =
(#all | List of (extension | restriction | list | union))
: ''
id = ID
targetNamespace = anyURI
version = token
xml:lang = language
{any attributes with non-schema namespace . . .}>
Content: ((include | import | redefine | override | annotation)*, (defaultOpenContent, annotation*)?, ((simpleType | complexType | group | attributeGroup | element | attribute | notation), annotation*)*)
</schema>
<defaultOpenContent
appliesToEmpty = boolean : false
id = ID
mode = (interleave | suffix) : interleave
{any attributes with non-schema namespace . . .}>
Content: (annotation?, any)
</defaultOpenContent>