W3C

XML Schema 1.1 Part 1: Structures

W3C Working Draft 31 August 2006

This version:
http://www.w3.org/TR/2006/WD-xmlschema11-1-20060831/
Latest version:
http://www.w3.org/TR/xmlschema11-1/
Previous versions:
http://www.w3.org/TR/2006/WD-xmlschema11-1-20060330/ http://www.w3.org/TR/2005/WD-xmlschema11-1-20050224/ http://www.w3.org/TR/2004/WD-xmlschema11-1-20040716/
Editors:
Henry S. Thompson, University of Edinburgh <ht@inf.ed.ac.uk>
C. M. Sperberg-McQueen, World Wide Web Consortium <cmsmcq@w3.org>
Shudi (Sandy) Gao 高殊镝, IBM <sandygao@ca.ibm.com>
Noah Mendelsohn, IBM <noah_mendelsohn@us.ibm.com>
David Beech, Oracle Corporation (retired) <davidbeech@earthlink.net>
Murray Maloney, Muzmo Communications <murray@muzmo.com>

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.


Abstract

XML Schema: Structures specifies the 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 XML 1.0 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 1.1 Part 2: Datatypes.

Status of this Document

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 Public Working Draft of XML Schema 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.

This draft was published on 31 August 2006. The major changes since the previous draft are:

For those primarily interested in the changes since version 1.0, the Changes since version 1.0 (§G) 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. 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).

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.

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 1.1 are discussed in the 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. Changes which have Working Group consensus are marked thus: new, added text, changed text, and deleted text. Other changes, which do not now have Working Group consensus, are marked this way: tentative additions, changes, and deletions.


Table of Contents

1 Introduction
    1.1 Introduction to Version 1.1
    1.2 Purpose
    1.3 Dependencies on Other Specifications
    1.4 Documentation Conventions and Terminology
2 Conceptual Framework
    2.1 Overview of XML Schema
    2.2 XML Schema Abstract Data Model
    2.3 Constraints and Validation Rules
    2.4 Conformance
    2.5 Names and Symbol Spaces
    2.6 Schema-Related Markup in Documents Being Validated
    2.7 Representation of Schemas on the World Wide Web
3 Schema Component Details
    3.1 Introduction
    3.2 Attribute Declarations
    3.3 Element Declarations
    3.4 Complex Type Definitions
    3.5 AttributeUses
    3.6 Attribute Group Definitions
    3.7 Model Group Definitions
    3.8 Model Groups
    3.9 Particles
    3.10 Wildcards
    3.11 Identity-constraint Definitions
    3.12 Assertions
    3.13 Notation Declarations
    3.14 Annotations
    3.15 Simple Type Definitions
    3.16 Schemas as a Whole
4 Schemas and Namespaces: Access and Composition
    4.1 Layer 1: Summary of the Schema-validity Assessment Core
    4.2 Layer 2: Schema Documents, Namespaces and Composition
    4.3 Layer 3: Schema Document Access and Web-interoperability
5 Schemas and Schema-validity Assessment
    5.1 Errors in Schema Construction and Structure
    5.2 Assessing Schema-Validity
    5.3 Missing Sub-components
    5.4 Responsibilities of Schema-aware Processors

Appendices

A Schema for SchemasSchema Documents (Structures) (normative)
B References (normative)
C Outcome Tabulations (normative)
    C.1 Validation Rules
    C.2 Contributions to the post-schema-validation infoset
    C.3 Schema Representation Constraints
    C.4 Schema Component Constraints
D Terminology for implementation-defined features
    D.1 Subset of the Post-schema-validation Infoset
    D.2 Terminology of schema construction
E Required Information Set Items and Properties (normative)
F Checklist of implementation-defined features
G Changes since version 1.0
    G.1 Changes already made
    G.2 Outstanding issues
H Implementing 'actually restricts'
I Checking content-type restriction
J Schema Components Diagram (non-normative)
K Glossary (non-normative)
L DTD for Schemas (non-normative)
M Analysis of the Unique Particle Attribution Constraint (non-normative)
N References (non-normative)
O Acknowledgements (non-normative)


1 Introduction

This document sets out the structural part (XML Schema: Structures) of the XML Schema definition language.

Chapter 2 presents a Conceptual Framework (§2) for XML Schemas, including an introduction to the nature of XML Schemas and an introduction to the XML Schema 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 XML Schema for an XML Schema 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 SchemasSchema 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.

next sub-section1.1 Introduction to Version 1.1

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:

  1. Support for versioning (acknowledging that this may be slightly disruptive to the XML transfer syntax at the margins)
  2. Support for co-occurrence constraints (which will certainly involve additions to the XML transfer syntax, which will not be understood by 1.0 processors)
  3. Bug fixes (unless in specific cases we decide that the fix is too disruptive for a point release)
  4. Editorial changes
  5. Design cleanup will possibly change behavior in edge cases
  6. Non-disruptive changes to type hierarchy (to better support current and forthcoming international standards and W3C recommendations)
  7. Design cleanup will possibly change component structure (changes to functionality restricted to edge cases)
  8. No significant changes in existing functionality
  9. No changes to XML transfer syntax except those required by version control hooks, co-occurrence constraints and bug fixes

The aim with regard to compatibility is that

previous sub-section next sub-section1.3 Dependencies on Other Specifications

The definition of XML Schema: 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.

Note:  Implementations may provide the heuristic of using the 1.1 datatypes if the input is labeled as XML 1.1, and the 1.0 datatypes if the input is labeled 1.0. It should be noted however that the XML version number is not required to be present in the input to an assessment episode, and in any case the heuristic should be subject to override by users, to support cases where users wish to accept XML 1.1 input but validate it using the 1.0 datatypes, or accept XML 1.0 input and validate it using the 1.1 datatypes.
Note:  Some users will perhaps wish to accept only XML 1.1 input, or only XML 1.0 input. Conforming implementations of this specification which accept XML input may accept XML 1.0, XML 1.1, or both and may provide user control over which versions of XML to accept.

previous sub-section 1.4 Documentation Conventions and Terminology

The section introduces the highlighting and typography as used in this document to present technical material.

All such issues are tabulated in Outstanding issues (§G.2).

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:

Example
<schema targetNamespace="http://www.example.com/XMLSchema/1.0/mySchema">
And an explanation of the example.

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:

Schema Component: Example
{example property}
A Component component. Required.

An example property

References to properties of schema components are links to the relevant definition as exemplified above, set off with curly braces, for instance {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 which of several different components may arise, 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.

Note: The illustrations are derived automatically from the Schema for SchemasSchema Documents (Structures) (normative) (§A). In the case of apparent conflict, the Schema for SchemasSchema Documents (Structures) (normative) (§A) takes precedence, as it, together with the ·Schema Representation Constraints·, provide the normative statement of the form of XML representations.
XML Representation Summary: example Element Information Item

<example
  count = integer
  size = (large | medium | small) : medium>
  Content: (all | any*)
</example>

Example Schema Component
Property
Representation
 
Description of what the property corresponds to, e.g. the value of the size [attribute]
 

References to elements in the text are links to the relevant illustration as exemplified above, set off with angle brackets, for instance <example>.

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:

PSVI Contributions for example information items
[new property]
The value the property gets.

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 following highlighting is used for non-normative commentary in this document:

Note: General comments directed to all readers.

Following [XML 1.1], wWithin normative prose in this specification, the words may and, should, must and must not are defined as follows:

may
Conforming documents and XML Schema-aware processors are permitted to but need not behave as described.
should
It is recommended that conforming documents and XML Schema-aware processors behave as described, but there can be valid reasons for them not to; it is important that the full implications be understood and carefully weighed before adopting behavior at variance with the recommendation.
must
Conforming documents and XML Schema-aware processors are required to behave as described; otherwise they are in error.
must not
Conforming documents and XML Schema-aware processors are forbidden to behave as described; if they do they are in error.

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].

Note however that thisThis specification provides a definition of error and of conformant processors' responsibilities with respect to errors (seein Schemas and Schema-validity Assessment (§5)) which is considerably more complex than that of [XML 1.1].

2 Conceptual Framework

This chapter gives an overview of XML Schema: 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 read [XML Schema: Primer] for a tutorial introduction, and only then consult the sub-sections of Schema Component Details (§3) named XML Representation of ... for the details.

next sub-section2.1 Overview of XML Schema

An XML Schema consistsis 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 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.

Issue (RQ-142i): Issue 2846 (RQ-142 PSVI properties), Issue 2822 (RQ-144 required properties)

Version 1.0 included several properties in the PSVI whose absence carried information (e.g. [type definition]), while at the same time not being completely clear about which PSVI properties, if any, were required. The Working Group intends to eliminate the former and clarify the latter.

Resolution:

For 142, which mandates that insofar as possible absence of a property should not in general signify, when it does explicit 'if-and-only-if' language is required, the effect is distributed throughout the PSVI sub-sub-sections in section 3.

The Working Group appears to be close to consensus (although no final decision has been made) on views which can be summarized thus:

  1. We should eliminate any dependency on the absence of specific properties (i.e. important situations should be describable and distinguishable in terms of properties and their values, without appeal to the absence of particular properties), or if this proves unfeasible in particular cases we should say explicitly that a property is present "if and only if" certain conditions apply. Any remaining "if" (if any) would be a true conditional, not an equivalence.
  2. Any specification of a class of processors (including ours) can require specific additional information not in the PSVI, though should note that interoperability is better if applications depend only on the properties present in the PSVI as we define it.
  3. In our own specification of processor classes, we should be explicit that processors may provide additional information. (Or alternatively be explicit that they must not -- but the chair believes the WG consensus was to allow it.)

For 144, a few general remarks here about flexible-but-firm conformance are wanted here; most of the new work should end up in section 4 and/or 5.

Schema-validity assessment has two aspects:

1 Determining local schema-validity, that is whether an element or attribute information item satisfies the constraints embodied in the relevant components of an XML Schema;
2 Synthesizing an overall validation outcome for the item, combining local schema-validity with the results of schema-validity assessments of its descendants, if any, and adding appropriate augmentations to the infoset to record this outcome.

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.

previous sub-section next sub-section2.2 XML Schema Abstract Data Model

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 can be described in terms of an abstract data model. In defining XML Schemas in terms of an abstract data model, this specification rigorously specifies the information which must be available to a conforming XML Schema 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 the abstract data model of the schema. [Definition:]   An XML Schema is a set of ·schema components·. There are 1314 kinds of component in all, falling into three groups. The primary components, which may (type definitions) or must (element and attribute declarations) have names, are as follows:

  • Simple type definitions
  • Complex type definitions
  • Attribute declarations
  • Element declarations

The secondary components, which must have names, are as follows:

  • Attribute group definitions
  • Identity-constraint definitions
  • Assertions
  • Model group definitions
  • Notation declarations

Finally, the "helper" components provide small parts of other components; they are not independent of their context:

  • Annotations
  • Model groups
  • Particles
  • Wildcards
  • Attribute Uses

The name [Definition:]  Component covers all the different kinds of 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 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·.

Note: At the abstract level, there is no requirement that the components of a schema share a ·target namespace·. Any schema for use in ·assessment· of documents containing names from more than one namespace will of necessity include components with different ·target namespaces·. This contrasts with the situation at the level of the XML representation of components, in which each schema document contributes definitions and declarations to a single target namespace.

·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· 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·.

2.2.1 Type Definition Components

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.

2.2.1.1 Type Definition Hierarchy

[Definition:]  Except for a distinguished ·ur-type definition·, 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:]  AThe 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 A type defined by appropriate use of facets or declarations so as to validate a subset of what another type definition validates, with consistent PSVI outcomes, is a restriction of the other type. The specific restrictionsadded 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 members of type B as well.

Issue (RQ-17i):Issue 2820 (RQ-17 simplify restriction rules)

Version 1.0 made clear that the intention for derivation by restriction was that restrictions validated a subset of what their base validated. However, the constructive rules for what constituted valid content model restrictions for complex type definition not only failed to enforce this completely correctly, but also ruled out various cases which evidently should have been allowed. The Working Group has decided to shift to a much higher level statement of what constitutes a valid restriction, appealing directly to the subset requirement, in order to address these problems.

Resolution:

A major change in definition/presentation, with only modest changes in consequences for schemas and validity, will be made, by defining restriction for complex type definitions in terms of the desired result, that is that all members of a restricted type are members of its base type. In the normative part of the spec. this will be done by appeal to local validity.

"Clarifying: R restricts B: any EII that is locally valid [per R] must also be locally valid [per B], with side conditions on properties on terms you appeal to [to] get same child allowed by two content models." [-F2F 2004-03-12, section Subsumption (W3C-member-only link)]

A non-normative appendix will provide references to published algorithms for enforcing the constraint.

[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 anyTyperootType 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 further special complex type definition, whose name is anyType in the XML Schema namespace, is also present in each ·XML Schema·. The definition of anyType serves as default type definition for element declarations whose XML representation does not specify one.

[Definition:]  A type definition used as the basis for an ·extension· or ·restriction· is known as the base type definition of that definition.

2.2.1.2 Simple Type 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 simpleits ·base type definition·. For the built-in primitive type definitions, this is [Definition:]  theThe simple ur-type definition, a special ·restriction· of the ·ur-type definition·, whose name is anySimpleType in the XML Schema namespace is the root of the ·Type Definition Hierarchy· for the simple type definitions. 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. The built-in list datatypes all have the ·simple ur-type definition· as their ·base type definition·.

[Definition:]  There is a further special datatype called anyAtomicType, a ·restriction· of the ·simple ur-type definition·, which is the ·base type definition· of all the primitive built-in datatypes. It too is considered to have an unconstrained lexical space. Its value space consists of the union of the value spaces of all the built-in primitive datatypes.

The mapping from lexical space to value space is unspecified for items whose type definition is the ·simple ur-type definition·or ·anyAtomicType·. Accordingly this specification does not constrain processors' behaviour 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·, checking identity constraints involving such items.

Note: The Working Group expects to return to this area in a future version of this specification.

Simple types may also be defined[XML Schema: Datatypes] provides mechanisms for defining new simple type definitions by ·restricting· one of the built-in primitive or ordinary datatypes. 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·.

For detailed information on simple type definitions, see Simple Type Definitions (§3.15) and [XML Schema: Datatypes]. The latter also defines an extensive inventory of pre-defined simple types.

2.2.1.3 Complex Type Definition

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 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.

Each complex type definition other than the ·ur-type definition· is either

or

A complex type which extends another does so by having additional content model particles at the end of the other definition's content model, or by having additional attribute declarations, or both.

Note: This specification allows only appending, and not other kinds of extensions. This decision simplifies application processing required to cast instances from derived to base type. 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).

2.2.2 Declaration Components

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.

2.2.2.2 Element Substitution Group

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 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. Other top-level element declarations, regardless of target namespace, can be designated as members of the 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 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 it. Therefore, although the names of elements can vary widely as new namespaces and members of the substitution group are defined, the content of member elements is strictly limited according to the type definition of the 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)).

2.2.2.4 Notation Declaration

A notation declaration is an association between a name and an identifier for a notation. For an attribute 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.13).

2.2.3 Model Group Components

The model group, particle, and wildcard components contribute to the portion of a complex type definition that controls an element information item's content.

2.2.3.2 Particle

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·.

[Definition:]  A particle can be used in a complex type definition to constrain the ·validation· of the [children] of an element information item; such a particle is called a content model.

Note: XML Schema: Structures ·content models· are similar to but more expressive than [XML 1.1] content models; unlike [XML 1.1], XML Schema: Structures applies ·content models· to the ·validation· of both mixed and element-only content.

Each content model, indeed each particle, 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).

Note: The language accepted by a content model plays a role in determining whether an element information item is locally valid or not: if the appropriate content model does not accept the sequence of elements among its children, then the element information item is not locally valid. (Some additional constraints must also be met: not every sequence in L(P) is locally valid against P. See Principles of Validation against Groups (§3.8.4.2).)

No assumption is made, in the definition above, that the items in the sequence are themselves valid; only the expanded names of the items in the sequence are relevant in determining whether the sequence is accepted by a particle. Their validity does affect whether their parent is (recursively) valid as well as locally valid.

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.

Note: This ·path· has nothing to do with [XPath] or XPath expressions. When there may otherwise be danger of confusion, the ·path· described here may be referred to as the ·match path· of S in P.

For detailed information on particles, see Particles (§3.9).

2.2.4 Identity-constraint DefinitionConstraint Components

2.2.4.1 Identity-constraint Definition

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] 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:  Identity constraints currently uses XPath 1.0. This may change in future working drafts of this specification to use XPath 2.0. Such change will not affect evaluation of identity constraints, given the XPath subset it uses.
2.2.4.2 Assertion

An assertion is a predicate associated with a type, which is checked for each instance of the type. Depending on their formulation, assertions are either required to be true of the instance, or required to be false. 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.12).

Note:  Assertions are currently only allowed to be specified in complex types. It may be deemed useful to also include assertions in named model group definitions and/or attribute groups, or even simple types, if proved useful.

previous sub-section next sub-section2.3 Constraints and Validation Rules

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:

Schema Component Constraint
[Definition:]  Constraints on the schema components themselves, i.e. conditions components must satisfy to be components at all. Located in the sixth sub-section of the per-component sections of Schema Component Details (§3) and tabulated in Schema Component Constraints (§C.4).
Schema Representation Constraint
[Definition:]  Constraints on the representation of schema components in XML beyond those which are expressed in Schema for SchemasSchema Documents (Structures) (normative) (§A). Located in the third sub-section of the per-component sections of Schema Component Details (§3) and tabulated in Schema Representation Constraints (§C.3).
Validation Rules
[Definition:]  Contributions to ·validation· associated with schema components. Located in the fourth sub-section of the per-component sections of Schema Component Details (§3) and tabulated in Validation Rules (§C.1).
Schema Information Set Contribution
[Definition:]  Augmentations to ·post-schema-validation infoset·s expressed by schema components, which follow as a consequence of ·validation· and/or ·assessment·. Located in the fifth sub-section of the per-component sections of Schema Component Details (§3) and tabulated in Contributions to the post-schema-validation infoset (§C.2).

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 leftleaves implicit.

previous sub-section next sub-section2.4 Conformance

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 Schemasbe schema-document aware. Such processors must, when processing schema documents, completely and correctly implement 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.

Note: By separating the conformance requirements relating to the concrete syntax of XML schema documents, this specification admits processors which use schemas stored in optimized binary representations, dynamically created schemas represented as programming language data structures, or implementations in which particular schemas are compiled into executable code such as C or Java. Such processors can be said to be ·minimally conforming· but not necessarily in ·conformance to the XML Representation of Schemas··schema-document aware·.

[Definition:]  Fully conformingWeb-aware processors are network-enabled processors which are not only both ·minimally conforming· and ·in conformance to the XML Representation of Schemasschema-document aware·, but which additionally must be capable of accessing schema documents from the World Wide Web according toas described in Representation of Schemas on the World Wide Web (§2.7) and How schema definitions are located on the Web (§4.3.2). .

Note: In version 1.0 of this specification the class of ·schema-document aware· processors was termed "conformant to the XML Representation of Schemas". Similarly, the class of ·Web-aware· processors was called "fully conforming".
Note: Although this specification provides just these three standard levels of conformance, it is anticipated that other conventions can be established in the future. For example, the World Wide Web Consortium is considering conventions for packaging on the Web a variety of resources relating to individual documents and namespaces. Should such developments lead to new conventions for representing schemas, or for accessing them on the Web, new levels of conformance can be established and named at that time. There is no need to modify or republish this specification to define such additional levels of conformance.

See Schemas and Namespaces: Access and Composition (§4) for a more detailed explanation of the mechanisms supporting these levels of conformance.

previous sub-section next sub-section2.5 Names and Symbol Spaces

As discussed in XML Schema Abstract Data Model (§2.2), most schema components (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 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 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.

previous sub-section next sub-section2.6 Schema-Related Markup in Documents Being Validated

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.

Issue (RQ-153i):Issue 3047 (RQ-153 XSD 1.1 namespace)

This specification must choose either to use the same namespace as XML Schema 1.0, or to use a different namespace, or to use more than one namespace. An explicit decision should be made.

XML Schema: 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. All schema processors have appropriate attribute declarations for these attributes built in, see Attribute Declaration for the 'type' attribute (§3.2.7), Attribute Declaration for the 'nil' attribute (§3.2.7), Attribute Declaration for the 'schemaLocation' attribute (§3.2.7) and Attribute Declaration for the 'noNamespaceSchemaLocation' attribute (§3.2.7).

2.6.1 xsi:type

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.16.3) for the means by which the ·QName· is associated with a type definition.

2.6.2 xsi:nil

XML Schema: Structures introduces a mechanism for signaling that an element shouldmust 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 ·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.

3 Schema Component Details

next sub-section3.1 Introduction

The following sections provide full details on the composition of all schema components, together with their XML representations and their contributions to ·assessment·. Each section is devoted to a single component, with separate subsections for

  1. properties: their values and significance
  2. XML representation and the mapping to properties
  3. constraints on representation
  4. validation rules
  5. ·post-schema-validation infoset· contributions
  6. constraints on the components themselves

The sub-sections immediately below introduce conventions and terminology used throughout the component sections.

3.1.1 Components and Properties

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 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, numberdecimal) 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 notmust not exist, so in some cases re-entrant chains of properties mustwill exist. Equality of components for the purposes of this specification is always defined as equality of names (including target namespaces) within symbol spaces.

Issue (RQ-125i):Issue 2837 (RQ-125 identity of anonymous types), Issue 2842 (RQ-134 inherited portions of content model)

Version 1.0 was deliberately reticent in stating identity conditions for components. With hindsight this was a mistake, and will be corrected.

Resolution:

Add {scope} property to type definition components which will either be the enclosing element declaration or "global", by analogy with element declarations {scope}. [For further context, see F2F 2004-03-12, section RQ-125 (W3C-member-only link).]

This change will solve the anonymous type equality problem by giving an unequivocal answer to the "who am I?" question for such types by way of the answer "Your identity is determined by your scope's identity."

Note: A schema and its components as defined in this chapter are an idealization of the information a schema-aware processor requires: implementations are not constrained in how they provide it. In particular, no implications about literal embedding versus indirection follow from the use below of language such as "properties . . . having . . . components as values".

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.

Any property not identified as optional is required to be presentnot 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 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 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].

Note: It is implementation-defined whether a schema processor uses the definition of legal character from [XML 1.1] or [XML 1.0].

3.1.2 XML Representations of Components

The principal purpose of XML Schema: 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 SchemasSchema Documents (Structures) (normative) (§A) and DTD for Schemas (non-normative) (§L)) and schema components. All the element information items in the XML representation of a schema must be in the XML Schema namespace, that is their [namespace name] must be 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.

Two aspects of the XML representations of components presented in the following sections are constant across them all:

  1. All of them allow attributes qualified with namespace names other than the XML Schema namespace itself: these appear as annotations in the corresponding schema component;
  2. All of them allow an <annotation> as their first child, for human-readable documentation and/or machine-targeted information.

3.1.3 The Mapping between XML Representations and Components

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 in the Schema for SchemasSchema 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 SchemasSchema 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·. This will often be a string, but may 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 be violated if one or more references cannot be 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· an appropriately-named component may have become available to discharge the reference: see Schemas and Namespaces: Access and Composition (§4) for details.

3.1.4 White Space Normalization during Validation

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.

[Definition:]  The normalized value of an element or attribute information item is an ·initial value· whose white space, if any, has been normalized according to the value of the whiteSpace facet of the simple type definition used in its ·validation·:

preserve
No normalization is done, the value is the ·normalized value·
replace
All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with #x20 (space).
collapse
Subsequent to the replacements specified above under replace, contiguous sequences of #x20s are collapsed to a single #x20, and initial and/or final #x20s are deleted.

If the simple type definition used in an item's ·validation· is the ·simple ur-type definition·, then the ·normalized value· must be determined as in the preserve case above.

There are three alternative validation rules which may supply the necessary background for the above: Attribute Locally Valid (§3.2.4) (clause 3), Element Locally Valid (Type) (§3.3.4) (clause 3.1.3) or Element Locally Valid (Complex Type) (§3.4.4) (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.

Note: Even when DTD-based information has been appealed to, and Attribute Value Normalization has taken place, the above definition of ·normalized value· may mean further normalization takes place, as for instance when character entity references in attribute values result in white space characters other than spaces in their ·initial value·s.
Note: The values replace and collapse may appear to provide a convenient way to "unwrap" text (i.e. undo the effects of pretty-printing and word-wrapping). In some cases, especially highly constrained data consisting of lists of artificial tokens such as part numbers or other identifiers, this appearance is correct. For natural-language data, however, the whitespace processing prescribed for these values is not only unreliable but will systematically remove the information needed to perform unwrapping correctly. For Asian scripts, for example, a correct unwrapping process will replace line boundaries not with blanks but with zero-width separators or nothing. In consequence, it is normally unwise to use these values for natural-language data, or for any data other than lists of highly constrained tokens.

previous sub-section next sub-section3.2 Attribute Declarations

Attribute declarations provide for:

  • Local ·validation· of attribute information item values using a simple type definition;
  • Specifying default or fixed values for attribute information items.
Example
<xs:attribute name="age" type="xs:positiveInteger" use="required"/>
The XML representation of an attribute declaration.

3.2.1 The Attribute Declaration Schema Component

The attribute declaration schema component has the following properties:

Property Record: Scope

The {name} property must match the local part of the names of attributes being ·validated·.

The value of the attribute 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} with {variety} 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}'s {parent} 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.

{value constraint} 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 {value} and {lexical form} used whenever the attribute is not actually present; fixed indicates that the attribute value if present must be identical to {value}, and if absent receives {value} and {lexical form} as for default. Note that it is values that are checked, not strings.

See Annotations (§3.14) for information on the role of the {annotations} property.

Note: A more complete and formal presentation of the semantics of {name}, {target namespace} and {value constraint} is provided in conjunction with other aspects of complex type ·validation· (see Element Locally Valid (Complex Type) (§3.4.4).)

[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). No means is provided in this specification to supply a default value for a namespace declaration.

3.2.2 XML Representation of Attribute Declaration Schema Components

Issue (RQ-121i):Issue 2835 (RQ-121 prohibited + fixed)

Neither the prose of this specification nor the schema for schema documents rules out XML representations of attribute declarations containing both use='prohibited' and fixed='...'. It will be made clear that this is not an error and that ‘prohibited’ wins.

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 and properties of the component are as follows:

XML Representation Summary: attribute Element Information Item

<attribute
  default = string
  fixed = string
  form = (qualified | unqualified)
  id = ID
  name = NCName
  ref = QName
  type = QName
  use = (optional | prohibited | required) : optional
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, simpleType?)
</attribute>

If the <attribute> element information item has <schema> as its parent, the corresponding schema component is as follows:
Attribute Declaration Schema Component
Property
Representation
 
 
The ·actual value· of the targetNamespace [attribute] of the parent <schema> element information item, or ·absent· if there is none.
 
The simple type definition corresponding to the <simpleType> element information item in the [children], if present, otherwise the simple type definition ·resolved· to by the ·actual value· of the type [attribute], if present, otherwise the ·simple ur-type definition·.
 
A Scope as follows:
Property
Value
global
 
If there is a default or a fixed [attribute], then a Value Constraint as follows, otherwise ·absent·.
Property
Value
either default or fixed, as appropriate
the ·actual value· (with respect to the {type definition}) of the [attribute]
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.
otherwise if the <attribute> element information item has <complexType> or <attributeGroup> as an ancestor and the ref [attribute] is absent, it corresponds to an attribute use with properties as follows (unless use='prohibited', in which case the item corresponds to nothing at all):
Attribute Use Schema Component
Property
Representation
 
true if the use [attribute] is present with ·actual value· required, otherwise false.
 
See the Attribute Declaration mapping immediately below.
 
If there is a default or a fixed [attribute], then a Value Constraint as follows, otherwise ·absent·.
Property
Value
either default or fixed, as appropriate
Attribute Declaration Schema Component
Property
Representation
 
 
If 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·.
 
The simple type definition corresponding to the <simpleType> element information item in the [children], if present, otherwise the simple type definition ·resolved· to by the ·actual value· of the type [attribute], if present, otherwise the ·simple ur-type definition·.
 
A Scope as follows:
Property
Value
If the <attribute> element information item has <complexType> as an ancestor, the Complex Type Definition corresponding to that item, otherwise (the <attribute> element information item is within an <attributeGroup> definition), ·absent·.
 
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.
otherwise (the <attribute> element information item has <complexType> or <attributeGroup> as an ancestor and the ref [attribute] is present), it corresponds to an attribute use with properties as follows (unless use='prohibited', in which case the item corresponds to nothing at all):
Attribute Use Schema Component
Property
Representation
 
true if the use [attribute] is present with ·actual value· required, otherwise false.
 
The (top-level) attribute declaration ·resolved· to by the ·actual value· of the ref [attribute]
 
If there is a default or a fixed [attribute], then a Value Constraint as follows, otherwise ·absent·.
Property
Value
either default or fixed, as appropriate

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.

The default when no simple type definition is referenced or provided is the ·simple ur-type definition·, which imposes no constraints at all.

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.

3.2.3 Constraints on XML Representations of Attribute Declarations

Schema Representation Constraint: Attribute Declaration Representation OK
In addition to the conditions imposed on <attribute> element information items by the schema for schemas, all of the following must be truealso apply :
1 default and fixed must not both be present.
2 If default and use are both present, use must have the ·actual value· optional.
3 If the item's parent is not <schema>, then all of the following mustmust be true:
3.1 One of ref or name must beis present, but not both.
3.2 If ref is present, then all of <simpleType>, form and type must beare absent.
4 type and <simpleType> must not both be present.
5 The corresponding attribute declaration must satisfy the conditions set out in Constraints on Attribute Declaration Schema Components (§3.2.6).

3.2.4 Attribute Declaration Validation Rules

Validation Rule: Attribute Locally Valid
For an attribute information item to be locally ·valid· with respect to an attribute declaration all of the following mustmust be true:
1 The declaration must not beis not ·absent· (see Missing Sub-components (§5.3) for how this can fail to be the case).
2 Its {type definition} must not beis not absent.
3 The item's ·normalized value· must beis locally ·valid· with respect to that {type definition} as per String Valid (§3.15.4).
4 The item's ·actual value· must matchmatches the {value} of the {value constraint}, if it is present and its {variety} is fixed.
Validation Rule: Schema-Validity Assessment (Attribute)
The schema-validity assessment of an attribute information item depends on its ·validation· alone.

[Definition:]  During ·validation·, associations between element and attribute information items among the [children] and [attributes] on the one hand, and element and attribute declarations on the other, are established as a side-effect. Such declarations are called the context-determined declarations. See clause 3.1 (in Element Locally Valid (Complex Type) (§3.4.4)) for attribute declarations, clause 2 (in Element Sequence Locally Valid (Particle) (§3.9.4.2)) for element declarations.

For an attribute information item's schema-validity to have been assessed all of the following mustmust be true:

1 A non-·absent··non-absent· attribute declaration must beis known for it, namely one of the following:
1.1 A declaration which has been established as its ·context-determined declaration·;
1.2 A declaration resolved to by its [local name] and [namespace name] as defined by QName resolution (Instance) (§3.16.4), provided its ·context-determined declaration· is not skip.
1.3
A declaration was stipulated by the processor (see Assessing Schema-Validity (§5.2)).
2 Its ·validity· with respect to that declaration must havehas been evaluated as per Attribute Locally Valid (§3.2.4).
3 Both clause 1 and clause 2 of Attribute Locally Valid (§3.2.4) must beare satisfied.

[Definition:]  For attributes, 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.

3.2.5 Attribute Declaration Information Set Contributions

Schema Information Set Contribution: Assessment Outcome (Attribute)
Issue (RQ-143i):Issue 2827 (RQ-143 attribute assessment)

An attribute with no type declaration cannot be 'assessed', as defined by (Schema-Validity Assessment (Attribute)), so it will never have any PSVI properties, whereas it would be natural for it to have [validation attempted] = none and [validity] = notKnown. This will be fixed.

Resolution:

It is likely that the current backward-chaining approach to defining schema-validity assessment will be reworked, in which case this will get fixed as part of that.

If the schema-validity of an attribute information item has been assessed as per Schema-Validity Assessment (Attribute) (§3.2.4), then in the ·post-schema-validation infoset· it has properties as follows:
PSVI Contributions for attribute information items
[validation context]
The nearest ancestor element information item with a [schema information] property.
[validity]
The appropriate case among the following:
1 If it was ·strictly assessed·, then the appropriate case among the following:
1.1 If it was ·valid· as defined by Attribute Locally Valid (§3.2.4), then valid;
1.2 otherwise invalid.
2 otherwise notKnown.
[validation attempted]
The appropriate case among the following:
1 If it was ·strictly assessed·, then full;
2 otherwise none.
[schema specified]
infoset. See Attribute Default Value (§3.4.5) for the other possible value.
Schema Information Set Contribution: Validation Failure (Attribute)
If and only if the local ·validity·, as defined by Attribute Locally Valid (§3.2.4) above, of an attribute information item has been assessed, then in the ·post-schema-validation infoset· the item has a property:
PSVI Contributions for attribute information items
[schema error code]
The appropriate case among the following:
1 If the item is not ·valid··invalid·, then a list. Applications wishing to provide information as to the reason(s) for the ·validation· failure are encouraged to record one or more error codes (see Outcome Tabulations (normative) (§C)) herein.
2 otherwise ·absent·.
Schema Information Set Contribution: Attribute Declaration
If an attribute information item is ·valid· with respect to an attribute declaration as per Attribute Locally Valid (§3.2.4), then in the ·post-schema-validation infoset· the attribute information item may, at processor option, havehas a property:
PSVI Contributions for attribute information items
[attribute declaration]
An ·item isomorphic· to the declaration component itself.
Schema Information Set Contribution: Attribute Validated by Type
If clause 3 of Attribute Locally Valid (§3.2.4) applies with respect to an attribute information item, then in the ·post-schema-validation infoset· the attribute information item has a propertythe properties:
PSVI Contributions for attribute information items
[schema normalized value]
The ·normalized value· of the item as ·validated·.
[type definition]
An ·item isomorphic· to the relevant attribute declaration's {type definition} component.
[type definition type]
simple.
[type definition namespace]
The {target namespace} of the ·type definition·.
[type definition anonymous]
true if the {name} of the ·type definition· is ·absent·, otherwise false.
[type definition name]
The {name} of the ·type definition·, if the {name} is not ·absent·. If the ·type definition·'s {name} property is ·absent·, then schema processors may, but need not, provide a value which uniquely identifies this type definition among those with the same target namespace.
Furthermore, the item has one of the following alternative sets of properties:

Either
PSVI Contributions for attribute information items
[type definition]
An ·item isomorphic· to the relevant attribute declaration's {type definition} component.
[member type definition]
If and only if that type definition has {variety} union, then an ·item isomorphic· to that member of its {member type definitions} which actually ·validated· the attribute item's [normalized value].
or
PSVI Contributions for attribute information items
[type definition type]
simple.
[type definition namespace]
The {target namespace} of the ·type definition·.
[type definition anonymous]
true if the {name} of the ·type definition· is ·absent·, otherwise false.
[type definition name]
The {name} of the ·type definition·, if it is not ·absent·. If it is ·absent·, schema processors may, but need not, provide a value which uniquely identifies this type definition among those with the same target namespace.
Note: The [type definition type], [type definition namespace], [type definition name], and [type definition anonymous] properties are redundant with the [type definition] property; they are defined for the convenience of implementations which wish to expose those specific properties but not the entire type definition.
If the ·type definition· has {variety} union, then calling [Definition:]   that member of the {member type definitions}basic member of its transitive membership which actually ·validated· the attribute item's ·normalized value· the actual member type definition, there are threefour additional properties:
PSVI Contributions for attribute information items
The first (·item isomorphic·) alternative above is provided for applications such as query processors which need access to the full range of details about an item's ·assessment·, for example the type hierarchy; the second, for lighter-weight processors for whom representing the significant parts of the type hierarchy as information items might be a significant burden.

Also, if and only if the declaration has a {value constraint}, the item has a property:

PSVI Contributions for attribute information items
If the attribute information item was not ·strictly assessed·, then instead of the values specified above,
1 The item's [schema normalized value] property has the ·initial value· of the item as its value;
2 The [type definition] and [member type definition] properties, or their alternatives, are based on the ·simple ur-type definition·.

3.2.6 Constraints on Attribute Declaration Schema Components

All attribute declarations (see Attribute Declarations (§3.2)) must satisfy the following constraints.

Schema Component Constraint: Simple Default Valid
For a Value Constraint to be a valid default with respect to a Simple Type Definition all of the following must beare true:
1 the Value Constraint's {lexical form} must beis ·valid· with respect to that Simple Type Definition as defined by String Valid (§3.15.4).
2 the Value Constraint's {lexical form} maps to its {value} in that Simple Type Definition's value space.
Schema Component Constraint: xmlns Not Allowed
The {name} of an attribute declaration must not match xmlns.
Note: The {name} of an attribute is an ·NCName·, which implicitly prohibits attribute declarations of the form xmlns:*.
Schema Component Constraint: xsi: Not Allowed
The {target namespace} of an attribute declaration, whether local or top-level, must not match http://www.w3.org/2001/XMLSchema-instance (unless it is one of the four built-in declarations given in the next section).
Note: This reinforces the special status of these attributes, so that they not only need not be declared to be allowed in instances, but must notmust not be declared. It also removes any temptation to experiment with supplying global or fixed values for e.g. xsi:type or xsi:nil, which would be seriously misleading, as they would have no effect.

3.2.7 Built-in Attribute Declarations

There are four attribute declarations present in every schema by definition:

Property
Value
type
http://www.w3.org/2001/XMLSchema-instance
The built-in QName simple type definition
A Scope as follows:
Property
Value
global
Property
Value
http://www.w3.org/2001/XMLSchema-instance
The built-in boolean simple type definition
A Scope as follows:
Property
Value
global
Property
Value
schemaLocation
http://www.w3.org/2001/XMLSchema-instance
An anonymous simple type definition, as follows:
Property
Value
http://www.w3.org/2001/XMLSchema-instance
The built-in anyURI simple type definition
A Scope as follows:
Property
Value
global
Property
Value
noNamespaceSchemaLocation
http://www.w3.org/2001/XMLSchema-instance
The built-in anyURI simple type definition
A Scope as follows:
Property
Value
global

previous sub-section next sub-section3.3 Element Declarations

Element declarations provide for:

  • Local ·validation· of element information item values using a type definition;
  • Specifying default or fixed values for an element information items;
  • Establishing uniquenesses and reference constraint relationships among the values of related elements and attributes;
  • Controlling the substitutability of elements through the mechanism of ·element substitution groups·.
Example
<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>
XML representations of several different types of element declaration

3.3.1 The Element Declaration Schema Component

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} with {variety} 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}'s {parent} 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.

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· only if it satisfies 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·.

If {nillable} is true, then an element maycan 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} which would otherwise require content. Formal details of element ·validation· are described in Element Locally Valid (Element) (§3.3.4).

{value constraint} establishes a default or fixed value for an element. If a {value constraint} with a {variety} of default is present, and if the element being ·validated· is empty, then the {value constraint}'s {lexical form} becomes the [schema normalized value] of the ·validated· element in the ·post-schema-validation infoset·. If fixed is specified, then the element's content must either be empty, in which case fixed behaves as default, or its value must be intentical to the {value constraint}'s {value}.

Note: The provision of defaults for elements goes beyond what is possible in XML 1.0 DTDs, and does not exactly correspond to defaults for attributes. In particular, an element with a non-empty {value constraint} whose simple type definition includes the empty string in its lexical space will nonetheless never receive that value, because the {value constraint} will override it.

{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, if any, identified by {substitution group affiliation}. Potential membership is transitive but not symmetric; an element declaration is a potential member of any group of which its {substitution group affiliation} is a potential member. Actual membership 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 the {substitution group affiliation} of other element declarations having the same {type definition} or types derived therefrom. The explicit values of {substitution group exclusions} rule out element declarations having types which are extensions or restrictions respectively of {type definition}. 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 headed by the declared element. If {disallowed substitutions} is empty, then all derived types and 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 notmust not themselves ever be used to ·validate· element content.

See Annotations (§3.14) for information on the role of the {annotations} property.

3.3.2 XML Representation of Element Declaration Schema Components

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 and properties of the component(s) it corresponds to are as follows:

XML Representation Summary: 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 = QName
  type = QName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*))
</element>

If the <element> element information item has <schema> as its parent, the corresponding schema component is as follows:
Element Declaration Schema Component
Property
Representation
 
The ·actual value· of the name [attribute].
 
The ·actual value· of the targetNamespace [attribute] of the parent <schema> element information item, or ·absent· if there is none.
 
A Scope as follows
Property
Value
global
 
The type definition corresponding to the <simpleType> or <complexType> element information item in the [children], if either is present, otherwise the type definition ·resolved· to by the ·actual value· of the 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··definition of anyType·.
 
The ·actual value· of the nillable [attribute], if present, otherwise false.
 
If there is a default or a fixed [attribute], then a Value Constraint as follows, otherwise ·absent·. [Definition:]  Use the name effective simple type definition for the {type definition}, if it is a simple type definition, or, if the {type definition}'s {content type} has {variety} simple, that {content type}'s {simple type definition}, or else the built-in string simple type definition).
Property
Value
either default or fixed, as appropriate
 
A set consisting of the identity-constraint-definitions corresponding to all the <key>, <unique> and <keyref> element information items in the [children], if any, otherwise the empty set.
 
The element declaration ·resolved· to by the ·actual value· of the substitutionGroup [attribute], if present, otherwise ·absent·.
 
A set depending on the ·actual value· of the 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:
1 If the EBV is the empty string, then the empty set;
2 If the EBV is #all, then {extension, restriction, substitution};
3 otherwise a set with members drawn from the set above, each being present or absent depending on whether the ·actual value· (which is a list) contains an equivalently named item.
Note: Although the blockDefault [attribute] of <schema> 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).
 
As for {disallowed substitutions} above, but using the final and finalDefault [attributes] in place of the block and blockDefault [attributes] and with the relevant set being {extension, restriction}.
 
The ·actual value· of the abstract [attribute], if present, otherwise false.
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.
otherwise if the <element> element information item has <complexType> or <group> as an ancestor and the ref [attribute] is absent, the corresponding schema components are as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):
Particle Schema Component
Property
Representation
 
The ·actual value· of the minOccurs [attribute], if present, otherwise 1.
 
unbounded, if the maxOccurs [attribute] equals unbounded, otherwise the ·actual value· of the maxOccurs [attribute], if present, otherwise 1.
 
A (local) element declaration as given below.
An element declaration as in the first case above, with the exception of its {target namespace} and {scope} properties, which are as below:
Element Declaration Schema Component
Property
Representation
 
If 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·.
 
A Scope as follows:
Property
Value
If the <element> element information item has <complexType> as an ancestor, the Complex Type Definition corresponding to that item, otherwise (the <element> element information item is within a named <group> definition), ·absent·.
otherwise (the <element> element information item has <complexType> or <group> as an ancestor and the ref [attribute] is present), the corresponding schema component is as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):
Particle Schema Component
Property
Representation
 
The ·actual value· of the minOccurs [attribute], if present, otherwise 1.
 
unbounded, if the maxOccurs [attribute] equals unbounded, otherwise the ·actual value· of the maxOccurs [attribute], if present, otherwise 1.
 
The (top-level) element declaration ·resolved· to by the ·actual value· of the ref [attribute].

<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, otherwise the ·ur-type definition··definition of 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>.

Example
<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>
The first example above declares an element whose type, by default, is the ·ur-type definition··anyType·. The second uses an embedded anonymous complex type definition.

The last two examples illustrate the use of local element declarations. Instances of myLocalElement within contextOne will be constrained by myFirstType, while those within contextTwo will be constrained by mySecondType.

Note: The possibility that differing attribute declarations and/or content models would apply to elements with the same name in different contexts is an extension beyond the expressive power of a DTD in XML 1.0.
Example
 <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>
An example from a previous version of the schema for datatypes. The 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. Two further elements are declared, each a member of the facet substitution group. Finally a type is defined which refers to facet, thereby allowing either period or encoding (or any other member of the group).

3.3.3 Constraints on XML Representations of Element Declarations

Schema Representation Constraint: Element Declaration Representation OK
In addition to the conditions imposed on <element> element information items by the schema for schemas: all of the following mustmust be true:
1 default and fixed must not both beare not both present.
2 If the item's parent is not <schema>, then all of the following must beare true:
2.1 One of ref or name must beis present, but not both.
2.2 If ref is present, then all of <complexType>, <simpleType>, <key>, <keyref>, <unique>, nillable, default, fixed, form, block and type must beare absent, i.e. only minOccurs, maxOccurs, id and <annotation> are allowed in addition toto appear together with ref, along with <annotation>.
3
type and either <simpleType> or <complexType> are mutually exclusive.

The <element> element does not have both a <simpleType> or <complexType> child and a type attribute.
4 The corresponding particle and/or element declarations must satisfy the conditions set out in Constraints on Element Declaration Schema Components (§3.3.6) and Constraints on Particle Schema Components (§3.9.6).

3.3.4 Element Declaration Validation Rules

Validation Rule: Element Locally Valid (Element)
For an element information item to be locally ·valid· with respect to an element declaration all of the following mustmust be true:
1 The declaration must not beis not ·absent·.
2 Its {abstract} must beis false.
3
The appropriate case among the following must be true:
3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
3.2 If {nillable} is true and there is such an attribute information item and its ·actual value· is true , then all of the following must be true:
3.2.1 The element information item must have no character or element information item [children].
3.2.2 There must be no {value constraint} with {variety} fixed.
One of the following is true:
3.1 {nillable} is false, and there is no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
3.2 {nillable} is true and one of the following is true
3.2.1 There is no such attribute information item.
3.2.2 There is such an attribute information item, and its ·actual value· is false.
3.2.3 There is such an attribute information item, and its ·actual value· is true, and all of the following are true:
3.2.3.1 The element information item has no character or element information item [children].
3.2.3.2 There is no {value constraint} with {variety} fixed.
4 If there is an attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is type, then all of the following must beare true:
4.1 The ·normalized value· of that attribute information item must beis ·valid· with respect to the built-in QName simple type, as defined by String Valid (§3.15.4);
4.2 The ·local name· and ·namespace name· (as defined in QName Interpretation (§3.16.3)), of the ·actual value· of that attribute information item must resolve to a type definition, as defined in QName resolution (Instance) (§3.16.4)[Definition:]  call this type definition the local type definition;
4.3 The ·local type definition· must beis validly derived from the {type definition} given the union of the {disallowed substitutions} and the {type definition}'s {prohibited substitutions}, as defined in Type Derivation OK (Complex) (§3.4.6) (if it is a complex type definition), or given {disallowed substitutions} as defined in Type Derivation OK (Simple) (§3.15.6) (if it is a simple type definition).
[Definition:]  The phrase actual type definition occurs below. If the above three clauses are satisfied, this must be understood as referring to the ·local type definition·, otherwise to the {type definition}.
5 The appropriate case among the following must beis true:
5.1 If the declaration has a {value constraint}, and the item has neither element nor character [children], and clause 3.2 has not applied, then all of the following must beare true:
5.1.1 If the ·actual type definition· is a ·local type definition·, then the declaration's {value constraint} must beis a valid default for the ·actual type definition· as defined in Element Default Valid (Immediate) (§3.3.6).
5.1.2 The element information item with the {lexical form} of the declaration's {value constraint} used as its ·normalized value· must beis ·valid· with respect to the ·actual type definition· as defined by Element Locally Valid (Type) (§3.3.4).
5.2 If the declaration has no {value constraint}, or the item has either element or character [children], or clause 3.2 has applied, then all of the following must beare true:
5.2.1 The element information item must beis ·valid· with respect to the ·actual type definition· as defined by Element Locally Valid (Type) (§3.3.4).
5.2.2 If there is a {value constraint} with {variety} fixed and clause 3.2 has not applied, then all of the following must beare true:
5.2.2.1 The element information item must havehas no element information item [children].
5.2.2.2 The appropriate case among the following mustmust be true:
5.2.2.2.1 If the ·actual type definition· is a Complex Type Definition whose {content type}has {variety} mixed, then the ·initial value· of the item must matchmatches the {lexical form} of the declaration's {value constraint}.
5.2.2.2.2 If the ·actual type definition· is a Simple Type Definition or a Complex Type Definition whose {content type} has {variety} simple, then the ·actual value· of the item must matchis identical to the {value constraint}'s {value}.
6 The element information item must beis ·valid· with respect to each of the {identity-constraint definitions} as per Identity-constraint Satisfied (§3.11.4).
7 If the element information item is the ·validation root·, then it must beis ·valid· per Validation Root Valid (ID/IDREF) (§3.3.4).
Validation Rule: Element Locally Valid (Type)
For an element information item to be locally ·valid· with respect to a type definition all of the following mustmust be true:
1 The type definition must not beis not ·absent·;
2 It must notdoes not have {abstract} with value true.
3 The appropriate case among the following must beis true:
3.1 If the type definition is a simple type definition, then all of the following must beare true:
3.1.1 The element information item's [attributes] must beare empty, excepting those whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is one of type, nil, schemaLocation or noNamespaceSchemaLocation.
3.1.2 The element information item must havehas no element information item [children].
3.1.3 If clause 3.2 of Element Locally Valid (Element) (§3.3.4) did not apply, then the ·normalized value· must beis ·valid· with respect to the type definition as defined by String Valid (§3.15.4).
3.2 If the type definition is a complex type definition, then the element information item must beis ·valid· with respect to the type definition as per Element Locally Valid (Complex Type) (§3.4.4);
Validation Rule: Validation Root Valid (ID/IDREF)
For an element information item which is the ·validation root· to be ·valid· all of the following mustmust be true:
1 There must beis no ID/IDREF binding in the item's [ID/IDREF table] whose [binding] is the empty set.
2 There must beis no ID/IDREF binding in the item's [ID/IDREF table] whose [binding] has more than one member.

See ID/IDREF Table (§3.16.5) for the definition of ID/IDREF binding.

Note: The first clause above applies when there is a reference to an undefined ID. The second applies when there is a multiply-defined ID. They are separated out to ensure that distinct error codes (see Outcome Tabulations (normative) (§C)) are associated with these two cases.
Note: Although this rule applies at the ·validation root·, in practice processors, particularly streaming processors, may wish to detect and signal the clause 2 case as it arises.
Note: This reconstruction of [XML 1.1]'s ID/IDREF functionality is imperfect in that if the ·validation root· is not the document element of an XML document, the results will not necessarily be the same as those a validating parser would give were the document to have a DTD with equivalent declarations.
Validation Rule: Schema-Validity Assessment (Element)
The schema-validity assessment of an element information item depends on its ·validation· and the ·assessment· of its element information item children and associated attribute information items, if any.

So for an element information item's schema-validity to be assessed all of the following mustmust be true:

1 One of the following must beis true:
1.1 All of the following must beare true:
1.1.1 A non-·absent··non-absent· element declaration must beis known for it, because one of the following is true
1.1.1.1 A declaration was stipulated by the processor (see Assessing Schema-Validity (§5.2)).
1.1.1.2 A declaration has been established as its ·context-determined declaration·.
1.1.1.3 All of the following must beare true:
1.1.1.3.1 Its ·context-determined declaration· is not skip.
1.1.1.3.2 Its [local name] and [namespace name] resolve to an element declaration as defined by QName resolution (Instance) (§3.16.4).
1.1.2 Its ·validity· with respect to that declaration must havehas been evaluated as per Element Locally Valid (Element) (§3.3.4).
1.1.3 If that evaluation involved the evaluation of Element Locally Valid (Type) (§3.3.4), clause 1 thereof must beis satisfied.
1.2 All of the following must beare true:
1.2.1 A non-·absent··non-absent· type definition is known for it because one of the following is true
1.2.1.1 A type definition was stipulated by the processor (see Assessing Schema-Validity (§5.2)).
1.2.1.2 All of the following must beare true:
1.2.1.2.1 There is an attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is type.
1.2.1.2.2 The ·normalized value· of that attribute information item is ·valid· with respect to the built-in QName simple type, as defined by String Valid (§3.15.4).
1.2.1.2.3 The ·local name· and ·namespace name· (as defined in QName Interpretation (§3.16.3)), of the ·actual value· of that attribute information item resolve to a type definition, as defined in QName resolution (Instance) (§3.16.4) -- [Definition:]  call this type definition the local type definition.
1.2.1.2.4 If there is also a processor-stipulated type definition, the ·local type definition· must beis validly derived from that type definition given its {prohibited substitutions}, as defined in Type Derivation OK (Complex) (§3.4.6) (if it is a complex type definition), or given the empty set, as defined in Type Derivation OK (Simple) (§3.15.6) (if it is a simple type definition).
1.2.2 The element information item's ·validity· with respect to the ·local type definition· (if present and validly derived) or the processor-stipulated type definition (if no ·local type definition· is present) has been evaluated as per Element Locally Valid (Type) (§3.3.4).
2 The schema-validity of all the element information items among its [children] has been assessed as per Schema-Validity Assessment (Element) (§3.3.4), and the schema-validity of all the attribute information items among its [attributes] has been assessed as per Schema-Validity Assessment (Attribute) (§3.2.4).

[Definition:]  If either case of clause 1 above holds, the element information item has been strictly assessed.

If the item cannot be ·strictly assessed·, because neither clause 1.1 nor clause 1.2 above are satisfied, [Definition:]  an element information item's schema validity maymust be laxly assessed if and only if its ·context-determined declaration· is not skip by ·validating· with respect to the ·ur-type definition··definition of anyType· as per Element Locally Valid (Type) (§3.3.4).

Editorial Note: Priority Feedback Request

In version 1.0 of this specification, the fallback to lax validation described in the preceding paragraph was optional, not required. The XML Schema Working Group solicits input from implementors and users of this specification as to whether this change is desirable and acceptable.
Note: In general if clause 1.1 above holds clause 1.2 does not, and vice versa. When an xsi:type [attribute] is involved, however, clause 1.2 takes precedence, as is made clear in Element Locally Valid (Element) (§3.3.4).
Note: The {name} and {target namespace} properties are not mentioned above because they are checked during particle ·validation·, as per Element Sequence Locally Valid (Particle) (§3.9.4.2).

3.3.5 Element Declaration Information Set Contributions

Schema Information Set Contribution: Assessment Outcome (Element)
If and only if the schema-validity of an element information item has been assessed as per Schema-Validity Assessment (Element) (§3.3.4), then in the ·post-schema-validation infoset· it has properties as follows:
PSVI Contributions for element information items
[validation context]
The nearest ancestor element information item with a [schema information] property (or this element item itself if it has such a property).
[validity]
The appropriate case among the following:
1 If it was ·strictly assessed·, then the appropriate case among the following:
1.1 If all of the following are true:
1.1.1 One of the following is true:
1.1.2 Neither its [children] nor its [attributes] contains an information item (element or attribute respectively) whose [validity] is invalid.
1.1.3 Neither its [children] nor its [attributes] contains an information item (element or attribute respectively) with a ·context-determined declaration· of mustFind whose [validity] is notKnown.
, then valid;
1.2 otherwise invalid..
2 otherwise notKnown.
[validation attempted]
The appropriate case among the following:
1 If it was ·strictly assessed· and neither its [children] nor its [attributes] contains an information item (element or attribute respectively) whose [validation attempted] is not full, then full;
2 If it was not ·strictly assessed· and neither its [children] nor its [attributes] contains an information item (element or attribute respectively) whose [validation attempted] is not none, then none;
3 otherwise partial.
Schema Information Set Contribution: Validation Failure (Element)
If and only if the local ·validity·, as defined by Element Locally Valid (Element) (§3.3.4) above and/or Element Locally Valid (Type) (§3.3.4) below, of an element information item has been assessed, then in the ·post-schema-validation infoset· the item has a property:
PSVI Contributions for element information items
[schema error code]
The appropriate case among the following:
1 If the item is not ·valid··invalid·, then a list. Applications wishing to provide information as to the reason(s) for the ·validation· failure are encouraged to record one or more error codes (see Outcome Tabulations (normative) (§C)) herein.
2 otherwise ·absent·.
Schema Information Set Contribution: Element Declaration
If and only if an element information item is ·valid· with respect to an element declaration as per Element Locally Valid (Element) (§3.3.4), then in the ·post-schema-validation infoset· the element information item must, at processor option, have eitherhas the properties:
PSVI Contributions for element information items
[element declaration]
an ·item isomorphic· to the declaration component itself
or
PSVI Contributions for element information items
[nil]
true if clause 3.2 of Element Locally Valid (Element) (§3.3.4) above is satisfied, otherwise false
PSVI Contributions for element information items
[element declaration]
an ·item isomorphic· to the declaration component itself
[nil]
true if clause 3.2 of Element Locally Valid (Element) (§3.3.4) above is satisfied, otherwise false
Schema Information Set Contribution: Element Validated by Type
If and only if an element information item is ·valid· with respect to a ·type definition· as per Element Locally Valid (Type) (§3.3.4), then in the ·post-schema-validation infoset· the item has a propertythe properties:
PSVI Contributions for element information items
[schema normalized value]
The appropriate case among the following:
1 If clause 3.2 of Element Locally Valid (Element) (§3.3.4) and Element Default Value (§3.3.5) above have not applied and either the ·type definition· is a simple type definition or its {content type} has {variety} simple, then the ·normalized value· of the item as ·validated·.
2 otherwise ·absent·.
[type definition]
An ·item isomorphic· to the ·type definition· component itself.
[type definition type]
simple or complex, depending on the ·type definition·.
[type definition namespace]
The {target namespace} of the ·type definition·.
[type definition anonymous]
true if the {name} of the ·type definition· is ·absent·, otherwise false.
[type definition name]
The {name} of the ·type definition·, if the {name} is not ·absent·. If the ·type definition·'s {name} property is ·absent·, schema processors may, but need not, provide a value unique to the definition.
Furthermore, the item has one of the following alternative sets of properties:

Either
PSVI Contributions for element information items
[type definition]
An ·item isomorphic· to the ·type definition· component itself.
[member type definition]
If and only if that type definition is a simple type definition with {variety} union, or a complex type definition whose {content type} has {variety} simple and {simple type definition} a simple type definition with {variety} union, then an ·item isomorphic· to that member of the union's {member type definitions} which actually ·validated· the element item's ·normalized value·.
or
PSVI Contributions for element information items
[type definition type]
simple or complex, depending on the ·type definition·.
[type definition namespace]
The {target namespace} of the ·type definition·.
[type definition anonymous]
true if the {name} of the ·type definition· is ·absent·, otherwise false.
[type definition name]
The {name} of the ·type definition·, if it is not ·absent·. If it is ·absent·, schema processors may, but need not, provide a value unique to the definition.
Note: The [type definition type], [type definition namespace], [type definition name], and [type definition anonymous] properties are redundant with the [type definition] property; they are defined for the convenience of implementations which wish to expose those specific properties but not the entire type definition.
If the ·type definition· is a simple type definition with {variety} union, or its {content type} has {variety} simple and {simple type definition} a simple type definition with {variety} union, then calling [Definition:]   that member of the {member type definitions}basic member of its transitive membership which actually ·validated· the element item's ·normalized value· the actual member type definition, there are threefour additional properties:
PSVI Contributions for element information items
The first (·item isomorphic·) alternative above is provided for applications such as query processors which need access to the full range of details about an item's ·assessment·, for example the type hierarchy; the second, for lighter-weight processors for whom representing the significant parts of the type hierarchy as information items might be a significant burden.

Also, if the declaration has a {value constraint}, the item has a property:

PSVI Contributions for element information items
Note that if an element is ·laxly assessed·, then the [type definition] and [member type definition] properties, or their alternatives, are based on the ·ur-type definition··definition of anyType·.
Schema Information Set Contribution: Element Default Value
If and only if the local ·validity·, as defined by Element Locally Valid (Element) (§3.3.4) above, of an element information item has been assessed, in the ·post-schema-validation infoset· the item has a property:
PSVI Contributions for element information items
[schema specified]
The appropriate case among the following:
1 If the item is ·valid· with respect to an element declaration as per Element Locally Valid (Element) (§3.3.4) and the {value constraint} is present, but clause 3.2 of Element Locally Valid (Element) (§3.3.4) above is not satisfied and the item has no element or character information item [children], then schema. Furthermore, the ·post-schema-validation infoset· has the {lexical form} of the {value constraint} as the item's [schema normalized value] property.
2 otherwise infoset.

3.3.6 Constraints on Element Declaration Schema Components

All element declarations (see Element Declarations (§3.3)) must satisfy the following constraint.

Schema Component Constraint: Element Declaration Properties Correct
All of the following mustmust be true:
2 If there is a {value constraint}, it is a valid default with respect to the {type definition} as defined in Element Default Valid (Immediate) (§3.3.6).
3 If there is a non-·absent··non-absent· {substitution group affiliation}, then {scope}'s {variety} must beis global.
4 If there is a {substitution group affiliation}, the {type definition} of the element declaration must beis validly derived from the {type definition} of the {substitution group affiliation}, given the value of the {substitution group exclusions} of the {substitution group affiliation}, as defined in Type Derivation OK (Complex) (§3.4.6) (if the {type definition} is complex) or as defined in Type Derivation OK (Simple) (§3.15.6) (if the {type definition} is simple).
5 If the {type definition} or {type definition}'s {content type}'s {simple type definition} is or is derivedconstructed from ID, then there must not be ais no {value constraint}.
Note: The use of ID as a type definition for elements goes beyond XML 1.0, and shouldshould be avoided if backwards compatibility is desired.
6 Circular substitution groups are disallowed. There are no circular substitution groups. That is, it must not beis not possible to return to an element declaration by repeatedly following the {substitution group affiliation} property.

The following constraints define relations appealed to elsewhere in this specification.

Schema Component Constraint: Element Default Valid (Immediate)
For a Value Constraint to be a valid default with respect to a type definition the appropriate case among the following mustmust be true:
1 If the type definition is a simple type definitionor a complex type definition whose {content type} has {variety} simple type definition, then the Value Constraint is a valid default with respect to the {content type}'s {simple type definition} as defined by Simple Default Valid (§3.2.6).
2 If the type definition is a complex type definition whose {content type}'s {variety} is not simple type definition, then all of the following must beare true:
2.1 its {content type} has {variety} mixed.
2.2 the {content type}'s {particle} must beis ·emptiable· as defined by Particle Emptiable (§3.9.6).
Schema Component Constraint: Substitution Group OK (Transitive)
For an element declaration (call it D) to be validly substitutable for another element declaration (call it C) subject to a blocking constraint (a subset of {substitution, extension, restriction}, the value of a {disallowed substitutions}) one of the following mustmust be true:
1 D and C are the same element declaration.
2 All of the following must beare true:
2.1 The blocking constraint does not contain substitution.
2.2 There is a chain of {substitution group affiliation}s from D to C, that is, either D's {substitution group affiliation} is C, or D's {substitution group affiliation}'s {substitution group affiliation} is C, or . . .
2.3 The set of all {derivation method}s involved in the derivation of D's {type definition} from C's {type definition} does not intersect with the union of the blocking constraint, C's {prohibited substitutions} (if C is complex, otherwise the empty set) and the {prohibited substitutions} (respectively the empty set) of any intermediate {type definition}s in the derivation of D's {type definition} from C's {type definition}.

[Definition:]  One element declaration is validly substitutable for another if together they satisfy constraint Substitution Group OK (Transitive) (§3.3.6).

Schema Component Constraint: Substitution Group
[Definition:]  Every element declaration (call this HEAD) in the {element declarations} of a schema defines a substitution group, a subset of those {element declarations}, as follows:

Define P, the potential substitution group for HEAD, as follows:

1 The element declaration itself is in P;
2 P is closed with respect to {substitution group affiliation}, that is, if any element declaration in the {element declarations} has a {substitution group affiliation} in P, then that element is also in P itself.
HEAD's actual ·substitution group· is then the set consisting of each member of P such that all of the following must beare true:
1 Its {abstract} is false.
2 It is validly substitutable for HEAD subject to HEAD's {disallowed substitutions} as the blocking constraint, as defined in Substitution Group OK (Transitive) (§3.3.6).

previous sub-section next sub-section3.4 Complex Type Definitions

Complex Type Definitions provide for:

Issue (RQ-36i): Issue 2857 (RQ-7 wildcards), Issue 2860 (RQ-36 local references), Issue 2544 (RQ-146 element declarations consistent)

Although extremely useful, wildcards have proved to interact in unfortunate ways with the Unique Particle Attribution and Element Declarations Consistent constraints, and this has limited their utility, particularly for use in allowing for extension and anticipating subsequent versions. The interpretation of wildcards will be changed to address these problems, without compromising backward compatibility.

Example
<xs:complexType name="PurchaseOrderType">
  <xs:sequence>
   <xs:element name="shipTo" type="USAddress"/>
   <xs:element name="billTo" type="USAddress"/>
   <xs:element ref="comment" minOccurs="0"/>
   <xs:element name="items"  type="Items"/>
  </xs:sequence>
  <xs:attribute name="orderDate" type="xs:date"/>
 </xs:complexType>
The XML representation of a complex type definition.

3.4.1 The Complex Type Definition Schema Component

A complex type definition schema component has the following properties:

Property Record: Content Type
{particle}
A Particle component. Required if {variety} is element-only or mixed, otherwise must be ·absent·.
{simple type definition}
A Simple Type Definition component. Required if {variety} is simple, otherwise must be ·absent·.
Issue (RQ-131i): Issue 2841 (RQ-131 ordering of annotations), Issue 2840 (RQ-130 lost annotations), Issue 2851 (RQ-19 annotations in PSVI)

Version 1.0 was inconsistent in providing for multiple sources of annotation, particularly where components corresponded to multiple nested elements in schema documents (e.g. Complex Type Definitions vis a vis xs:complexType, xs:complexContent and xs:restriction). This will change so that all components can have multiple annotations, and annotations will be handled consistently across all kinds of components.

Also applies anywhere else {annotations} plural appears — everywhere, in fact.

Resolution:

  1. All components have an {annotations} property;
  2. It contains a sequence of annotations;
  3. Namely all annotations "scoped" by this component, but not "scoped" by any other component "further down".
  4. The order of annotations within {annotations} is implementation-determined.

Note that when point 3 above mentions "annotations 'scoped' by . . ." this means <annotation> elements and out-of-band attributes.

[Agendum 4.1 SCD-related requirements (W3C-member-only link)]

Complex type definitions are identified by their {name} and {target namespace}. Except for anonymous complex type definitions (those with no {name}), since type definitions (i.e. both simple and complex type definitions taken together) must be uniquely identified within an ·XML Schema·, no complex type definition can have the same name as another simple or complex type definition. Complex type {name}s and {target namespace}s are provided for reference from instances (see xsi:type (§2.6.1)), and for use in the XML representation of schema components (specifically in <element>). See References to schema components across namespaces (<import>) (§4.2.3) for the use of component identifiers when importing one schema into another.

Note: The {name} of a complex type is not ipso facto the [(local) name] of the element information items ·validated· by that definition. The connection between a name and a type definition is described in Element Declarations (§3.3).

As described in Type Definition Hierarchy (§2.2.1.1), each complex type is derived from a {base type definition} which is itself either a Simple Type Definition (§2.2.1.2) or a Complex Type Definition (§2.2.1.3). {derivation method} specifies the means of derivation as either extension or restriction (see Type Definition Hierarchy (§2.2.1.1)).

A complex type with an empty specification for {final} can be used as a {base type definition} for other types derived by either of extension or restriction; the explicit values extension, and restriction prevent further derivations by extension and restriction respectively. If all values are specified, then [Definition:]  the complex type is said to be final, because no further derivations are possible. Finality is not inherited, that is, a type definition derived by restriction from a type definition which is final for extension is not itself, in the absence of any explicit final attribute of its own, final for anything.

The {context} property is only relevant for anonymous type definitions, for which its value is the component in which this type definition appears as the value of a property, e.g. {type definition}.

Complex types for which {abstract} is true must not be used as the {type definition} for the ·validation· of element information items. It follows that they must not be referenced from an xsi:type (§2.6.1) attribute in an instance document. Abstract complex types can be used as {base type definition}s, or even as the {type definition}s of element declarations, provided in every case a concrete derived type definition is used for ·validation·, either via xsi:type (§2.6.1) or the operation of a substitution group.

{attribute uses} are a set of attribute uses. See Element Locally Valid (Complex Type) (§3.4.4) and Attribute Locally Valid (§3.2.4) for details of attribute ·validation·.

{attribute wildcard}s provide a more flexible specification for ·validation· of attributes not explicitly included in {attribute uses}. Informally, the specific values of {attribute wildcard} are interpreted as follows:

  • any: [attributes] can include attributes with any qualified or unqualified name.
  • a set whose members are either namespace names or ·absent·: [attributes] can include any attribute(s) from the specified namespace(s). If ·absent· is included in the set, then any unqualified attributes are (also) allowed.
  • 'not' and a namespace name: [attributes] cannot include attributes from the specified namespace.
  • 'not' and ·absent·: [attributes] cannot include unqualified attributes.

See Element Locally Valid (Complex Type) (§3.4.4), The Wildcard Schema Component (§3.10.1) and Wildcard allows Namespace Name (§3.10.4)Wildcard allows Expanded Name (§3.10.4) for formal details of attribute wildcard ·validation·.

{content type} determines the ·validation· of [children] of element information items. Informally:

{prohibited substitutions} determine whether an element declaration appearing in a · content model· is prevented from additionally ·validating· element items with an xsi:type (§2.6.1) attribute that identifies a complex type definition derived by extension or restriction from this definition, or element items in a substitution group whose type definition is similarly derived: If {prohibited substitutions} is empty, then all such substitutions are allowed, otherwise, the derivation method(s) it names are disallowed.

{assertions} constrain elements and attributes to exist, not to exist, or to have specified values. Though specified as a sequence, the order among the assertions is not significant during assessment. See Assertions (§3.12).

See Annotations (§3.14) for information on the role of the {annotations} property.

3.4.2 XML Representation of Complex Type Definitions

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 displays first the elements involved in the first case, then those for the second. The property mapping is shown once for each case.

XML Representation Summary: complexType Element Information Item

<complexType
  abstract = boolean : false
  block = (#all | List of (extension | restriction))
  final = (#all | List of (extension | restriction))
  id = ID
  mixed = boolean : false
  name = NCName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), (assert | report)*)))
</complexType>

Whichever alternative for the content of <complexType> is chosen, the following property mappings apply:
Complex Type Definition Schema Component
Property
Representation
 
The ·actual value· of the name [attribute] if present, otherwise ·absent·.
 
The ·actual value· of the targetNamespace [attribute] of the <schema> ancestor element information item if present, otherwise ·absent·.
 
The ·actual value· of the abstract [attribute], if present, otherwise false.
 
A set corresponding to the ·actual value· of the 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:
1 If the EBV is the empty string, then the empty set;
2 If the EBV is #all, then {extension, restriction};
3 otherwise a set with members drawn from the set above, each being present or absent depending on whether the ·actual value· (which is a list) contains an equivalently named item.
Note: Although the blockDefault [attribute] of <schema> may include values other than restriction orextension, those values are ignored in the determination of {prohibited substitutions} for complex type definitions (they are used elsewhere).
 
As for {prohibited substitutions} above, but using the final and finalDefault [attributes] in place of the block and blockDefault [attributes].
 
If the name [attribute] is present, then ·absent·, otherwise (the parent element information item will be <element>), the Element Declaration corresponding to that parent information item.
 
A sequence whose members are Assertions drawn from the following sources, in order:
2 Assertions corresponding to all the <assert> and <report> element information items among the [children], if any, in order.
 
The annotations corresponding to the <annotation> element information item in the [children], if present, in the <simpleContent> and <complexContent> [children], if present, and in their <restriction> and <extension> [children], if present, otherwise ·absent·.
When the <simpleContent> alternative is chosen, the following elements are relevant, and the remaining property mappings are as below. Note that either <restriction> or <extension> must be chosen as the content of <simpleContent>.

<simpleContent
  id = ID
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (restriction | extension))
</simpleContent>

<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)*)?, ((attribute | attributeGroup)*, anyAttribute?), (assert | report)*)
</restriction>

<extension
  base = QName
  id = ID
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?), (assert | report)*)
</extension>

<attributeGroup
  id = ID
  ref = QName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</attributeGroup>

<anyAttribute
  id = ID
  namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )
  notNamespace = List of (anyURI | (##targetNamespace | ##local))
  notQName = List of QName
  processContents = (lax | skip | strict) : strict
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</anyAttribute>

Property
Representation
 
The type definition ·resolved· to by the ·actual value· of the base [attribute]
 
If the <restriction> alternative is chosen, then restriction, otherwise (the <extension> alternative is chosen) extension.
 
A union of sets of attribute uses as follows
1 The set of attribute uses corresponding to the <attribute> [children], if any.
2 The {attribute uses} of the attribute groups ·resolved· to by the ·actual value·s of the ref [attribute] of the <attributeGroup> [children], if any.
3 if the type definition ·resolved· to by the ·actual value· of the base [attribute] is a complex type definition, the {attribute uses} of that type definition, unless the <restriction> alternative is chosen, in which case some members of that type definition's {attribute uses} may notmust not be included, namely those whose {attribute declaration}'s {name} and {target namespace} are the same as one of the following:
3.1 the {name} and {target namespace} of the {attribute declaration} of an attribute use in the set per clause 1 or clause 2 above;
3.2 what would have been the {name} and {target namespace} of the {attribute declaration} of an attribute use in the set per clause 1 above but for the ·actual value· of the use [attribute] of the relevant <attribute> among the [children] of <restriction> being prohibited.
 
1 [Definition:]  Let the local wildcard be defined as the appropriate case among the following:
1.1 If there is an <anyAttribute> present, then a wildcard based on the ·actual value·s of the namespace and processContentsits [attributes] and the <annotation> [children], exactly as for the wildcard corresponding to an <any> element as set out in XML Representation of Wildcard Schema Components (§3.10.2);
1.2 otherwise ·absent·.
2 [Definition:]  Let the complete wildcard be defined as the appropriate case among the following:
2.1 If there are no <attributeGroup> [children] corresponding to attribute groups with non-·absent··non-absent· {attribute wildcard}s, then the ·local wildcard·.
2.2 If there are one or more <attributeGroup> [children] corresponding to attribute groups with non-·absent··non-absent· {attribute wildcard}s, then the appropriate case among the following:
2.2.1 If there is an <anyAttribute> present, then a wildcard whose {process contents} and {annotations} are those of the ·local wildcard·, and whose {namespace constraint} is the intensional intersection of the {namespace constraint} of the ·local wildcard· and of the {namespace constraint}s of all the non-·absent··non-absent· {attribute wildcard}s of the attribute groups corresponding to the <attributeGroup> [children], as defined in Attribute Wildcard Intersection (§3.10.6).
2.2.2 If there is no <anyAttribute> present, then a wildcard whose properties are as follows:
The {process contents} of the first non-·absent··non-absent· {attribute wildcard} of an attribute group among the attribute groups corresponding to the <attributeGroup> [children].
The intensional intersection of the {namespace constraint}s of all the non-·absent··non-absent· {attribute wildcard}s of the attribute groups corresponding to the <attributeGroup> [children], as defined in Attribute Wildcard Intersection (§3.10.6).
3 The value is then determined by the appropriate case among the following:
3.1 If the <restriction> alternative is chosen, then the ·complete wildcard·;
3.2 If the <extension> alternative is chosen, then
3.2.1 [Definition:]  let the base wildcard be defined as the appropriate case among the following:
3.2.1.1 If the type definition ·resolved· to by the ·actual value· of the base [attribute] is a complex type definition with an {attribute wildcard}, then that {attribute wildcard}.
3.2.1.2 otherwise ·absent·.
3.2.2 The value is then determined by the appropriate case among the following:
3.2.2.1 If the ·base wildcard· is non-·absent··non-absent· , then the appropriate case among the following:
3.2.2.1.1 If the ·complete wildcard· is ·absent·, then the ·base wildcard·.
3.2.2.1.2 otherwise a wildcard whose {process contents} and {annotations} are those of the ·complete wildcard·, and whose {namespace constraint} is the intensional union of the {namespace constraint} of the ·complete wildcard· and of the ·base wildcard·, as defined in Attribute Wildcard Union (§3.10.6).
3.2.2.2 otherwise (the ·base wildcard· is ·absent·) the ·complete wildcard·
 
A Content Type as follows:
Property
Value
simple
the appropriate case among the following:
1 If the type definition ·resolved· to by the ·actual value· of the base [attribute] is a complex type definition whose own {content type} has {variety} simple and the <restriction> alternative is chosen, then starting from either
1.1 the simple type definition corresponding to the <simpleType> among the [children] of <restriction> if there is one;
1.2 otherwise (<restriction> has no <simpleType> among its [children]), the simple type definition which is the {simple type definition} of the {content type} of the type definition ·resolved· to by the ·actual value· of the base [attribute]
a simple type definition which restricts the simple type definition identified in clause 1.1 or clause 1.2 with a set of facet components corresponding to the appropriate element information items among the <restriction>'s [children] (i.e. those which specify facets, if any), as defined in Simple Type Restriction (Facets) (§3.15.6);
2 If the type definition ·resolved· to by the ·actual value· of the base [attribute] is a complex type definition whose own {content type} has {variety} mixed and {particle} a Particle which is ·emptiable·, as defined in Particle Emptiable (§3.9.6) and the <restriction> alternative is chosen, then starting from the simple type definition corresponding to the <simpleType> among the [children] of <restriction> (which must be present) a simple type definition which restricts that simple type definition with a set of facet components corresponding to the appropriate element information items among the <restriction>'s [children] (i.e. those which specify facets, if any), as defined in Simple Type Restriction (Facets) (§3.15.6);
3 If the type definition ·resolved· to by the ·actual value· of the base [attribute] is a complex type definition (whose own {content type} must have {variety} simple, see below) and the <extension> alternative is chosen, then the {simple type definition} of the {content type} of that complex type definition;
4 otherwise (the type definition ·resolved· to by the ·actual value· of the base [attribute] is a simple type definition and the <extension> alternative is chosen), then that simple type definition.
When the <complexContent> alternative is chosen, the following elements are relevant (as are the <attributeGroup> and <anyAttribute> elements, not repeated here), and the additional property mappings are as below. Note that either <restriction> or <extension> must be chosen as the content of <complexContent>, but their content models are different in this case from the case above when they occur as children of <simpleContent>.
The property mappings below are also used in the case where the third alternative (neither <simpleContent> nor <complexContent>) is chosen. This case is understood as shorthand for complex content restricting the ·ur-type definition·, and the details of the mappings shouldmust be modified as necessary.

<complexContent
  id = ID
  mixed = boolean
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (restriction | extension))
</complexContent>

<restriction
  base = QName
  id = ID
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), (assert | report)*)
</restriction>

<extension
  base = QName
  id = ID
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), (assert | report)*))
</extension>

Property
Representation
 
The type definition ·resolved· to by the ·actual value· of the base [attribute]
 
If the <restriction> alternative is chosen, then restriction, otherwise (the <extension> alternative is chosen) extension.
 
A union of sets of attribute uses as follows:
1 The set of attribute uses corresponding to the <attribute> [children], if any.
2 The {attribute uses} of the attribute groups ·resolved· to by the ·actual value·s of the ref [attribute] of the <attributeGroup> [children], if any.
3 The {attribute uses} of the type definition ·resolved· to by the ·actual value· of the base [attribute], unless the <restriction> alternative is chosen, in which case some members of that type definition's {attribute uses} must not be included, namely those whose {attribute declaration}'s {name} and {target namespace} are the same as one of the following:
3.1 The {name} and {target namespace} of the {attribute declaration} of an attribute use in the set per clause 1 or clause 2 above;
3.2 what would have been the {name} and {target namespace} of the {attribute declaration} of an attribute use in the set per clause 1 above but for the ·actual value· of the use [attribute] of the relevant <attribute> among the [children] of <restriction> being prohibited.
 
As above for the <simpleContent> alternative.
 
1 [Definition:]  Let the effective mixed be the appropriate case among the following:
1.1 If the mixed [attribute] is present on <complexContent>, then its ·actual value·;
1.2 If the mixed [attribute] is present on <complexType>, then its ·actual value·;
1.3 otherwise false.
2 [Definition:]  Let the effective content be the appropriate case among the following:
2.1 If one of the following is true
2.1.1 There is no <group>, <all>, <choice> or <sequence> among the [children];
2.1.2 There is an <all> or <sequence> among the [children] with no [children] of its own excluding <annotation>;
2.1.3 There is a <choice> among the [children] with no [children] of its own excluding <annotation> whose minOccurs [attribute] has the ·actual value· 0;
, then the appropriate case among the following:
2.1.4 If the ·effective mixed· is true, then A particle whose properties are as follows:
A model group whose {compositor} is sequence and whose {particles} is empty.
.
2.1.5 otherwise empty
2.2 otherwise the particle corresponding to the <all>, <choice>, <group> or <sequence> among the [children].
3 Then the value of the property is the appropriate case among the following:
3.1 If the <restriction> alternative is chosen, then the appropriate case among the following:
3.1.1 If the ·effective content· is empty , then a Content Type as follows:
3.1.2 otherwise a Content Type as follows:
Property
Value
mixed if the ·effective mixed· is true, otherwise elementOnly
3.2 If the <extension> alternative is chosen, then the appropriate case among the following:
3.2.1 If the ·effective content· is empty, then the {content type} of the type definition ·resolved· to by the ·actual value· of the base [attribute]
3.2.2 If the type definition ·resolved· to by the ·actual value· of the base [attribute] has a {content type} with {variety} empty or simple, then a Content Type as per clause 3.1.2 above;
3.2.3 otherwise a Content Type as follows:
Property
Value
mixed if the ·effective mixed· is true, otherwise elementOnly
a Particle whose properties are as follows:
A model group whose {compositor} is sequence and whose {particles} are the particle of the {content type} of the type definition ·resolved· to by the ·actual value· of the base [attribute] followed by the ·effective content·.
Note: If the {base type definition} is a complex type definition, then the {assertions} always contain members of the {assertions} of the {base type definition}, no matter which alternatives are chosen in the XML representation, <simpleContent> or <complexContent>, <restriction> or <extension>.
Note: Aside from the simple coherence requirements enforced above, constraining type definitions identified as restrictions to actually be restrictions, that is, to ·validate· a subset of the items which are ·validated· by their base type definition, is enforced in Constraints on Complex Type Definition Schema Components (§3.4.6).
Note: The only substantive function of the value prohibited for the use attribute of an <attribute> is in establishing the correspondence between a complex type defined by restriction and its XML representation. It serves to prevent inheritance of an identically named attribute use from the {base type definition}. Such an <attribute> does not correspond to any component, and hence there is no interaction with either explicit or inherited wildcards in the operation of Complex Type Definition Validation Rules (§3.4.4) or Constraints on Complex Type Definition Schema Components (§3.4.6).

Careful consideration of the above concrete syntax reveals that a type definition need consist of no more than a name, i.e. that <complexType name="anyThing"/> is allowed.

Example
<xs:complexType name="length1">
 <xs:simpleContent>
  <xs:extension base="xs:nonNegativeInteger">
   <xs:attribute name="unit" type="xs:NMTOKEN"/>
  </xs:extension>
 </xs:simpleContent>
</xs:complexType>

<xs:element name="width" type="length1"/>

  <width unit="cm">25</width>

<xs:complexType name="length2">
 <xs:complexContent>
  <xs:restriction base="
     xs:anyType
     xs:rootType
     ">
   <xs:sequence>
    <xs:element name="size" type="xs:nonNegativeInteger"/>
    <xs:element name="unit" type="xs:NMTOKEN"/>
   </xs:sequence>
  </xs:restriction>
 </xs:complexContent>
</xs:complexType>

<xs:element name="depth" type="length2"/>

  <depth>
   <size>25</size><unit>cm</unit>
  </depth>

<xs:complexType name="length3">
 <xs:sequence>
  <xs:element name="size" type="xs:nonNegativeInteger"/>
  <xs:element name="unit" type="xs:NMTOKEN"/>
 </xs:sequence>
</xs:complexType>
    
Three approaches to defining a type for length: one with character data content constrained by reference to a built-in datatype, and one attribute, the other two using two elements. length3 is the abbreviated alternative to length2: they correspond to identical type definition components.
Example
<xs:complexType name="personName">
 <xs:sequence>
  <xs:element name="title" minOccurs="0"/>
  <xs:element name="forename" minOccurs="0" maxOccurs="unbounded"/>
  <xs:element name="surname"/>
 </xs:sequence>
</xs:complexType>

<xs:complexType name="extendedName">
 <xs:complexContent>
  <xs:extension base="personName">
   <xs:sequence>
    <xs:element name="generation" minOccurs="0"/>
   </xs:sequence>
  </xs:extension>
 </xs:complexContent>
</xs:complexType>

<xs:element name="addressee" type="extendedName"/>

  <addressee>
   <forename>Albert</forename>
   <forename>Arnold</forename>
   <surname>Gore</surname>
   <generation>Jr</generation>
  </addressee>
A type definition for personal names, and a definition derived by extension which adds a single element; an element declaration referencing the derived definition, and a ·valid· instance thereof.
Example
<xs:complexType name="simpleName">
 <xs:complexContent>
  <xs:restriction base="personName">
   <xs:sequence>
    <xs:element name="forename" minOccurs="1" maxOccurs="1"/>
    <xs:element name="surname"/>
   </xs:sequence>
  </xs:restriction>
 </xs:complexContent>
</xs:complexType>

<xs:element name="who" type="simpleName"/>

   <who>
    <forename>Bill</forename>
    <surname>Clinton</surname>
   </who>
A simplified type definition derived from the base type from the previous example by restriction, eliminating one optional daughter and fixing another to occur exactly once; an element declared by reference to it, and a ·valid· instance thereof.
Example
<xs:complexType name="paraType" mixed="true">
 <xs:choice minOccurs="0" maxOccurs="unbounded">
  <xs:element ref="emph"/>
  <xs:element ref="strong"/>
 </xs:choice>
 <xs:attribute name="version" type="xs:numberdecimal"/>
</xs:complexType>
A further illustration of the abbreviated form, with the mixed attribute appearing on complexType itself.

3.4.3 Constraints on XML Representations of Complex Type Definitions

Schema Representation Constraint: Complex Type Definition Representation OK
In addition to the conditions imposed on <complexType> element information items by the schema for schemas, all of the following must be truealso apply :
1 If the <complexContent> alternative is chosen, the type definition ·resolved· to by the ·actual value· of the base [attribute] must be a complex type definition;
2 If the <simpleContent> alternative is chosen, all of the following mustmust be true:
2.1 The type definition ·resolved· to by the ·actual value· of the base [attribute] must beis one of the following:
2.1.1 a complex type definition whose {content type} has {variety} simple;
2.1.2 only if the <restriction> alternative is also chosen, a complex type definition whose {content type} has {variety} mixed and {particle} a Particle which is ·emptiable·, as defined in Particle Emptiable (§3.9.6);
2.1.3 only if the <extension> alternative is also chosen, a simple type definition.
2.2 If clause 2.1.2 above is satisfied, then there must beis a <simpleType> among the [children] of <restriction>.
Note: Although not explicitly ruled out either here or in Schema for SchemasSchema Documents (Structures) (normative) (§A), specifying <xs:complexType . . .mixed='true' when the <simpleContent> alternative is chosen has no effect on the corresponding component, and shouldshould be avoided. This may be ruled out in a subsequent version of this specification.
3 The corresponding complex type definition component must satisfy the conditions set out in Constraints on Complex Type Definition Schema Components (§3.4.6);
4
If clause 2.2.1 or clause 2.2.2 in the correspondence specification above for {attribute wildcard} is satisfied, the intensional intersection must be expressible, as defined in Attribute Wildcard Intersection (§3.10.6).

3.4.4 Complex Type Definition Validation Rules

Validation Rule: Element Locally Valid (Complex Type)
For an element information item to be locally ·valid· with respect to a complex type definition all of the following mustmust be true:
1
{abstract} is false.
2 If clause 3.2 of Element Locally Valid (Element) (§3.3.4) did not apply, then the appropriate case among the following must beis true:
2.1 If the {content type} has {variety} empty, then the element information item has no character or element information item [children].
2.2 If the {content type} has {variety} simple, then the element information item has no element information item [children], and the ·normalized value· of the element information item is ·valid· with respect to the {content type}'s {simple type definition} as defined by String Valid (§3.15.4).
2.3 If the {content type} has {variety} element-only, then the element information item has no character information item [children] other than those whose [character code] is defined as a white space in [XML 1.1].
Note: It is implementation-defined whether a schema processor supports the definition of white space from [XML 1.1], or that from [XML 1.0], or both.
2.4 If the {content type} has {variety} element-only or mixed, then the sequence of the element information item's element information item [children], if any, taken in order, is ·valid· with respect to the {content type}'s {particle}, as defined in Element Sequence Locally Valid (Particle) (§3.9.4.2).
3 For each attribute information item in the element information item's [attributes] excepting those whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is one of type, nil, schemaLocation or noNamespaceSchemaLocation, the appropriate case among the following must beis true:
3.1 If there is among the {attribute uses} an attribute use with an {attribute declaration} whose {name} matches the attribute information item's [local name] and whose {target namespace} is identical to the attribute information item's [namespace name] (where an ·absent· {target namespace} is taken to be identical to a [namespace name] with no value), then the attribute information must beis ·valid· with respect to that attribute use as per Attribute Locally Valid (Use) (§3.5.4). In this case the {attribute declaration} of that attribute use is the ·context-determined declaration· for the attribute information item with respect to Schema-Validity Assessment (Attribute) (§3.2.4) and Assessment Outcome (Attribute) (§3.2.5).
3.2 otherwise all of the following must beare true:
3.2.1 There must beis an {attribute wildcard}.
3.2.2 The attribute information item must beis ·valid· with respect to it as defined in Item Valid (Wildcard) (§3.10.4).
4 The {attribute declaration} of each attribute use in the {attribute uses} whose {required} is true matches one of the attribute information items in the element information item's [attributes] as per clause 3.1 above.
5 Let [Definition:]  the wild IDs be the set of all attribute information items to which clause 3.2 applied and whose ·validation· resulted in a ·context-determined declaration· of mustFind or no ·context-determined declaration· at all, and whose [local name] and [namespace name] resolve (as defined by QName resolution (Instance) (§3.16.4)) to an attribute declaration whose {type definition} is or is derivedconstructed from ID. Then all of the following must beare true:
5.1 There must beis no more than one item in ·wild IDs·.
5.2 If ·wild IDs· is non-empty, there must not be anyare no attribute uses among the {attribute uses} whose {attribute declaration}'s {type definition} is or is derivedconstructed from ID.
Note: This clause serves to ensure that even via attribute wildcards no element has more than one attribute of type ID, and that even when an element legitimately lacks a declared attribute of type ID, a wildcard-validated attribute must not supply it. That is, if an element has a type whose attribute declarations include one of type ID, it either has that attribute or no attribute of type ID.
6
The element information item is ·valid· with respect to each of the {assertions} as per Assertion Satisfied (§3.12.4).
Note: When an {attribute wildcard} is present, this does not introduce any ambiguity with respect to how attribute information items for which an attribute use is present amongst the {attribute uses} whose name and target namespace match are ·assessed·. In such cases the attribute use always takes precedence, and the ·assessment· of such items stands or falls entirely on the basis of the attribute use and its {attribute declaration}. This follows from the details of clause 3.

3.4.5 Complex Type Definition Information Set Contributions

Schema Information Set Contribution: Attribute Default Value
For each attribute use in the {attribute uses} whose {required} is false and whose {value constraint} is not ·absent· but whose {attribute declaration} does not match one of the attribute information items in the element information item's [attributes] as per clause 3.1 of Element Locally Valid (Complex Type) (§3.4.4) above, the ·post-schema-validation infoset· has an attribute information item whose properties are as below added to the [attributes] of the element information item.
Issue (RQ-22i):Issue 2852 (RQ-22 add normalized default)

Constructed default attribute information items in the PSVI did not have a [normalized value] property, only a [schema normalized value], making them incompatible with ordinary attribute infoitems. On balance, it seems sensible to correct this.

Resolution:

Add a [normalized value] property to the constructed attribute infoitem which arises when a default value is applied.

The added items shouldmust also either have [type definition] (and [member type definition] if appropriate) properties, or their lighter-weight alternatives, as specified in Attribute Validated by Type (§3.2.5).

3.4.6 Constraints on Complex Type Definition Schema Components

All complex type definitions (see Complex Type Definitions (§3.4)) must satisfy the following constraints.

Schema Component Constraint: Complex Type Definition Properties Correct
All of the following mustmust be true:
2 If the {base type definition} is a simple type definition, the {derivation method} must beis extension.
3 Circular definitions are disallowed, except for the ·ur-type definition·There are no circular definitions, except for that of rootType. That is, it must beis possible to reach the ·ur-type definition·definition of rootType by repeatedly following the {base type definition}.
4 TwoNo two distinct attribute declarations in the {attribute uses} must not have identical {name}s and {target namespace}s.
5 TwoNo two distinct attribute declarations in the {attribute uses} must not have {type definition}s which are or are derivedconstructed from ID.
Schema Component Constraint: Derivation Valid (Extension)
If the {derivation method} is extension, then the appropriate case among the following mustmust be true:
1 If the {base type definition} is a complex type definition, then all of the following must beare true:
1.1 The {final} of the {base type definition} must notdoes not contain extension.
1.2 Its {attribute uses} must beis a subset of the {attribute uses} of the complex type definition itself, that is. That is, for every attribute use in the {attribute uses} of the {base type definition}, there must beis an attribute use in the {attribute uses} of the complex type definition itself whose {attribute declaration} has the same {name}, {target namespace} and {type definition} as its attribute declaration.
1.3 If it has an {attribute wildcard}, then the complex type definition must also havealso has one, and the base type definition's {attribute wildcard}'s {namespace constraint} must beis a subset of the complex type definition's {attribute wildcard}'s {namespace constraint}, as defined by Wildcard Subset (§3.10.6).
1.4 One of the following must beis true:
1.4.1 The {content type} of the {base type definition} and the {content type} of the complex type definition itself both have {variety} simple and {simple type definition} the same simple type definition.
1.4.2 The {content type} of both the {base type definition} and the complex type definition itself have {variety} empty.
1.4.3 All of the following must beare true:
1.4.3.1 The {content type} of the complex type definition itself must specifyhas {variety} element-only or mixed.
1.4.3.2 One of the following must beis true:
1.4.3.2.1 The {content type} of the {base type definition} has {variety} empty.
1.4.3.2.2 All of the following must beare true:
1.4.3.2.2.1 Both {content type}s have {variety} mixed or both have {variety} element-only.
1.4.3.2.2.2 The {particle} of the {content type} of the complex type definition must beis a ·valid extension· of the {base type definition}'s {content type}'s {particle}, as defined in Particle Valid (Extension) (§3.9.6).
1.5 It must in principle beis in principle possible to derive the complex type definition in two steps, the first an extension and the second a restriction (possibly vacuous), from that type definition among its ancestors whose {base type definition} is the ·ur-type definition·.
Note: This requirement ensures that nothing removed by a restriction is subsequently added back by an extension. It is trivial to check if the extension in question is the only extension in its derivation, or if there are no restrictions bar the first from the ·ur-type definition·.

Constructing the intermediate type definition to check this constraint is straightforward: simply re-order the derivation to put all the extension steps first, then collapse them into a single extension. If the resulting definition can be the basis for a valid restriction to the desired definition, the constraint is satisfied.

1.6
The {assertions} of the {base type definition} is a prefix of the {assertions} of the complex type definition itself.
2 If the {base type definition} is a simple type definition, then all of the following must beare true:
2.1 The {content type}'s {variety} is simple and its {simple type definition} must beis the same simple type definition.
2.2 The {final} of the {base type definition} must notdoes not contain extension.
[Definition:]  If this constraint Derivation Valid (Extension) (§3.4.6) holds of a complex type definition, it is a valid extension of its {base type definition}.

[Definition:]   A complex type T is a valid extension of its {base type definition} if and only if T has a {derivation method} of extension and satisfies the constraint Derivation Valid (Extension) (§3.4.6).

Schema Component Constraint: Derivation Valid (Restriction, Complex)
If the {derivation method} is restriction all of the following mustmust be true:
1 The {base type definition} must beis a complex type definition whose {final} does not contain restriction.
2
For each attribute use (call this R) in the {attribute uses} the appropriate case among the following must beis true:
2.1 If there is an attribute use in the {attribute uses} of the {base type definition} (call this B) whose {attribute declaration} has the same {name} and {target namespace}, then all of the following must beare true:
2.1.1 one of the following must beis true:
2.1.1.1 B's {required} is false.
2.1.1.2 R's {required} is true.
2.1.2 R's {attribute declaration}'s {type definition} must beis validly derived from B's {type definition} given the empty set as defined in Type Derivation OK (Simple) (§3.15.6).
2.1.3 [Definition:]  Let the effective value constraint of an attribute use be its {value constraint}, if present, otherwise its {attribute declaration}'s {value constraint} . Then one of the following must beis true:
2.1.3.1 B's ·effective value constraint· is ·absent· or has {variety} default.
2.1.3.2 R's ·effective value constraint· has {variety} fixed and {value} identical to B's.
2.2 otherwise the {base type definition} must havehas an {attribute wildcard} and the ({target namespace}, {name}) pair of the R's {attribute declaration} must beis ·valid· with respect to that wildcard, as defined in Wildcard allows Namespace Name (§3.10.4)Wildcard allows Expanded Name (§3.10.4).
3
For each attribute use in the {attribute uses} of the {base type definition} whose {required} is true, there must beis an attribute use with an {attribute declaration} with the same {name} and {target namespace} as its {attribute declaration} in the {attribute uses} of the complex type definition itself whose {required} is true.
4
If there is an {attribute wildcard}, all of the following must beare true:
4.1 The {base type definition} must also havealso has one.
4.2 The complex type definition's {attribute wildcard}'s {namespace constraint} must beis a subset of the {base type definition}'s {attribute wildcard}'s {namespace constraint}, as defined by Wildcard Subset (§3.10.6).
4.3 Unless the {base type definition} is the ·ur-type definition·, the complex type definition's {attribute wildcard}'s {process contents} must beis identical to or stronger than the {base type definition}'s {attribute wildcard}'s {process contents}, where strict is stronger than lax is stronger than skip.
5 One of the following must beis true:
5.1 The {base type definition} must beis the ·ur-type definition·.
5.2 All of the following must beare true:
5.2.1 The {content type} of the complex type definition has {variety} simple
5.2.2 One of the following must beis true:
5.2.2.1 The {simple type definition} of the{content type} of the {base type definition} must beis a simple type definition from which the {content type}'s {simple type definition} is validly derived given the empty set as defined in Type Derivation OK (Simple) (§3.15.6).
5.2.2.2 The {base type definition}'s {content type} has {variety} mixed and have{particle} a Particle which is ·emptiable· as defined in Particle Emptiable (§3.9.6).
5.3 All of the following must beare true:
5.3.1 The {content type} of the complex type itself has {variety} empty
5.3.2 One of the following must beis true:
5.3.2.1 The {content type} of the {base type definition} must also bealso has {variety} empty.
5.3.2.2 The {content type} of the {base type definition} has {variety} elementOnly or mixed and have{particle} a Particle which is ·emptiable· as defined in Particle Emptiable (§3.9.6).
5.4 All of the following must beare true:
5.4.1 One of the following must beis true:
5.4.1.1 The {content type} of the complex type definition itself has {variety} element-only and the {content type} of the {base type definition} does not have {variety} simple.
5.4.1.2 The {content type} of the complex type definition itself and of the {base type definition} have {variety} mixed.
5.4.2
The {particle} of the {content type} of the complex type definition itself must be a ·valid restriction· of the {particle} of the {content type} of the {base type definition} as defined in Particle Valid (Restriction) (§3.9.6).
5.4.3
The {content type} of the complex type definition itself ·restricts· the {content type} of the {base type definition} as defined in Content type restricts (§3.4.6).
Note: Attempts to derive complex type definitions whose {content type} has {variety} element-only by restricting a {base type definition} whose {content type} has {variety} empty are not ruled out by this clause. However if the complex type definition itself has a non-pointless particle it will fail to satisfy Particle Valid (Restriction) (§3.9.6). On the other hand some type definitions with pointless element-only content, for example an empty <sequence>, will satisfy Particle Valid (Restriction) (§3.9.6) with respect to an empty {base type definition}, and so be valid restrictions. For purposes of checking this constraint, they are treated as attempts to restrict the empty sequence.
7
The {assertions} of the {base type definition} is a prefix of the {assertions} of the complex type definition itself.
[Definition:]   If this constraint Derivation Valid (Restriction, Complex) (§3.4.6) holds of a complex type definition, it is a valid restriction of its {base type definition} [Definition:]   A complex type definition with {derivation method} restriction is a valid restriction of its {base type definition} if and only if the constraint Derivation Valid (Restriction, Complex) (§3.4.6) is satisfied.
Note: In the definition of restriction in version 1.0 of this specification, it says

"Members of a type, A, whose definition is a restriction of the definition of another type, B, are always members of type B as well."

However no definition of membership in a type was provided, and this statement accordingly lacked force. We can now restate the intended sense of 'restriction' as follows:

A type definition R is a valid ·restriction· of another type definition B if and only if:

  1. All element information items which are ·abstractly valid· against R are ·abstractly valid· against B.
  2. When type definitions are assigned to children or attributes of an element information item in the PSVI by both R and B, those assigned by R are identical to or derived by one or more restriction or subsetting steps from the corresponding ones assigned by B.
  3. When element declarations are assigned to children or attributes of an element information item in the PSVI by both R and B, the corresponding ones assigned by R appeal to at least the same identity constraints, value constraints and disallowed substitutions as those assigned by B, and may appeal to stronger ones.
  4. Either B is the base type definition of R, or else the base type definition of R is a restriction of B.
Note: It will be noted that valid restriction involves both a subset relation on the set of elements valid against R and those valid against B, and an derivation relation, explicit in the type hierarchy, between the types assigned to attributes and child elements by R and those assigned to the same attributes and children by B.

[Definition:]  An attribute or element information item I is abstractly valid with respect to a simple or complex type definition D if and only if schema-validity assessment of I with respect to D (as defined by Schema-Validity Assessment (Element) (§3.3.4) or Schema-Validity Assessment (Attribute) (§3.2.4)) either results in a [validity] property of valid, or would result in [validity] of valid if constraints on the abstractness of type definitions and element declarations were ignored.

In practice, it is difficult to enforce the definition above directly as a Constraint on Components, owing to a number of corner cases which are difficult to detect or describe concisely. The following constraint is the operationally normative statement.

Schema Component Constraint: Complex type definition actually restricts
[Definition:]  A complex type definition R (for "restriction") actually restricts another type definition B (for "base") if and only if all of the following are true:
1 Every element information item which is ·locally valid· with respect to R is also ·locally valid· with respect to B.
2 If R and B have elementOnly or mixed as the {variety} of their {content type}s, then for all element information items E which are ·locally valid· with respect to R, for all children C of E, one of the following is true
2.1 Test[E,PR] is not defined for C.
2.2 all of the following are true:
2.2.1 Test[E,PB] and Test[E,PR] are both defined for C
2.2.2 Test[E,PB](C) subsumes Test[E,PR](C).
where PR is R's {content type}'s {particle} and PB is B's {content type}'s {particle}.

[Definition:]  An element information item is locally valid with respect to a complex type definition if and only if it satisfies all but the last clause of Element Locally Valid (Complex Type) (§3.4.4) with respect to that definition.

When the child sequence of an element information item E is ·locally valid· against a type definition whose {content type}'s {particle} is P there is a (partial) functional mapping from the element information items in the child sequence to tests, where tests are either Element Declarations, ·the ur-type· or empty, arising as follows:

Element Declarations
Either explicitly present, or successfully located as a result of a strict or lax Wildcard.
An undischarged lax Wildcard.
empty
a skip Wildcard.
(failure to map)
An undischarged strict Wildcard.
[Definition:]  Call this mapping Test[E,P].

[Definition:]  A test G (for general) subsumes another test S (for specific) if and only if one of the following is true

1 G is empty.
2 G is ·the ur-type· and S is not empty.
3 G and S are both Element Declarations and all of the following are true:
3.1 Either G has {nillable} true or S has {nillable} false.
3.2 Either G has no {value constraint}, or it is not fixed, or S has a fixed {value constraint} with the same value.
3.3 S's {identity-constraint definitions} are a superset of G's.
3.4 S disallows a superset of the substitutions that G does.
3.5 S's {type definition} is validly derived given {extension, list, union} from G's {type definition} as defined by Type Derivation OK (Complex) (§3.4.6) or Type Derivation OK (Simple) (§3.15.6), as appropriate.
Note: Implementing 'actually restricts' (§H) provides guidance to implementors on how to implement this constraint.
Schema Component Constraint: Content type restricts
Note: Checking content-type restriction (§I) provides guidance to implementors on how to implement this constraint.
[Definition:]  A Content Type RCT (for "restriction") restricts another Content Type BCT (for "base") if and only if the appropriate case among the following must be true:
1 If BCT's {variety} is empty, then either there is no sequence of element information items which is ·locally valid· with respect to RCT's {particle}, or only the empty sequence is.
2 otherwise Using the name R for RCT's {particle} and B for BCT's {particle}, all of the following are true:
2.1 Every sequence of element information items which is ·locally valid· with respect to R is also ·locally valid· with respect to B.
2.2 For all sequences of element information items ES which are ·locally valid· with respect to R, for all elements E in ES, . one of the following is true
2.2.1 ·Test[ES,R]· is not defined for E.
2.2.2 All of the following are true:
2.2.2.1 ·Test[ES,B]· and ·Test[ES,R]· are both defined for E

[Definition:]  A sequence of element information items is locally valid with respect to a Particle if and only if it satisfies Element Sequence Locally Valid (Particle) (§3.9.4.2) with respect to that Particle.

When a sequence of an element information items ES is ·locally valid· with respect to a Particle P there is a (partial) functional mapping from the element information items in the sequence to tests, where tests are either Element Declarations, ·the ur-type· or empty, arising as follows:

Element Declarations
Either explicitly present, or successfully located as a result of a strict or lax Wildcard.
An undischarged lax Wildcard.
empty
a skip Wildcard.
(failure to map)
An undischarged strict Wildcard.
[Definition:]  Call this mapping Test[ES,P].

[Definition:]  A test G (for general) subsumes another test S (for specific) if and only if one of the following is true

1 G is empty.
2 G is ·the ur-type· and S is not empty.
3 G and S are both Element Declarations and all of the following are true:
3.1 Either G has {nillable} true or S has {nillable} false.
3.2 Either G has no {value constraint}, or it is not fixed, or S has a fixed {value constraint} with the same value.
3.3 S's {identity-constraint definitions} are a superset of G's.
3.4 S disallows a superset of the substitutions that G does.
3.5 S's {type definition} is validly derived given {extension, list, union} from G's {type definition} as defined by Type Derivation OK (Complex) (§3.4.6) or Type Derivation OK (Simple) (§3.15.6), as appropriate.
Note: To restrict a complex type definition with a simple base type definition to empty, use a simple type definition with a fixed value of the empty string: this preserves the type information.

The following constraint defines a relation appealed to elsewhere in this specification.

Schema Component Constraint: Type Derivation OK (Complex)
For a complex type definition (call it D, for derived) to be validly derived from a type definition (call this B, for base) given a subset of {extension, restriction} all of the following mustmust be true:
1 If B and D are not the same type definition, then the {derivation method} of D must not beis not in the subset.
2 One of the following must beis true:
2.1 B and D must beare the same type definition.
2.2 B must beis D's {base type definition}.
2.3 All of the following must beare true:
2.3.1 D's {base type definition} must not beis not the ·ur-type definition·.
2.3.2 The appropriate case among the following must beis true:
2.3.2.1 If D's {base type definition} is complex, then it must beis validly derived from B given the subset as defined by this constraint.
2.3.2.2 If D's {base type definition} is simple, then it must beis validly derived from B given the subset as defined in Type Derivation OK (Simple) (§3.15.6).
Note: This constraint is used to check that when someone uses a type in a context where another type was expected (either via xsi:type or substitution groups), that the type used is actually derived from the expected type, and that that derivation does not involve a form of derivation which was ruled out by the expected type.

Note:

The wording of clause
2.1 above appeals to a notion of component identity which is only incompletely defined by this version of this specification. In some cases, the wording of this specification does make clear the rules for component identity. These cases include:
  • When they are both top-level components with the same component type, namespace name, and local name;
  • When they are necessarily the same type definition (for example, when the two types definitions in question are the type definitions associated with two attribute or element declarations, which are discovered to be the same declaration);
  • When they are the same by construction (for example, when an element's type definition defaults to being the same type definition as that of its substitution-group head or when a complex type definition inherits an attribute declaration from its base type definition).

In other cases two it is possible that conforming implementations maywill disagree as to whether components are identical.

3.4.7 Built-in Complex Type DefinitionDefinitions

There is a Complex Type Definition corresponding to the root of the type hierarchy present in every schema by definition:

Property
Value
rootType
http://www.w3.org/2001/XMLSchema
A Content Type as follows:
Property
Value
a Particle with the following properties: properties shown below in Outer particle for rootType (§3.4.7).
Property
Value
a model group with the following properties:
Property
Value
sequence
a list containing one particle with the following properties:
Property
Value
unbounded
a wildcard with the following properties:
Property
Value
any A Namespace Constraint with the following properties:
Property
Value
The empty set
The empty set
The empty set
a wildcard with the following properties::
Property
Value
any A Namespace Constraint with the following properties:
Property
Value
The empty set
The empty set
The empty set
The empty sequence

The outer particle of rootType contains a simple sequence:

Property
Value
a model group with the following properties:
Property
Value
sequence
a list containing one particle with the properties shown below in Inner particle for rootType (§3.4.7).

The inner particle of rootType contains a skip wildcard:

Property
Value
unbounded
a wildcard with the following properties:
Property
Value
any A Namespace Constraint with the following properties:
Property
Value
The empty set
The empty set

The mixed content specification together with the skip wildcard and attribute specification produce the defining property for the root of the type hierarchy, namely that every type definition is (eventually) a restriction of it: its permissions and requirements are the least restrictive possible.

There is also a complex type definition nearly equivalent to the ·ur-type definition·for ·anyType· present in every schema by definition. It has the following properties:

Property
Value
anyType
http://www.w3.org/2001/XMLSchema
The empty set
a wildcard with the following properties::
Property
Value
any A Namespace Constraint with the following properties:
Property
Value
The empty set
The empty set
The empty set
The empty sequence

The outer particle of ·anyType· contains a sequence with a single term:

Property
Value
a model group with the following properties:
Property
Value
sequence
a list containing one particle with the properties shown below in Inner Particle for Content Type of anyType (§3.4.7).

The inner particle of ·anyType· contains a wildcard which matches any element:

Property
Value
unbounded
a wildcard with the following properties:
Property
Value
any A Namespace Constraint with the following properties:
Property
Value
The empty set
The empty set
Note: This specification does not provide an inventory of built-in complex type definitions for use in user schemas. A preliminary library of complex type definitions is available which includes both mathematical (e.g. rational) and utility (e.g. array) type definitions. In particular, there is a text type definition which is recommended for use as the type definition in element declarations intended for general text content, as it makes sensible provision for various aspects of internationalization. For more details, see the schema document for the type library at its namespace name: http://www.w3.org/2001/03/XMLSchema/TypeLibrary.xsd.

previous sub-section next sub-section3.5 AttributeUses

An attribute use is a utility component which controls the occurrence and defaulting behavior of attribute declarations. It plays the same role for attribute declarations in complex types that particles play for element declarations.

Example
<xs:complexType>
 . . .
 <xs:attribute ref="xml:lang" use="required"/>
 <xs:attribute ref="xml:space" default="preserve"/>
 <xs:attribute name="version" type="xs:numberdecimal" fixed="1.0"/>
</xs:complexType>
     
XML representations which all involve attribute uses, illustrating some of the possibilities for controlling occurrence.

3.5.1 The Attribute Use Schema Component

The attribute use schema component has the following properties:

{required} determines whether this use of an attribute declaration requires an appropriate attribute information item to be present, or merely allows it.

{attribute declaration} provides the attribute declaration itself, which will in turn determine the simple type definition used.

{value constraint} allows for local specification of a default or fixed value. This must be consistent with that of the {attribute declaration}, in that if the {attribute declaration} specifies a fixed value, the only allowed {value constraint} is the same fixed value.

3.5.2 XML Representation of Attribute Use Components

Attribute uses correspond to all uses of <attribute> which allow a use attribute. These in turn correspond to two components in each case, an attribute use and its {attribute declaration} (although note the latter is not new when the attribute use is a reference to a top-level attribute declaration). The appropriate mapping is described in XML Representation of Attribute Declaration Schema Components (§3.2.2).

3.5.4 Attribute Use Validation Rules

Validation Rule: Attribute Locally Valid (Use)
The item's ·actual value· must matchmatches the {value} of the {value constraint}, if it is present and its {variety} is fixed.

For an attribute information item to be·valid· with respect to an attribute use its ·actual value· must be identical to the {value} of the attribute use's {value constraint}, if it is present and has {variety} fixed.

previous sub-section next sub-section3.6 Attribute Group Definitions

A schema can name a group of attribute declarations so that they may be incorporated as a group into complex type definitions.

Attribute group definitions do not participate in ·validation· as such, but the {attribute uses} and {attribute wildcard} of one or more complex type definitions may be constructed in whole or part by reference to an attribute group. Thus, attribute group definitions provide a replacement for some uses of XML's parameter entity facility. Attribute group definitions are provided primarily for reference from the XML representation of schema components (see <complexType> and <attributeGroup>).

Example
<xs:attributeGroup name="myAttrGroup">
    <xs:attribute . . ./>
    . . .
</xs:attributeGroup>

<xs:complexType name="myelement">
    . . .
    <xs:attributeGroup ref="myAttrGroup"/>
</xs:complexType>
XML representations for attribute group definitions. The effect is as if the attribute declarations in the group were present in the type definition.

3.6.1 The Attribute Group Definition Schema Component

The attribute group definition schema component has the following properties:

Attribute groups are identified by their {name} and {target namespace}; attribute group identities must be unique within an ·XML Schema·. See References to schema components across namespaces (<import>) (§4.2.3) for the use of component identifiers when importing one schema into another.

{attribute uses} is a set attribute uses, allowing for local specification of occurrence and default or fixed values.

{attribute wildcard} provides for an attribute wildcard to be included in an attribute group. See above under Complex Type Definitions (§3.4) for the interpretation of attribute wildcards during ·validation·.

See Annotations (§3.14) for information on the role of the {annotations} property.

3.6.2 XML Representation of Attribute Group Definition Schema Components

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 and properties of the component it corresponds to are as follows:

XML Representation Summary: attributeGroup Element Information Item

<attributeGroup
  id = ID
  name = NCName
  ref = QName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))
</attributeGroup>

When an <attributeGroup> appears as a daughter of <schema> or <redefine>, it corresponds to an attribute group definition as below. When it appears as a daughter of <complexType> or <attributeGroup>, it does not correspond to any component as such.
Attribute Group Definition Schema Component
Property
Representation
 
 
The ·actual value· of the targetNamespace [attribute] of the parent schema element information item.
 
The union of the set of attribute uses corresponding to the <attribute> [children], if any, with the {attribute uses} of the attribute groups ·resolved· to by the ·actual value·s of the ref [attribute] of the <attributeGroup> [children], if any.
 
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.

The example above illustrates a pattern which recurs in the XML representation of schemas: The same element, in this case attributeGroup, serves both to define and to incorporate by reference. In the first case the name attribute is required, in the second the ref attribute is required, and the element must be empty. These two are mutually exclusive, and also conditioned by context: the defining form, with a name, must occur at the top level of a schema, whereas the referring form, with a ref, must occur within a complex type definition or an attribute group definition.

3.6.3 Constraints on XML Representations of Attribute Group Definitions

Schema Representation Constraint: Attribute Group Definition Representation OK
In addition to the conditions imposed on <attributeGroup> element information items by the schema for schemas, all of the following must be truealso apply :
1 The corresponding attribute group definition, if any, must satisfy the conditions set out in Constraints on Attribute Group Definition Schema Components (§3.6.6).
2
If clause 2.2.1 or clause 2.2.2 in the correspondence specification in XML Representation of Complex Type Definitions (§3.4.2) for {attribute wildcard}, as referenced above, is satisfied, the intensional intersection must be expressible, as defined in Attribute Wildcard Intersection (§3.10.6).
3 Circular group reference is disallowed outside <redefine>. That is, unless this element information item's parent is <redefine>, then among the [children], if any, there must not be an <attributeGroup> with ref [attribute] which resolves to the component corresponding to this <attributeGroup>. Indirect circularity is also ruled out. That is, when QName resolution (Schema Document) (§3.16.3) is applied to a ·QName· arising from any <attributeGroup>s with a ref [attribute] among the [children], it must not be the case that a ·QName· is encountered at any depth which resolves to the component corresponding to this <attributeGroup>.

previous sub-section next sub-section3.7 Model Group Definitions

A model group definition associates a name and optional annotations with a Model Group. By reference to the name, the entire model group can be incorporated by reference into a {term}.

Model group definitions are provided primarily for reference from the XML Representation of Complex Type Definitions (§3.4.2) (see <complexType> and <group>). Thus, model group definitions provide a replacement for some uses of XML's parameter entity facility.

Example
<xs:group name="myModelGroup">
 <xs:sequence>
  <xs:element ref="someThing"/>
  . . .
 </xs:sequence>
</xs:group>

<xs:complexType name="trivial">
 <xs:group ref="myModelGroup"/>
 <xs:attribute .../>
</xs:complexType>

<xs:complexType name="moreSo">
 <xs:choice>
  <xs:element ref="anotherThing"/>
  <xs:group ref="myModelGroup"/>
 </xs:choice>
 <xs:attribute .../>
</xs:complexType>
A minimal model group is defined and used by reference, first as the whole content model, then as one alternative in a choice.

3.7.1 The Model Group Definition Schema Component

The model group definition schema component has the following properties:

Model group definitions are identified by their {name} and {target namespace}; model group identities must be unique within an ·XML Schema·. See References to schema components across namespaces (<import>) (§4.2.3) for the use of component identifiers when importing one schema into another.

Model group definitions per se do not participate in ·validation·, but the {term} of a particle may correspond in whole or in part to a model group from a model group definition.

{model group} is the Model Group for which the model group definition provides a name.

See Annotations (§3.14) for information on the role of the {annotations} property.

3.7.2 XML Representation of Model Group Definition Schema Components

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 and properties of the component it corresponds to are as follows:

XML Representation Summary: 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>

If there is a name [attribute] (in which case the item will have <schema> or <redefine> as parent), then the item corresponds to a model group definition component with properties as follows:
Model Group Definition Schema Component
Property
Representation
 
 
The ·actual value· of the targetNamespace [attribute] of the parent schema element information item.
 
A model group which is the {term} of a particle corresponding to the <all>, <choice> or <sequence> among the [children] (there must be one).
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.
Otherwise, the item will have a ref [attribute], in which case it corresponds to a particle component with properties as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):
Particle Schema Component
Property
Representation
 
The ·actual value· of the minOccurs [attribute], if present, otherwise 1.
 
unbounded, if the maxOccurs [attribute] equals unbounded, otherwise the ·actual value· of the maxOccurs [attribute], if present, otherwise 1.
 
The {model group} of the model group definition ·resolved· to by the ·actual value· of the ref [attribute]

The name of this section is slightly misleading, in that the second, un-named, case above (with a ref and no name) is not really a named model group at all, but a reference to one. Also note that in the first (named) case above no reference is made to minOccurs or maxOccurs: this is because the schema for schemas does not allow them on the child of <group> when it is named. This in turn is because the {min occurs} and {max occurs} of the particles which refer to the definition are what count.

Given the constraints on its appearance in content models, an <all> shouldmust only occur as the only item in the [children] of a named model group definition or a content model: see Constraints on Model Group Schema Components (§3.8.6).

previous sub-section next sub-section3.8 Model Groups

When the [children] of element information items are not constrained to be empty or by reference to a simple type definition (Simple Type Definitions (§3.15)), the sequence of element information item [children] content may be specified in more detail with a model group. Because the {term} property of a particle can be a model group, and model groups contain particles, model groups can indirectly contain other model groups; the grammar for content models is therefore recursive. [Definition:]  A model group directly contains the particles in the value of its {particles} property. [Definition:]  A model group indirectly contains the particles, groups, wildcards, and element declarations which are ·contained· by the particles it ·directly contains·. [Definition:]  A model group contains the components which it either ·directly contains· or ·indirectly contains·.

Example
<xs:all>
 <xs:element ref="cats"/>
 <xs:element ref="dogs"/>
</xs:all>

<xs:sequence>
 <xs:choice>
  <xs:element ref="left"/>
  <xs:element ref="right"/>
 </xs:choice>
 <xs:element ref="landmark"/>
</xs:sequence>
XML representations for the three kinds of model group, the third nested inside the second.

3.8.1 The Model Group Schema Component

The model group schema component has the following properties:

specifies a sequential (sequence), disjunctive (choice) or conjunctive (all) interpretation of the {particles}. This in turn determines whether the element information item [children] ·validated· by the model group must:

  • (sequence) correspond, in order, to the specified {particles};
  • (choice) corresponded to exactly one of the specified {particles};
  • (all) contain all and only exactly zero or one of each element specified in {particles}. The elements can occur in any order. In this case, to reduce implementation complexity, {particles} is restricted to contain local and top-level element declarations only, with {min occurs}=0 or 1, {max occurs}=1.

When two or more particles contained directly or indirectly in the {particles} of a model group have identically named element declarations as their {term}, the type definitions of those declarations must be the same. By 'indirectly' is meant particles within the {particles} of a group which is itself the {term} of a directly contained particle, and so on recursively.

See Annotations (§3.14) for information on the role of the {annotations} property.

3.8.2 XML Representation of Model Group Schema Components

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 and properties of the component they correspond to are as follows:

XML Representation Summary: all Element Information Item

<all
  id = ID
  maxOccurs = 1 : 1
  minOccurs = (0 | 1) : 1
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (element | any)*)
</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>

Each of the above items corresponds to a particle containing a model group, with properties as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):
Particle Schema Component
Property
Representation
 
The ·actual value· of the minOccurs [attribute], if present, otherwise 1.
 
unbounded, if the maxOccurs [attribute] equals unbounded, otherwise the ·actual value· of the maxOccurs [attribute], if present, otherwise 1.
 
A model group as given below:
Model Group Schema Component
Property
Representation
 
One of all, choice, sequence depending on the element information item.
 
A sequence of particles corresponding to all the <all>, <choice>, <sequence>, <any>, <group> or <element> items among the [children], in order.
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.

3.8.4 Model Group Validation Rules

3.8.4.1 Language Recognition by Groups

Each model group M denotes a language L(M), whose members are the sequences of element information items ·accepted· by M.

Within L(M) a smaller language V(M) can be identified, which is of particular importance for schema-validity assessment. The difference between the two languages is that V(M) enforces some constraints which are ignored in the definition of L(M). Informally L(M) is the set of sequences which are accepted by a model group if no account is taken of the schema component constraint Unique Particle Attribution (§3.8.6) or the related provisions in the validation rules which specify how to choose a unique ·path· in a non-deterministic content model. By contrast, V(M) takes account of those constraints and includes only the sequences which are ·locally valid· against M. For all model groups M, V(M) is a subset of L(M). L(M) and related concepts are described in this section; V(M) is described in the next section, Principles of Validation against Groups (§3.8.4.2).

[Definition:]  When a sequence S of element information items is checked against a model group M, the sequence of ·basic particles· which the items of S match, in order, is a path of S in M. For a given S and P, the path of S in P is not necessarily unique. Detailed rules for the matching, and thus for the construction of paths, are given in Language Recognition by Groups (§3.8.4.1) and Principles of Validation against Particles (§3.9.4.1). Not every sequence has a path in every content model, but every sequence accepted by the content model does have a path. [Definition:]  For a content model M and a sequence S in L(M), the path of S in M is a complete path; prefixes of complete paths which are themselves not complete paths are incomplete paths. For example, in the content model

   <xsd:sequence>
    <xsd:element name="a"/>
    <xsd:element name="b"/>
    <xsd:element name="c"/>
   </xsd:sequence>

the sequences (<a/><b/><c/>) and (<a/><b/>) have ·paths· (the first a ·complete path· and the second an ·incomplete path·), but the sequences (<a/><b/><c/><d/>) and (<a/><x/>) do not have paths.

Note: It is possible, but unusual, for a content model to have some paths which are neither complete paths, nor prefixes of complete paths. For example, the content model
   <xsd:sequence>
    <xsd:element name="a"/>
    <xsd:element name="b"/>
    <xsd:choice/>
   </xsd:sequence>
accepts no sequences because the empty choice recognizes no input sequences. But the sequences (</a>) and (</a><b/>) have paths in the content model.

The definitions of L(M) and ·paths· in M, when M is a ·basic term· or a ·basic particle·, are given in Principles of Validation against Particles (§3.9.4.1). The definitions for groups are given below.

3.8.4.1.1 Sequences

This section defines L(M), the set of ·paths· in M, and V(M), if M is a sequence group.

If M is a Model Group, and the {compositor} of M is sequence, and the {particles} of M is the sequence P1, P2, ..., Pn, then L(M) is the set of sequences S = S1 + S2 + ... + Sn (taking "+" as the concatenation operator), where Si is in L(Pi) for 0 < in. The sequence of sequences S1, S2, ..., Sn is a ·partition· of S. Less formally, when M is a sequence of P1, P2, ... Pn, then L(M) is the set of sequences formed by taking one sequence which is accepted by P1, then one accepted by P2, and so on, up through Pn, and then concatenating them together in order.

[Definition:]  A partition of a sequence is a sequence of sub-sequences, some or all of which may be empty, such that concatenating all the sub-sequences yields the original sequence.

When M is a sequence group and S is a sequence of input items, the set of ·paths· of S in M is the set of all paths Q = Q1 + Q2 + ... + Qj, where

  • jn, and
  • S = S1 + S2 + ... + Sj (i.e. S1, S2, ..., Sj is a ·partition· of S), and
  • Si is in L(Pi) for 0 < i < j, and
  • Qi is a ·path· of Si in Pi for 0 < ij.

Example
By this definition, some sequences which do not satisfy the entire content model nevertheless have ·paths· in a content model. For example, given the content model P
   <xsd:sequence>
    <xsd:element name="a"/>
    <xsd:element name="b"/>
    <xsd:element name="c"/>
   </xsd:sequence>
<a/><b/>
and an input sequence Swhere n = 3, j = 2, then S1 is (<a/>), S2 is (<b/>), and S has a ·path· in P, even though S is not in L(P). The ·path· has two items, first the Particle for the a element, then the Particle for the b element.

When M is a sequence group, the set V(M) (the set of sequences ·locally valid· against M) is the set of sequences S which are in L(M) and which have a ·validation-path· in M. Informally, V(M) contains those sequences which are accepted by M and for which no element information item is ever ·attributed to· a ·wildcard particle· if it can, in context, instead be ·attributed to· an ·element particle·. There will invariably be a ·partition· of S whose members are ·locally valid· against the sub-sequences of P.

Note: For sequences with more than one ·path· in M, the ·attributions· of the ·validation-path· are used in validation and for determining the contents of the ·post-schema-validation infoset·. For example, if M is
  <xsd:sequence>
   <xsd:any minOccurs="0"/>
   <xsd:element name="a" minOccurs="0"/>
  </xsd:sequence>
then the sequence (<a/>) has two ·paths· in M, one containing just the ·wildcard particle· and the other containing just the ·element particle·. It is the latter which is a ·validation-path· and which determines which Particle the item in the input is ·attributed to·.
Note: There are model groups for which some members of L(M) are not in V(M). For example, if M is
  <xsd:sequence>
   <xsd:any minOccurs="0"/>
   <xsd:element name="a"/>
  </xsd:sequence>
then the sequence (<a/><a/>) is in L(M), but not in V(M), because the validation rules require that the first a be ·attributed to· the ·wildcard particle·. In a ·validation-path· the initial a will invariably be ·attributed to· the ·element particle·, and so no sequence with an initial a can be ·locally valid· against this model group.
3.8.4.1.2 Choices

This section defines L(M), the set of ·paths· in M, and V(M), if M is a choice group.

When the {compositor} of M is choice, and the {particles} of M is the sequence P1, P2, ..., Pn, then L(M) is L(P1) ∪ L(P2) ∪ ... ∪ L(Pn), and the set of ·paths· of S in P is the set Q = Q1Q2 ∪ ... ∪ Qn, where Qi is the set of ·paths· of S in Pi, for 0 < in. Less formally, when M is a choice of P1, P2, ... Pn, then L(M) contains any sequence accepted by any of the particles P1, P2, ... Pn, and any ·path· of S in any of the particles P1, P2, ... Pn is a ·path· of S in P.

The set V(M) (the set of sequences ·locally valid· against M) is the set of sequences S which are in L(M) and which have a ·validation-path· in M. In effect, this means that if one of the choices in M ·attributed· an initial element information item to a ·wildcard particle·, and another ·attributed· the same item to an ·element particle·, then the latter choice is used for validation.

Note: For example, if M is
  <xsd:choice>
   <xsd:any/>
   <xsd:element name="a"/>
  </xsd:choice>
then the ·validation-path· for the sequence (<a/>) contains just the ·element particle· and it is to the ·element particle· that the input element will be ·attributed·; the alternate ·path· containing just the ·wildcard particle· is not relevant for validation as defined in this specification.
3.8.4.1.3 All-groups

This section defines L(M), the set of ·paths· in M, and V(M), if M is an all-group.

When the {compositor} of M is all, and the {particles} of M is the sequence P1, P2, ..., Pn, then L(M) is the set of sequences S = S1 × S2 × ... × Sn (taking "×" as the interleave operator), where for 0 < in, Si is in L(Pi). The set of sequences {S1, S2, ..., Sn} is a ·grouping· of S. The set of ·paths· of S in P is the set of all ·paths· Q = Q1 × Q2 × ... × Qn, where Qi is a ·path· of Si in Pi, for 0 < in.

Less formally, when M is an all-group of P1, P2, ... Pn, then L(M) is the set of sequences formed by taking one sequence which is accepted by P1, then one accepted by P2, and so on, up through Pn, and then interleaving them together. Equivalently, L(M) is the set of sequences S such that the set {S1, S2, ..., Sn} is a ·grouping· of S, and for 0 < in, Si is in L(Pi).

[Definition:]  A grouping of a sequence is a set of sub-sequences, some or all of which may be empty, such that each member of the original sequence appears once and only once in one of the sub-sequences and all members of all sub-sequences are in the original sequence.

For example, given the content model P

  <xsd:all>
   <xsd:element name="a" minOccurs="0" maxOccurs="5">
   <xsd:element name="b" minOccurs="1" maxOccurs="1">
   <xsd:element name="c" minOccurs="0" maxOccurs="5">
   </xsd:element>
  </xsd:all>

and an input sequence S

<a/><b/><a/>

where n = 3, then S1 is (<a/><a/>), S2 is (<b/>), and the ·path· of S in P is the sequence containing first the Particle for the a element, then the Particle for the b element, then once more the Particle for the a element.

The set V(M) (the set of sequences ·locally valid· against M) is the set of sequences S which are in L(M) and which have a ·validation-path· in M. In effect, this means that if one of the Particles in M ·attributed· an element information item to a ·wildcard particle·, and a ·competing· Particle ·attributed· the same item to an ·element particle·, then the ·element particle· is used for validation.

Note: For example, if M is
  <xsd:all>
   <xsd:any/>
   <xsd:element name="a"/>
  </xsd:all>
then M accepts sequences of length two, containing one a element and one other element.

The other element can be anything at all, including a second a element. After the first a the ·element particle· accepts no more elements and so no longer ·competes· with the ·wildcard particle·. So if the sequence (<a/><a/>) is checked against M, in the ·validation-path· the first a element will be ·attributed to· the ·element particle· and the second to the ·wildcard particle·.

3.8.4.1.4 Multiple Paths in Groups

It is possible for a given sequence of element information items to have multiple ·paths· in a given model group M; this is the case, for example, when M is ambiguous, as for example

  <xsd:choice>
   <xsd:sequence>
    <xsd:element ref="my:a" maxOccurs="unbounded"/>
    <xsd:element ref="my:b"/>
   </xsd:sequence>
   <xsd:sequence>
    <xsd:element ref="my:a"/>
    <xsd:element ref="my:b" maxOccurs="unbounded"/>
   </xsd:sequence>
  </xsd:choice>

which can match the sequence (<a/><b/>) in more than one way. It may also be the case with unambiguous model groups, if they do not correspond to a deterministic expression (as it is termed in [XML 1.1]). For example,

  <xsd:sequence>
   <xsd:element name="a" minOccurs="0"/>
   <xsd:element name="a"/>
  </xsd:sequence>
Note: Because these model groups do not obey the constraint Unique Particle Attribution (§3.8.6), they cannot appear in a valid schema.
3.8.4.2 Principles of Validation against Groups

As noted above, each model group M denotes a language L(M), whose members are sequences of element information items. Each member of L(M) has one or more ·paths· in M, as do other sequences of element information items.

By imposing conditions on ·paths· in a model group M it is possible to identify a set of ·validation-paths· in M, such that if M is a model group which obeys the Unique Particle Attribution (§3.8.6) constraint, then any sequence S has at most one ·validation-path· in M. The language V(M) can then be defined as the set of sequences which have ·validation-paths· in M.

[Definition:]  Two Particles P1 and P2 contained in some Particle P compete with each other if and only if some sequence S of element information items has two ·paths· in P which are identical except that one path has P1 as its last item and the other has P2.

For example, in the content model

  <xsd:sequence>
   <xsd:element name="a"/>
   <xsd:choice>
    <xsd:element name="b"/>
    <xsd:any/>
   </xsd:choice>
  </xsd:sequence>

the sequence (<a/><b/>) has two paths, one (Q1) consisting of the Particle whose {term} is the declaration for a followed by the Particle whose {term} is the declaration for b, and a second (Q2) consisting of the Particle whose {term} is the declaration for a followed by the Particle whose {term} is the wildcard. The sequences Q1 and Q2 are identical except for their last items, and so the two Particles which are the last items of Q1 and Q2 are said to ·compete· with each other.

By contrast, in the content model

  <xsd:choice>
   <xsd:sequence>
    <xsd:element name="a"/>
    <xsd:element name="b"/>
   </xsd:sequence>
   <xsd:sequence>
    <xsd:element name="c"/>
    <xsd:any/>
   </xsd:sequence>
  </xsd:choice>

the Particles for b and the wildcard do not compete, because there is no pair of ·paths· in P which differ only in one having the ·element particle· for b and the other having the ·wildcard particle·.

[Definition:]  Two (or more) ·paths· of a sequence S in a Particle P are competing paths if and only if they are identical except for their final items, which differ.

[Definition:]  For any sequence S of element information items and any particle P, a ·path· of S in P is a validation-path if and only if for each prefix of the ·path· which ends with a ·wildcard particle·, the corresponding prefix of S has no ·competing path· which ends with an ·element particle·.

Note: It is a consequence of the definition of ·validation-path· that for any content model M which obeys constraint Unique Particle Attribution (§3.8.6) and for any sequence S of element information items, S has at most one ·validation-path· in M.

[Definition:]  A sequence S of element information items is locally valid against a particle P if and only if S has a ·validation-path· in P. The set of all such sequences is written V(P).

3.8.4.3 Validation Rules
Validation Rule: Element Sequence Valid
[Definition:]  Define a partition of a sequence as a sequence of sub-sequences, some or all of which may be empty, such that concatenating all the sub-sequences yields the original sequence.

For a sequence (possibly empty) of element information items to be locally ·valid· with respect to a model group the appropriate case among the following mustmust be true:

1 If the {compositor} is sequence, then there must be a ·partition· of the sequence into n sub-sequences where n is the length of {particles} such that each of the sub-sequences in order is ·valid· with respect to the corresponding particle in the {particles} as defined in Element Sequence Locally Valid (Particle) (§3.9.4.2).
2 If the {compositor} is choice, then there must be a particle among the {particles} such that the sequence is ·valid· with respect to that particle as defined in Element Sequence Locally Valid (Particle) (§3.9.4.2).
3 If the {compositor} is all, then there must be a ·partition· of the sequence into n sub-sequences where n is the length of {particles} such that there is a one-to-one mapping between the sub-sequences and the {particles} where each sub-sequence is ·valid· with respect to the corresponding particle as defined in Element Sequence Locally Valid (Particle) (§3.9.4.2).

Nothing in the above should be understood as ruling out groups whose {particles} is empty: although no sequence can be ·valid· with respect to such a group whose {compositor} is choice, the empty sequence is ·valid· with respect to empty groups whose {compositor} is sequence or all.

Validation Rule: Element Sequence Valid
For a sequence S (possibly empty) of element information items to be locally ·valid· with respect to a model group M, S must be in V(M).
Note: It is possible to define groups whose {particles} is empty. When a choice-group M has an empty {particles} property, then L(M) is the empty set. When M is a sequence- or all-group with an empty {particles} property, then L(M) is the set containing the empty (zero-length) sequence.
Note: The above definition is implicitly non-deterministic, and should not be taken as a recipé for implementations. Note in particular that when {compositor} is all, the particles is restricted to a list of local and top-level element declarations (see Constraints on Model Group Schema Components (§3.8.6)). A much simpler implementation is possible than would arise from a literal interpretation of the definition above; informally, the content is ·valid· when each declared element occurs exactly once (or at most once, if {min occurs} is 0), and each is ·valid· with respect to its corresponding declaration. The elements can occur in arbitrary order.

3.8.6 Constraints on Model Group Schema Components

All model groups (see Model Groups (§3.8)) must satisfy the following constraints.

Schema Component Constraint: Model Group Correct
All of the following mustmust be true:
2 Circular groups are disallowed.There are no circular groups. That is, within the {particles} of a group there must not be at any depth a particleis no particle at any depth whose {term} is the group itself.
Schema Component Constraint: All Group Limited
When a model group has {compositor} all, then all of the following mustmust be true:
1 It appears only as the value of one or both of the following properties:
1.1 the {model group} property of a model group definition.
1.2 the {term} property of a Particle with {max occurs}=1which is the {particle} of the {content type} of a complex type definition.
2
The {max occurs} of all the particles in the {particles} of the group must be 0 or 1.
Schema Component Constraint: Element Declarations Consistent
Issue (RQ-146i):Issue 2544 (RQ-146 element declarations consistent)

Some corner cases, e.g. involving 'skip' wildcards, have emerged with respect to this constraint. It will be restated at a higher level of abstraction, in terms of desired outcome. See also (§3.4).

Resolution:

This constraint will be restated in terms of intended outcome, i.e. that (modulo the impact of xsi:type) validation of an EII with a type definition will always assign the same type definitions to elements or attributes of the same name.

If the {particles} contains, either directly, indirectly (that is, within the {particles} of a contained model group, recursively) or ·implicitly· two or more element declaration particles with the same {name} and {target namespace}, then all their type definitions must be the same top-level definition, that is, all of the following mustmust be true:
1 all their {type definition}s must have a non-·absent··non-absent· {name}.
2 all their {type definition}s must have the same {name}.
3 all their {type definition}s must have the same {target namespace}.

[Definition:]  A list of particles implicitly contains an element declaration if and only if a member of the list contains that element declaration in its ·substitution group·.

[Definition:]   The attributions of a sequence S of element information items, when S is checked against a particle P, are the ·element· or ·wildcard particles· in P with which the items in S are matched. It is the sequence of these Particles which forms the ·path· of S in P. When Particle is non-deterministic, then each element information item in S is attributed to to the Particle it matches up with in the unique ·validation-path·, not to any other Particle. Element information items are attributed to ·element particles· only when the element's expanded name ·matches· the {term} of the Particle, and to ·wildcard particles· only then the element's namespace ·matches· the Wildcard. In addition, the ·attribution· of element information items to Particles must respect the structure (sequence, choice, {min occurs} and {max occurs}, etc.) of the Particle and of Particles nested within its {term}. The rules are given in more detail in Language Recognition by Groups (§3.8.4.1) and Language Recognition for Repetitions (§3.9.4.1), and in Validation Rule Element Sequence Accepted (Particle) (§3.9.4.2).

[Definition:]   An element particle is a Particle whose {term} is an Element Declaration. [Definition:]   A wildcard particle is a Particle whose {term} is a Wildcard.

Schema Component Constraint: Unique Particle Attribution
A content model must be formed such that during ·validation· of an element information item sequence, the particle component contained directly, indirectly or ·implicitly· therein with which to attempt to ·validate· each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.

A content model must not contain two ·element particles· which ·compete· with each other, nor two ·wildcard particles· which ·compete· with each other.
Note: Content models in which an ·element particle· and a ·wildcard particle· ·compete· with each other are not prohibited. In such cases, the Element Declaration is chosen; see the definitions of ·attribution· and ·validation-path·.
Note: This constraint reconstructs for XML Schema the equivalent constraints of [XML 1.1] and SGML. Given the presence of element substitution groups and wildcards, the concise expression of this constraint is difficult, seeSee Analysis of the Unique Particle Attribution Constraint (non-normative) (§M) for further discussion.

Since this constraint is expressed at the component level, it applies to content models whose origins (e.g. via type derivation and references to named model groups) are no longer evident. So particles at different points in the content model are always distinct from one another, even if they originated from the same named model group.

Note: It is a consequence of Unique Particle Attribution (§3.8.6), together with the definition of ·validation-path·, that any sequence S of element information items has at most one ·validation-path· in any particle P. This means in turn that each item in S is attributed to at most one particle in P. No item can match more than one Wildcard or more than one Element Declaration (because no two ·wildcard particles· and no two ·element particles· may ·compete·), and if an item matches both a ·wildcard particle· and an ·element particle·, it is ·attributed· by the rules for ·validation-paths· to the ·element particle·.
Note: Because locally-scoped element declarations may or may not have a {target namespace}, the scope of declarations is not relevant to enforcing either of the two preceding constraintsthe Unique Particle Attribution (§3.8.6) constraint or the Element Declarations Consistent (§3.8.6) constraint.

The following constraints define relations appealed to elsewhere in this specification.

Schema Component Constraint: Effective Total Range (all and sequence)
The effective total range of a particle whose {term} is a group whose {compositor} is all or sequence is a pair of minimum and maximum, as follows:
minimum
The product of the particle's {min occurs} and the sum of the {min occurs} of every wildcard or element declaration particle in the group's {particles} and the minimum part of the effective total range of each of the group particles in the group's {particles} (or 0 if there are no {particles}).
maximum
unbounded if the {max occurs} of any wildcard or element declaration particle in the group's {particles} or the maximum part of the effective total range of any of the group particles in the group's {particles} is unbounded, or if any of those is non-zero and the {max occurs} of the particle itself is unbounded, otherwise the product of the particle's {max occurs} and the sum of the {max occurs} of every wildcard or element declaration particle in the group's {particles} and the maximum part of the effective total range of each of the group particles in the group's {particles} (or 0 if there are no {particles}).
Schema Component Constraint: Effective Total Range (choice)
The effective total range of a particle whose {term} is a group whose {compositor} is choice is a pair of minimum and maximum, as follows:
minimum
The product of the particle's {min occurs} and the minimum of the {min occurs} of every wildcard or element declaration particle in the group's {particles} and the minimum part of the effective total range of each of the group particles in the group's {particles} (or 0 if there are no {particles}).
maximum
unbounded if the {max occurs} of any wildcard or element declaration particle in the group's {particles} or the maximum part of the effective total range of any of the group particles in the group's {particles} is unbounded, or if any of those is non-zero and the {max occurs} of the particle itself is unbounded, otherwise the product of the particle's {max occurs} and the maximum of the {max occurs} of every wildcard or element declaration particle in the group's {particles} and the maximum part of the effective total range of each of the group particles in the group's {particles} (or 0 if there are no {particles}).

previous sub-section next sub-section3.9 Particles

As described in Model Groups (§3.8), particles contribute to the definition of content models.

When an element is validated against a complex type, its sequence of child elements is checked against the content model of the complex type and the children are ·attributed to· to Particles of the content model. The attribution of items to Particles partially determines the calculation of the items' ·context-determined declarations·: When an element information item is ·attributed to· an ·element particle·, that Particle's Element Declaration, or an Element Declaration ·validly substitutable· for it, becomes the item's ·context-determined declaration·; when the item is ·attributed to· a ·wildcard particle·, the ·context-determined declaration· depends on the variety of the wildcard.

Example
<xs:element ref="egg" minOccurs="12" maxOccurs="12"/>

<xs:group ref="omelette" minOccurs="0"/>

<xs:any maxOccurs="unbounded"/>
     
XML representations which all involve particles, illustrating some of the possibilities for controlling occurrence.

3.9.1 The Particle Schema Component

The particle schema component has the following properties:

In general, multiple element information item [children], possibly with intervening character [children] if the content type is mixed, can be ·validated· with respect to a single particle. When the {term} is an element declaration or wildcard, {min occurs} determines the minimum number of such element [children] that can occur. The number of such children must be greater than or equal to {min occurs}. If {min occurs} is 0, then occurrence of such children is optional.

Again, when the {term} is an element declaration or wildcard, the number of such element [children] must be less than or equal to any numeric specification of {max occurs}; if {max occurs} is unbounded, then there is no upper bound on the number of such children.

When the {term} is a model group, the permitted occurrence range is determined by a combination of {min occurs} and {max occurs} and the occurrence ranges of the {term}'s {particles}.

[Definition:]  A particle directly contains the component which is the value of its {term} property. [Definition:]  A particle indirectly contains the particles, groups, wildcards, and element declarations which are contained by the value of its {term} property. [Definition:]  A particle contains the components which it either ·directly contains· or ·indirectly contains·.

3.9.2 XML Representation of Particle Components

Particles correspond to all three elements (<element> not immediately within <schema>, <group> not immediately within <schema> and <any>) which allow minOccurs and maxOccurs attributes. These in turn correspond to two components in each case, a particle and its {term}. The appropriate mapping is described in XML Representation of Element Declaration Schema Components (§3.3.2), XML Representation of Model Group Schema Components (§3.8.2) and XML Representation of Wildcard Schema Components (§3.10.2) respectively.

3.9.4 Particle Validation Rules

3.9.4.1 Principles of Validation against Particles

Every particle P ·recognizes· some language L(P). When {min occurs} and {max occurs} of P are both 1, L(P) is the language of P's {term}. The following section (Language Recognition for Repetitions (§3.9.4.1)) describes how more complicated counts are handled.

3.9.4.1.1 Language Recognition for Repetitions

When {min occurs} of P = {max occurs} of P = n, and T is the {term} of P, then L(P) is the set of sequences S = S1 + S2 + ... + Snsuch that Si is in L(T) for 0 < in. Less formally: L(P) is the set of sequences which have ·partitions· into n sub-sequences for which each of the n subsequences is in the language accepted by the {term} of P.

When {min occurs} = j and {max occurs} = k, and T is the {term} of P, then L(P) is the set of sequences S = S1, + S2 + ... + Sn, i.e. the set of sequences which have ·partitions· into n sub-sequences such that nj and nk (or k is unbounded) and Si is in L(T) for 0 < in.

When {min occurs} = 0, then L(P) also includes the empty sequence.

If (1) Particle P has {min occurs} = j, {max occurs} = k, and {term} = T, and (2) S is a sequence of element information items such that S = S1 + S2 + ... + Sn (i.e. S1, S2, ..., Sn is a ·partition· of S), and (3) nk (or k is unbounded), and (4) Si is in L(T) for 0 < i < n, then:

Note:  Informally: the path of an input sequence S in a particle P may go through the ·basic particles· in P as many times as is allowed by the {max occurs} of P. If the path goes through P more than once, each time before the last one must correspond to a sequence accepted by the {term} of P; because the last iteration in the path may not be complete, it need not be accepted by the {term}.

3.9.4.1.2 Validation of Basic Terms

When the {term} of a Particle P is an Element Declaration D, then L(P) is the set of all sequences of length 1 whose sole member is an element information item which ·matches· D. [Definition:]  An element information item E matches an Element Declaration D if and only if:

  • either the expanded name of E ·matches· the {name} and {target namespace} of D,
  • or the expanded name of E resolves to an element declaration D2 which is substitutable for D.

[Definition:]  An expanded name E matches an ·NCName· N and a namespace name NS if and only if all of the following are true:

  • The local name of E is identical to N.
  • Either the namespace name of E is identical to NS, or else E has no namespace name (E is an unqualified name) and NS is ·absent·.

When the {term} of a Particle P is a Wildcard W, then L(P) is the set of all sequences of length 1 whose sole member is an element information item E which ·matches· W. [Definition:]  An element information item E matches a Wildcard W (or a ·wildcard particle· whose {term} is W) if and only if W allows the [namespace name] of E, as defined in the validation rule Wildcard allows Namespace Name (§3.10.4).

[Definition:]  Two namespace names N1 and N2 are said to match if and only if they are identical or both are ·absent·.

For principles of validation when the {term} is a model group instead of a ·basic particle·, see Language Recognition by Groups (§3.8.4.1) and Principles of Validation against Groups (§3.8.4.2).

3.9.4.2 Validation Rules
Validation Rule: Element Sequence Accepted (Particle)
the appropriate case among the following mustmust be true:
1 If the {term} is a wildcard, then all of the following must beare true:
1.1 The length of the sequence must beis greater than or equal to the {min occurs}.
1.2 If {max occurs} is a number, the length of the sequence must beis less than or equal to the {max occurs}.
1.3 Each element information item in the sequence must beis ·valid· with respect to the wildcard as defined by Item Valid (Wildcard) (§3.10.4).
In this case, each element information item in the sequence is ·attributed to· the particle.
2 If the {term} is an element declaration, then all of the following must beare true:
2.1 The length of the sequence must beis greater than or equal to the {min occurs}.
2.2 If {max occurs} is a number, the length of the sequence must beis less than or equal to the {max occurs}.
2.3 For each element information item in the sequence one of the following must beis true:
2.3.1 The element declaration is local (i.e. its {scope}'s {variety} must not beis not global), its {abstract} is false, the element information item's [namespace name] is identical to the element declaration's {target namespace} (where an ·absent· {target namespace} is taken to be identical to a [namespace name] with no value) and the element information item's [local name] matches the element declaration's {name}.

In this case the element declaration is the ·context-determined declaration· for the element information item with respect to Schema-Validity Assessment (Element) (§3.3.4) and Assessment Outcome (Element) (§3.3.5).

2.3.2 The element declaration is top-level (i.e. its {scope}'s {variety} is global), its {abstract} is false, the element information item's [namespace name] is identical to the element declaration's {target namespace} (where an ·absent· {target namespace} is taken to be identical to a [namespace name] with no value) and the element information item's [local name] matches the element declaration's {name}.

In this case the element declaration is the ·context-determined declaration· for the element information item with respect to Schema-Validity Assessment (Element) (§3.3.4) and Assessment Outcome (Element) (§3.3.5).

2.3.3 The element declaration is top-level (i.e. its {scope}'s {variety} is global), its {disallowed substitutions} does not contain substitution, the [local ] and [namespace name] of the element information item resolve to an element declaration, as defined in QName resolution (Instance) (§3.16.4) -- [Definition:]  call this declaration the substituting declaration and the ·substituting declaration· together with the particle's element declaration's {disallowed substitutions} is ·validly substitutable· for the particle's element declaration as defined in Substitution Group OK (Transitive) (§3.3.6).

In this case the ·substituting declaration· is the ·context-determined declaration· for the element information item with respect to Schema-Validity Assessment (Element) (§3.3.4) and Assessment Outcome (Element) (§3.3.5).

In this case the element information item is ·attributed to· the particle.
3 If the {term} is a model group, then all of the following must beare true:
3.1 There is a ·partition· of the sequence into n sub-sequences such that n is greater than or equal to {min occurs}.
3.2 If {max occurs} is a number, n must beis less than or equal to {max occurs}.
3.3 Each sub-sequence in the ·partition· is ·valid· with respect to that model group as defined in Element Sequence Valid (§3.8.4.3).
In this case, the element information items in each sub-sequence are ·attributed to· Particles within the model group which is the {term}, as described in Language Recognition by Groups (§3.8.4.1).
Note: The rule just given does not require that the content model be deterministic. In practice, however, most non-determinism in content models is ruled out by the schema component constraint Unique Particle Attribution (§3.8.6). Non-determinism can occur despite that constraint for several reasons. In some such cases, some particular element information item may be accepted by either a Wildcard or an Element Declaration. In such situations, the validation process defined in this specification matches the element information item against the Element Declaration, both in identifying the Element Declaration as the item's ·context-determined declaration·, and in choosing alternative paths through a content model. Other cases of non-determinism involve nested particles each of which has {max occurs} greater than 1, where the input sequence can be partitioned in multiple ways. In those cases, there is no fixed rule for eliminating the non-determinism.
Note: clause 1 and clause 2.3.3 do not interact: an element information item validatable by a declaration with a substitution group head in a different namespace is not validatable by a wildcard which accepts the head's (namespace, name) pair but not its own.

3.9.6 Constraints on Particle Schema Components

All particles (see Particles (§3.9)) must satisfy the following constraints.

Schema Component Constraint: Particle Correct
All of the following mustmust be true:
2 If {max occurs} is not unbounded, that is, it has a numeric value, then all of the following must beare true:
2.1 {min occurs} must not beis not greater than {max occurs}.
2.2 {max occurs} must beis greater than or equal to 1.

The following constraints define relations appealed to elsewhere in this specification.

Schema Component Constraint: Particle Valid (Extension)
[Definition:]  For a particle (call it E, for extension) to be a valid extension of another particle (call it B, for base) one of the following mustmust be true:
1 They are the same particle.
2 E's {min occurs}={max occurs}=1 and its {term} is a sequence group whose {particles}' first member is a particle all of whose properties, recursively, are identical to those of B, with the exception of {annotation} properties.

The approach to defining a type by restricting another type definition set out here is designed to ensure that types defined in this way are guaranteed to be a subset of the type they restrict. This is accomplished by requiring a clear mapping between the components of the base type definition and the restricting type definition. Permissible mappings are set out below via a set of recursive definitions, bottoming out in the obvious cases, e.g. where an (restricted) element declaration corresponds to another (base) element declaration with the same name and type but the same or wider range of occurrence.

Note: The structural correspondence approach to guaranteeing the subset relation set out here is necessarily verbose, but has the advantage of being checkable in a straightforward way. The working group solicits feedback on how difficult this is in practice, and on whether other approaches are found to be viable.
Schema Component Constraint: Particle Valid (Restriction)
Issue (RQ-11i): Issue 3042 (RQ-11 pointless occurrences rule), Issue 3043 (RQ-12 choice-vs-choice rules), Issue 2820 (RQ-17 simplify restriction rules)

A number of cases have emerged in which the detailed rules in this section do not allow content models that common sense suggests should be allowed, or vice versa. The decision to move to a higher-level definition of restriction (see (§2.2.1.1)) means these issues have actually been overtaken.

Resolution:

The decision to move to a higher-level definition of restriction means almost all of this constraint will disappear.

[Definition:]  For a particle (call it R, for restriction) to be a valid restriction of another particle (call it B, for base) one of the following mustmust be true:
1 They are the same particle.
2 depending on the kind of particle, per the table below, with the qualifications that all of the following must beare true:
2.1 Any top-level element declaration particle (in R or B) which is the {substitution group affiliation} of one or more other element declarations and whose ·substitution group· contains at least one element declaration other than itself is treated as if it were a choice group whose {min occurs} and {max occurs} are those of the particle, and whose {particles} consists of one particle with {min occurs} and {max occurs} of 1 for each of the declarations in its ·substitution group·.
2.2 Any pointless occurrences of <sequence>, <choice> or <all> are ignored, where pointlessness is understood as follows:
One of the following must beis true:
2.2.1 {particles} is empty.
2.2.2 All of the following must beare true:
2.2.2.1 The particle within which this <sequence> appears has {max occurs} and {min occurs} of 1.
2.2.2.2 One of the following must beis true:
2.2.2.2.1 The <sequence>'s {particles} has only one member.
2.2.2.2.2 The particle within which this <sequence> appears is itself among the {particles} of a <sequence>.
One of the following must beis true:
2.2.1 {particles} is empty.
2.2.2 {particles} has only one member.
One of the following must beis true:
2.2.1 {particles} is empty and the particle within which this <choice> appears has {min occurs} of 0.
2.2.2 All of the following must beare true:
2.2.2.1 The particle within which this <choice> appears has {max occurs} and {min occurs} of 1.
2.2.2.2 One of the following must beis true:
2.2.2.2.1 The <choice>'s {particles} has only one member.
2.2.2.2.2 The particle within which this <choice> appears is itself among the {particles} of a <choice>.
Base Particle
eltanyallchoicesequence
Derived ParticleeltNameAnd- TypeOKNSCompatRecurse- AsIfGroupRecurse- AsIfGroupRecurseAs- IfGroup
anyForbiddenNSSubsetForbiddenForbiddenForbidden
allForbiddenNSRecurse- CheckCardinalityRecurseForbiddenForbidden
choiceForbiddenNSRecurse- CheckCardinalityForbiddenRecurseLaxForbidden
seq- uenceForbiddenNSRecurse- CheckCardinalityRecurse- UnorderedMapAndSumRecurse
Schema Component Constraint: Occurrence Range OK
For a particle's occurrence range to be a valid restriction of another's occurrence range all of the following mustmust be true:
1 Its {min occurs} is greater than or equal to the other's {min occurs}.
2 one of the following must beis true:
2.1 The other's {max occurs} is unbounded.
2.2 Both {max occurs} are numbers, and the particle's is less than or equal to the other's.
Schema Component Constraint: Particle Restriction OK (Elt:Elt -- NameAndTypeOK)
For an element declaration particle to be a ·valid restriction· of another element declaration particle all of the following mustmust be true:
1 The declarations' {name}s and {target namespace}s are the same.
2 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6).
3 One of the following must beis true:
3.1 Both B's declaration's {scope}'s {variety} and R's declaration's {scope}'s {variety} are global.
3.2 All of the following must beare true:
3.2.1 Either B's {nillable} is true or R's {nillable} is false.
3.2.2 either B's declaration's {value constraint} is absent, or its {variety} is not fixed, or R's declaration's {value constraint}'s {variety} is fixed and the two {value constraint}'s {value}s are identical.
3.2.3 R's declaration's {identity-constraint definitions} is a subset of B's declaration's {identity-constraint definitions}, if any.
Issue (RQ-15i):Issue 2850 (RQ-15 restriction and identity constraints)

Version 1.0 got the appropriate constraint for identity-constraint definitions and restriction backwards — the restricted definition must have the same or more constraints, not less.

Resolution:

When you're constructing a restricted type, then

  • the identity constraints of a local element are inherited;
  • any new ones (those occurring in the declaration of E local to R) are added.

[IG Archive (W3C-member-only link)]

3.2.4 R's declaration's {disallowed substitutions} is a superset of B's declaration's {disallowed substitutions}.
3.2.5 R's {type definition} is validly derived given {extension, list, union} from B's {type definition} as defined by Type Derivation OK (Complex) (§3.4.6) or Type Derivation OK (Simple) (§3.15.6), as appropriate.
Note: The above constraint on {type definition} means that in deriving a type by restriction, any contained type definitions must themselves be explicitly derived by restriction from the corresponding type definitions in the base definition, or be one of the member types of a corresponding union..
Schema Component Constraint: Particle Derivation OK (Elt:Any -- NSCompat)
For an element declaration particle to be a ·valid restriction· of a wildcard particle all of the following mustmust be true:
1 The element declaration's {target namespace} is ·valid· with respect to the wildcard's {namespace constraint} as defined by Wildcard allows Namespace Name (§3.10.4).
2 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6).
Schema Component Constraint: Particle Derivation OK (Elt:All/Choice/Sequence -- RecurseAsIfGroup)
For an element declaration particle to be a ·valid restriction· of a group particle (all, choice or sequence) a group particle of the variety corresponding to B's, with {min occurs} and {max occurs} of 1 and with {particles} consisting of a single particle the same as the element declaration must be a ·valid restriction· of the group as defined by Particle Derivation OK (All:All,Sequence:Sequence -- Recurse) (§3.9.6), Particle Derivation OK (Choice:Choice -- RecurseLax) (§3.9.6) or Particle Derivation OK (All:All,Sequence:Sequence -- Recurse) (§3.9.6), depending on whether the group is all, choice or sequence.
Schema Component Constraint: Particle Derivation OK (Any:Any -- NSSubset)
For a wildcard particle to be a ·valid restriction· of another wildcard particle all of the following mustmust be true:
1 R's occurrence range must be a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6).
2 R's {namespace constraint} must be an intensional subset of B's {namespace constraint} as defined by Wildcard Subset (§3.10.6).
3 Unless B is the content model wildcard of the ·ur-type definition·, R's {process contents} must be identical to or stronger than B's {process contents}, where strict is stronger than lax is stronger than skip.

Note:

The exception to the third clause above for
derivations from the ·ur-type definition· is necessary as its wildcards have a {process contents} of lax, so without this exception, no use of wildcards with {process contents} of skip would be possible.
Schema Component Constraint: Particle Derivation OK (All/Choice/Sequence:Any -- NSRecurseCheckCardinality)
For a group particle to be a ·valid restriction· of a wildcard particle all of the following mustmust be true:
1 Every member of the {particles} of the group is a ·valid restriction· of the wildcard as defined by Particle Valid (Restriction) (§3.9.6).
2 The effective total range of the group, as defined by Effective Total Range (all and sequence) (§3.8.6) (if the group is all or sequence) or Effective Total Range (choice) (§3.8.6) (if it is choice) is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6).
Schema Component Constraint: Particle Derivation OK (All:All,Sequence:Sequence -- Recurse)
For an all or sequence group particle to be a ·valid restriction· of another group particle with the same {compositor} all of the following mustmust be true:
1 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6).
2 There is a complete ·order-preserving· functional mapping from the particles in the {particles} of R to the particles in the {particles} of B such that all of the following must beare true:
2.1 Each particle in the {particles} of R is a ·valid restriction· of the particle in the {particles} of B it maps to as defined by Particle Valid (Restriction) (§3.9.6).
2.2 All particles in the {particles} of B which are not mapped to by any particle in the {particles} of R are ·emptiable· as defined by Particle Emptiable (§3.9.6).
Note: Although the ·validation· semantics of an all group does not depend on the order of its particles, derived all groups are required to match the order of their base in order to simplify checking that the derivation is OK.
[Definition:]  A complete functional mapping is order-preserving if each particle r in the domain R maps to a particle b in the range B which follows (not necessarily immediately) the particle in the range B mapped to by the predecessor of r, if any, where "predecessor" and "follows" are defined with respect to the order of the lists which constitute R and B.
Schema Component Constraint: Particle Derivation OK (Choice:Choice -- RecurseLax)
For a choice group particle to be a ·valid restriction· of another choice group particle all of the following mustmust be true:
1 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6);
2 There is a complete ·order-preserving· functional mapping from the particles in the {particles} of R to the particles in the {particles} of B such that each particle in the {particles} of R is a ·valid restriction· of the particle in the {particles} of B it maps to as defined by Particle Valid (Restriction) (§3.9.6).
Note: Although the ·validation· semantics of a choice group does not depend on the order of its particles, derived choice groups are required to match the order of their base in order to simplify checking that the derivation is OK.
Schema Component Constraint: Particle Derivation OK (Sequence:All -- RecurseUnordered)
For a sequence group particle to be a ·valid restriction· of an all group particle all of the following mustmust be true:
1 R's occurrence range is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6).
2 There is a complete functional mapping from the particles in the {particles} of R to the particles in the {particles} of B such that all of the following must beare true:
2.1 No particle in the {particles} of B is mapped to by more than one of the particles in the {particles} of R;
2.2 Each particle in the {particles} of R is a ·valid restriction· of the particle in the {particles} of B it maps to as defined by Particle Valid (Restriction) (§3.9.6);
2.3 All particles in the {particles} of B which are not mapped to by any particle in the {particles} of R are ·emptiable· as defined by Particle Emptiable (§3.9.6).
Note: Although this clause allows reordering, because of the limits on the contents of all groups the checking process can still be deterministic.
Schema Component Constraint: Particle Derivation OK (Sequence:Choice -- MapAndSum)
For a sequence group particle to be a ·valid restriction· of a choice group particle all of the following mustmust be true:
1 There is a complete functional mapping from the particles in the {particles} of R to the particles in the {particles} of B such that each particle in the {particles} of R is a ·valid restriction· of the particle in the {particles} of B it maps to as defined by Particle Valid (Restriction) (§3.9.6).
2 The pair consisting of the product of the {min occurs} of R and the length of its {particles} and unbounded if {max occurs} is unbounded otherwise the product of the {max occurs} of R and the length of its {particles} is a valid restriction of B's occurrence range as defined by Occurrence Range OK (§3.9.6).
Note: This clause is in principle more restrictive than absolutely necessary, but in practice will cover all the likely cases, and is much easier to specify than the fully general version.
Note: This case allows the "unfolding" of iterated disjunctions into sequences. It may be particularly useful when the disjunction is an implicit one arising from the use of substitution groups.
Schema Component Constraint: Particle Emptiable
[Definition:]  For a particle to be emptiable one of the following mustmust be true:
1 Its {min occurs} is 0.
2 Its {term} is a group and the minimum part of the effective total range of that group, as defined by Effective Total Range (all and sequence) (§3.8.6) (if the group is all or sequence) or Effective Total Range (choice) (§3.8.6) (if it is choice), is 0.

previous sub-section next sub-section3.10 Wildcards

In order to exploit the full potential for extensibility offered by XML plus namespaces, more provision is needed than DTDs allow for targeted flexibility in content models and attribute declarations. A wildcard provides for ·validation· of attribute and element information items dependent on their namespace names, but independently ofand optionally on their local names.

Issue (RQ-9i):

Issue 2867 (RQ-9 wildcard namespace sets)

In version 1.0 negated wildcards were restricted to negating only one namespace. Experience suggests that at least at the component level this may need to be expanded, but no final decision will be made on this until details of the change in interpretation of wildcards more generally (see (§3.4)) are worked out.

At the moment wildcards can only negate a single namespace. To handle certain cases which become possible because to the change in interpretation of wildcards as subordinate to explicit elements (see (§3.4)), it may be necessary to negate/exclude a set of explicitly enumerated expanded names. This would be a change at the component level only.

A related possibility, more likely motivated by versioning needs, would be to provide, perhaps again only at the component level for now, for sets of namespace names to be negated.

Resolution:

None recorded.

Example
<xs:any processContents="skip"/>

<xs:any namespace="##other" processContents="lax"/>

<xs:any namespace="http://www.w3.org/1999/XSL/Transform"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        notQName="xsl:comment xsl:fallback"/>

<xs:any nnotNamespace="##targetNamespace"/>

<xs:anyAttribute namespace="http://www.w3.org/XML/1998/namespace"/>
XML representations of the four basic types of wildcard, plus one attribute wildcard.

3.10.1 The Wildcard Schema Component

The wildcard schema component has the following properties:

{namespace constraint} provides for ·validation· of attribute and element items that:

  1. ({variety} any) have any namespace or are not namespace-qualified;
  2. ({variety} not and {namespaces} a set containing exactly one namespace name) are namespace-qualified with a namespace other than the specified namespace name;
  3. ({variety} not and {namespaces} a set containing exactly one member, namely ·absent·) are namespace-qualified;
  4. ({variety} not and {namespaces} a set whose members are either namespace names or ·absent·) have any namespace other than the specified namespaces and/or, if ·absent· is included in the set, are namespace-qualified;
  5. ({variety} enumeration and {namespaces} a set whose members are either namespace names or ·absent·) have any of the specified namespaces and/or, if ·absent· is included in the set, are unqualified.
  6. ({disallowed names} is not empty) have any (namespace name, local name) other than the specified names.

{process contents} controls the impact on ·assessment· of the information items allowed by wildcards, as follows:

strict
There must be a top-level declaration for the item available, or the item must have an xsi:type, and the item must be ·valid· as appropriate.
skip
No constraints at all: the item must simply be well-formed XML.
lax
If the item has a uniquely determined declaration available, it must be ·valid· with respect to that definition, that is, ·validate· if you can, don't worry if you can't.

See Annotations (§3.14) for information on the role of the {annotations} property.

3.10.2 XML Representation of Wildcard Schema Components

The XML representation for a wildcard schema component is an <any> or <anyAttribute> element information item. The correspondences between the properties of an <any> information item and properties of the components it corresponds to are as follows (see <complexType> and <attributeGroup> for the correspondences for <anyAttribute>):

XML Representation Summary: 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
  processContents = (lax | skip | strict) : strict
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</any>

A particle containing a wildcard, with properties as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):
Particle Schema Component
Property
Representation
 
The ·actual value· of the minOccurs [attribute], if present, otherwise 1.
 
unbounded, if the maxOccurs [attribute] equals unbounded, otherwise the ·actual value· of the maxOccurs [attribute], if present, otherwise 1.
 
A wildcard as given below:
Wildcard Schema Component
Property
Representation
 
Dependent on the ·actual value· of the namespace [attribute]: if absent, then a Namespace Constraint with {variety} any, otherwise as follows:
##other
a Namespace Constraint with {variety} not and {namespaces} a set with exactly one member, the ·actual value· of the targetNamespace [attribute] of the <schema> ancestor element information item if present, otherwise·absent·
otherwise
Property
Value
enumeration
a set whose members are namespace names corresponding to the space-delimited substrings of the string, except
1 if one such substring is ##targetNamespace, the corresponding member is the ·actual value· of the targetNamespace [attribute] of the <schema> ancestor element information item if present, otherwise ·absent·.
2 if one such substring is ##local, the corresponding member is ·absent·.
A Namespace Constraint with the following properties:
Property
Value
the appropriate case among the following:
1 If the namespace [attribute] is present, then the appropriate case among the following:
1.1 If the ·actual value· of the namespace [attribute] is "##any", then any;
1.2 If the ·actual value· of the namespace [attribute] is "##other", then not;
1.3 otherwise enumeration;
2 If the notNamespace [attribute] is present, then not;
3 otherwise (neither namespace nor notNamespace is present) any.
the appropriate case among the following:
1 If neither namespace nor notNamespace is present, then the empty set;
2 If the namespace [attribute] is present and its ·actual value· is "##any", then the empty set;
3 If the namespace [attribute] is present and its ·actual value· is "##other", then a set consisting ·absent· and, if the targetNamespace [attribute] of the <schema> ancestor element information item is present, its ·actual value·;
4 otherwise a set whose members are namespace names corresponding to the space-delimited substrings of the ·actual value· of the namespace or notNamespace [attribute] (whichever is present), except
4.1 if one such substring is ##targetNamespace, the corresponding member is the ·actual value· of the targetNamespace [attribute] of the <schema> ancestor element information item if present, otherwise ·absent·;
4.2 if one such substring is ##local, the corresponding member is ·absent·.
A set whose members are QName values corresponding to the space-delimited substrings of the ·actual value· of the notQName [attribute] if present, otherwise the empty set.
 
The ·actual value· of the processContents [attribute], if present, otherwise strict.
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.

Wildcards are subject to the same ambiguity constraints (Unique Particle Attribution (§3.8.6)) as other content model particles: If an instance element could match either an explicit particle and a wildcard, or one of two wildcards, within the content model of a type, that model is in error.

3.10.3 Constraints on XML Representations of Wildcards

Schema Representation Constraint: Wildcard Representation OK
In addition to the conditions imposed on <any> element information items by the schema for schemas, the corresponding particle and model group must satisfy the conditions set out in Constraints on Model Group Schema Components (§3.8.6) and Constraints on Particle Schema Components (§3.9.6).
all of the following mustmust be true:
1 namespace and notNamespace are not both present;
2 The corresponding particle and model group satisfy the conditions set out in Constraints on Model Group Schema Components (§3.8.6) and Constraints on Particle Schema Components (§3.9.6).

3.10.4 Wildcard Validation Rules

Validation Rule: Item Valid (Wildcard)
For an element or attribute information item to be locally ·valid· with respect to a wildcard constraint its ([namespace name], [local name]) pair must be ·valid· with respect to the wildcard constraint, as defined in Wildcard allows Namespace Name (§3.10.4)Wildcard allows Expanded Name (§3.10.4).

When this constraint applies the appropriate case among the following mustmust be true:

Validation Rule: Wildcard allows Expanded Name
For a (namespace name, local name) pair to be ·valid· with respect to a wildcard constraint (the value of a {namespace constraint}) all of the following mustmust be true:
1 The namespace name is ·valid· with respect to the wildcard constraint, as defined in Wildcard allows Namespace Name (§3.10.4);
2 The constraint's {disallowed names} does not contain such pair.
Validation Rule: Wildcard allows Namespace Name
For a value which is either a namespace name or ·absent· to be ·valid· with respect to a wildcard constraint (the value of a {namespace constraint}) one of the following mustmust be true:
1 The constraint's {variety} must beis any.
2
All of the following must beare true:
2.1 The constraint's {variety} is not and its {namespaces} is a set with exactly one member, a namespace name or ·absent· ([Definition:]  call this the namespace test).
2.2 The value must not be identical to the ·namespace test·.
2.3 The value must not be ·absent·.
The constraint's {variety} is not, and the value is not identical to any of the members of the constraint's {namespaces}.
3 The constraint's {variety} is enumeration, and the value is identical to one of the members of the constraint's {namespaces}.

3.10.6 Constraints on Wildcard Schema Components

All wildcards (see Wildcards (§3.10)) must satisfy the following constraint.

The following constraints define a relation appealed to elsewhere in this specification.

Schema Component Constraint: Wildcard Subset
Formally, fFor a namespace constraint (call it sub) to be an intensional subset of another namespace constraint (call it super), the set of expanded QNames allowed by super, as defined in Wildcard allows Expanded Name (§3.10.4), must be a superset of that allowed by sub.↑

Informally, one of the following mustmust be true:

1 super's {variety} must beis any.
2 All of the following must beare true:
2.1 sub's {variety} must beis not.
2.2 super's {variety} must beis not and the single member of its {namespaces} is identical to the single membera subset of sub's {namespaces}.
3 All of the following must beare true:
3.1 sub's {variety} is enumeration.
3.2 One of the following must beis true:
3.2.1 super's {variety} is enumeration and its {namespaces} must beis the same set or a superset of sub's {namespaces}.
3.2.2 super's {variety} must beis not and neither the single member of its {namespaces} nor ·absent·none of the members of its {namespaces} must beis in sub's {namespaces}.

And the following must be true:
1 Each member of super's {disallowed names} is not allowed by sub, as defined in Wildcard allows Expanded Name (§3.10.4).
Schema Component Constraint: Attribute Wildcard Union
Formally, fFor a Namespace Constraint to be the intensional union of two other Namespace Constraints (call them O1 and O2), the set of expanded QNames allowed by such Namespace Constraint, as defined in Wildcard allows Expanded Name (§3.10.4), must be the union of those allowed by O1 and O2.

Informally, it must be as given by the appropriate case among the following:

1 If O1 and O2 have the same {variety} and identical {namespaces}, then a Namespace Constraint with {variety} and {namespaces} as for O1.
2 If either O1 or O2 has {variety} any, then a Namespace Constraint with {variety} any.
3 If both O1 and O2 have {variety} enumeration, then a Namespace Constraint with {variety} enumeration and {namespaces} the union of O1's {namespaces} and O2's {namespaces}.
4 If the two both have {variety} not and let I be the intersection of O1's {namespaces} and O2's {namespaces}, then a Namespace Constraint with {variety} not and {namespaces} a set with ·absent· as the only member.
the appropriate case among the following:
4.1 If I is the empty set, then a Namespace Constraint with {variety} any.
4.2 otherwise a Namespace Constraint with {variety} not and {namespaces} I.
5 If either O1 or O2 has {variety} not and {namespaces} a set whose single member isa namespace name (call this N){namespaces} S1 and the other has {variety} enumeration and {namespaces} S2 and let S be S1 minus S2, then
the appropriate case among the following:
5.1 If the set S includes both N and ·absent·, then a Namespace Constraint with {variety} any.
5.2 If the set S includes N but not ·absent·, then a Namespace Constraint with {variety} not and {namespaces} a set whose only member is ·absent·.
5.3 If the set S includes ·absent· but not N, then the union is not expressible.
5.4 If the set S does not include either N or ·absent·, then a Namespace Constraint with {variety} not and {namespaces} the same as the {namespaces} of whichever of O1 or O2 has {variety} not.
the appropriate case among the following:
5.1 If S is the empty set, then a Namespace Constraint with {variety} any.
5.2 otherwise a Namespace Constraint with {variety} not and {namespaces} S.
6
either O1 or O2 has {variety} not and{namespaces} a set whose single member is ·absent· and the other has {variety} enumeration and {namespaces} S

the appropriate case among the following:
6.1 If the set S includes ·absent·, then a Namespace Constraint with {variety} any.
6.2 If the set S does not include ·absent·, then a Namespace Constraint with {variety} not and {namespaces} a set whose only member is ·absent·.

And its {disallowed names} must be as given by the following:
7 It has members of O1's {disallowed names} that are not allowed by O2, as defined in Wildcard allows Expanded Name (§3.10.4), and members of O2's {disallowed names} that are not allowed by O1.

In the case where there are more than two Namespace Constraints to be combined, the intensional union is determined by identifying the intensional union of two of them as above, then the intensional union of the result with the third (providing the first union was expressible), and so on as required.
Schema Component Constraint: Attribute Wildcard Intersection
Formally, fFor a Namespace Constraint to be the intensional intersection of two other Namespace Constraints (call them O1 and O2), the set of expanded QNames allowed by such Namespace Constraint, as defined in Wildcard allows Expanded Name (§3.10.4), must be the intersection of those allowed by O1 and O2.

Informally, it must be as given by: the appropriate case among the following:

1 If O1 and O2 have the same {variety} and identical {namespaces}, then a Namespace Constraint with {variety} and {namespaces} as for O1.
2 If either O1 or O2 has {variety} any, then a Namespace Constraint with {variety} and {namespaces} as for the other.
3 If either O1 or O2 has {variety} not and {namespaces} a set whose single member is NS1 and the other has {variety} enumeration and {namespaces} S2, then a Namespace Constraint with {variety} enumeration and {namespaces} the same as S, minus N if it was in S, minus ·absent· if it was in S S2 minus S1.
4 If both O1 and O2 have {variety} enumeration, then a Namespace Constraint with {variety} enumeration and {namespaces} the intersection of their {namespaces}.
5
the two have {variety} not but the single members of their {namespaces} are different namespace names

the intersection is not expressible.
6
the one has {variety} not and {namespaces} a set whose single member is a namespace name (call the set N) and the other has {variety} not and {namespaces} a set whose single member is ·absent·

7
both O1 and O2 have {variety} not

a Namespace Constraint with {variety} not and {namespaces} the union of their {namespaces}.

And its {disallowed names} must be as given by the following:
8 It has members of O1's {disallowed names} that are allowed by O2, as defined in Wildcard allows Expanded Name (§3.10.4), and members of O2's {disallowed names} that are allowed by O1.

In the case where there are more than two Namespace Constraints to be combined, the intensional intersection is determined by identifying the intensional intersection of two of them as above, then the intensional intersection of the result with the third (providing the first intersection was expressible), and so on as required.

previous sub-section next sub-section3.11 Identity-constraint Definitions

Identity-constraint definition components provide for uniqueness and reference constraints with respect to the contents of multiple elements and attributes.

Example
<xs:key name="fullName">
 <xs:selector xpath=".//person"/>
 <xs:field xpath="forename"/>
 <xs:field xpath="surname"/>
</xs:key>

<xs:keyref name="personRef" refer="fullName">
 <xs:selector xpath=".//personPointer"/>
 <xs:field xpath="@first"/>
 <xs:field xpath="@last"/>
</xs:keyref>

<xs:unique name="nearlyID">
 <xs:selector xpath=".//*"/>
 <xs:field xpath="@id"/>
</xs:unique>
XML representations for the three kinds of identity-constraint definitions.

3.11.1 The Identity-constraint Definition Schema Component

The identity-constraint definition schema component has the following properties:

Issue (RQ-14i):Issue 2848 (RQ-14 annotations on field and select)

Version 1.0 provided no home for annotations on xs:field and xs:select. The overall reworking of annotation at the component level described in (§3.4.1) will take care of this.

Resolution:

See (§3.4.1).

Identity-constraint definitions are identified by their {name} and {target namespace}; Identity-constraint definition identities must be unique within an ·XML Schema·. See References to schema components across namespaces (<import>) (§4.2.3) for the use of component identifiers when importing one schema into another.

Informally, {identity-constraint category} identifies the Identity-constraint definition as playing one of three roles:

  • (unique) the Identity-constraint definition asserts uniqueness, with respect to the content identified by {selector}, of the tuples resulting from evaluation of the {fields} XPath expression(s).
  • (key) the Identity-constraint definition asserts uniqueness as for unique. key further asserts that all selected content actually has such tuples.
  • (keyref) the Identity-constraint definition asserts a correspondence, with respect to the content identified by {selector}, of the tuples resulting from evaluation of the {fields} XPath expression(s), with those of the {referenced key}.

These constraints are specified along side the specification of types for the attributes and elements involved, i.e. something declared as of type integer may also serve as a key. Each constraint declaration has a name, which exists in a single symbol space for constraints. The equality and inequalityidentity conditions appealed to in checking these constraints apply to the values of the fields selected, not their lexical representation, so that for example 3.0 and 3 would be conflicting keys if they were both numberdecimal, but non-conflicting if they were both strings, or one was a string and one a numberdecimal. Values of differing type can only be equal if one type is derived from the other, and the value is in the value space of both.

Overall the augmentations to XML's ID/IDREF mechanism are:

  • Functioning as a part of an identity-constraint is in addition to, not instead of, having a type;
  • Not just attribute values, but also element content and combinations of values and content can be declared to be unique;
  • Identity-constraints are specified to hold within the scope of particular elements;
  • (Combinations of) attribute values and/or element content can be declared to be keys, that is, not only unique, but always present and non-nillable;
  • The comparison between keyref {fields} and key or unique {fields} is by value equality, not by string equality.

{selector} specifies a restricted XPath ([XPath]) expression relative to instances of the element being declared. This must identify a node set of subordinate elements (i.e. contained within the declared element) to which the constraint applies.

{fields} specifies XPath expressions relative to each element selected by a {selector}. This must identify a single node (element or attribute) whose content or value, which must be of a simple type, is used in the constraint. It is possible to specify an ordered list of {fields}s, to cater to multi-field keys, keyrefs, and uniqueness constraints.

In order to reduce the burden on implementers, in particular implementers of streaming processors, only restricted subsets of XPath expressions are allowed in {selector} and {fields}. The details are given in Constraints on Identity-constraint Definition Schema Components (§3.11.6).

Note: Provision for multi-field keys etc. goes beyond what is supported by xsl:key.
Note:  Identity constraints currently uses XPath 1.0. This may change in future working drafts of this specification to use XPath 2.0. Such change will not affect evaluation of identity constraints, given the XPath subset it uses.

See Annotations (§3.14) for information on the role of the {annotations} property.

3.11.2 XML Representation of Identity-constraint Definition Schema Components

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 and properties of the component they correspond to are as follows:

XML Representation Summary: unique Element Information Item

<unique
  id = ID
  name = NCName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (selector, field+))
</unique>

<key
  id = ID
  name = NCName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (selector, field+))
</key>

<keyref
  id = ID
  name = NCName
  refer = QName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (selector, field+))
</keyref>

<selector
  id = ID
  xpath = a subset of XPath expression, see below
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</selector>

<field
  id = ID
  xpath = a subset of XPath expression, see below
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</field>

Property
Representation
 
 
The ·actual value· of the targetNamespace [attribute] of the parent schema element information item.
 
One of key, keyref or unique, depending on the item.
 
A restricted XPath expression corresponding to the ·actual value· of the xpath [attribute] of the <selector> element information item among the [children]
 
A sequence of XPath expressions, corresponding to the ·actual value·s of the xpath [attribute]s of the <field> element information item [children], in order.
 
If the item is a <keyref>, the identity-constraint definition ·resolved· to by the ·actual value· of the refer [attribute], otherwise ·absent·.
 
The annotations corresponding to the <annotation> element information item in the [children], if present, and in the <selector> and <field> [children], if present, otherwise ·absent·.
Example
<xs:element name="vehicle">
 <xs:complexType>
  . . .
  <xs:attribute name="plateNumber" type="xs:integer"/>
  <xs:attribute name="state" type="twoLetterCode"/>
 </xs:complexType>
</xs:element>

<xs:element name="state">
 <xs:complexType>
  <xs:sequence>
   <xs:element name="code" type="twoLetterCode"/>
   <xs:element ref="vehicle" maxOccurs="unbounded"/>
   <xs:element ref="person" maxOccurs="unbounded"/>
  </xs:sequence>
 </xs:complexType>

 <xs:key name="reg"> <!-- vehicles are keyed by their plate within states -->
  <xs:selector xpath=".//vehicle"/>
  <xs:field xpath="@plateNumber"/>
 </xs:key>
</xs:element>

<xs:element name="root">
 <xs:complexType>
  <xs:sequence>
   . . .
   <xs:element ref="state" maxOccurs="unbounded"/>
   . . .
  </xs:sequence>
 </xs:complexType>

 <xs:key name="state"> <!-- states are keyed by their code -->
  <xs:selector xpath=".//state"/>
  <xs:field xpath="code"/>
 </xs:key>

 <xs:keyref name="vehicleState" refer="state">
  <!-- every vehicle refers to its state -->
  <xs:selector xpath=".//vehicle"/>
  <xs:field xpath="@state"/>
 </xs:keyref>

 <xs:key name="regKey"> <!-- vehicles are keyed by a pair of state and plate -->
  <xs:selector xpath=".//vehicle"/>
  <xs:field xpath="@state"/>
  <xs:field xpath="@plateNumber"/>
 </xs:key>

 <xs:keyref name="carRef" refer="regKey"> <!-- people's cars are a reference -->
  <xs:selector xpath=".//car"/>
  <xs:field xpath="@regState"/>
  <xs:field xpath="@regPlate"/>
 </xs:keyref>

</xs:element>

<xs:element name="person">
 <xs:complexType>
  <xs:sequence>
   . . .
   <xs:element name="car">
    <xs:complexType>
     <xs:attribute name="regState" type="twoLetterCode"/>
     <xs:attribute name="regPlate" type="xs:integer"/>
    </xs:complexType>
   </xs:element>
  </xs:sequence>
 </xs:complexType>
</xs:element>
A state element is defined, which contains a code child and some vehicle and person children. A vehicle in turn has a plateNumber attribute, which is an integer, and a state attribute. State's codes are a key for them within the document. Vehicle's plateNumbers are a key for them within states, and state and plateNumber is asserted to be a key for vehicle within the document as a whole. Furthermore, a person element has an empty car child, with regState and regPlate attributes, which are then asserted together to refer to vehicles via the carRef constraint. The requirement that a vehicle's state match its containing state's code is not expressed here.

3.11.4 Identity-constraint Definition Validation Rules

Validation Rule: Identity-constraint Satisfied
For an element information item to be locally ·valid· with respect to an identity-constraint all of the following mustmust be true:
1 The {selector}, with the element information item as the context node, evaluates to a node-set (as defined in [XPath]). [Definition:]  Call this the target node set.
2 Each node in the ·target node set· is either the context node or an element node among its descendants.
3 For each node in the ·target node set· all of the {fields}, with that node as the context node, evaluate to either an empty node-set or a node-set with exactly one member, which must havehas a simple type. [Definition:]  Call the sequence of the type-determined values (as defined in [XML Schema: Datatypes]) of the [schema normalized value] of the element and/or attribute information items in those node-sets in order the key-sequence of the node.
4 [Definition:]  Call the subset of the ·target node set· for which all the {fields} evaluate to a node-set with exactly one member which is an element or attribute node with a simple type the qualified node set. The appropriate case among the following must beis true:
4.1 If the {identity-constraint category} is unique, then no two members of the ·qualified node set· have ·key-sequences· whose members are pairwise equal, as defined by EqualEquality in [XML Schema: Datatypes].
4.2 If the {identity-constraint category} is key, then all of the following must beare true:
4.2.1 The ·target node set· and the ·qualified node set· are equal, that is, every member of the ·target node set· is also a member of the ·qualified node set· and vice versa.
4.2.2 No two members of the ·qualified node set· have ·key-sequences· whose members are pairwise equal, as defined by EqualEquality in [XML Schema: Datatypes].
4.2.3 No element member of the ·key-sequence· of any member of the ·qualified node set· was assessed as ·valid· by reference to an element declaration whose {nillable} is true.
4.3 If the {identity-constraint category} is keyref, then for each member of the ·qualified node set· (call this the keyref member), there must beis a ·node table· associated with the {referenced key} in the [identity-constraint table] of the element information item (see Identity-constraint Table (§3.11.5), which must beis understood as logically prior to this clause of this constraint, below) and there must beis an entry in that table whose ·key-sequence· is equal to the keyref member's ·key-sequence· member for member, as defined by EqualEquality in [XML Schema: Datatypes].
Note: The use of [schema normalized value] in the definition of ·key sequence· above means that default or fixed value constraints may play a part in ·key sequence·s.
Note: Because the validation of keyref (see clause 4.3) depends on finding appropriate entries in a element information item's ·node table·, and ·node tables· are assembled strictly recursively from the node tables of descendants, only element information items within the sub-tree rooted at the element information item being ·validated· can be referenced successfully.
Note: Although this specification defines a ·post-schema-validation infoset· contribution which would enable schema-aware processors to implement clause 4.2.3 above (Element Declaration (§3.3.5)), processors are not required to provide it. This clause can be read as if in the absence of this infoset contribution, the value of the relevant {nillable} property must be available.

3.11.5 Identity-constraint Definition Information Set Contributions

Schema Information Set Contribution: Identity-constraint Table
[Definition:]  An eligible identity-constraint of an element information item is one such that clause 4.1 or clause 4.2 of Identity-constraint Satisfied (§3.11.4) is satisfied with respect to that item and that constraint, or such that any of the element information item [children] of that item have an [identity-constraint table] property whose value has an entry for that constraint.

[Definition:]  A node table is a set of pairs each consisting of a ·key-sequence· and an element node.

Whenever an element information item has one or more ·eligible identity-constraints·, in the ·post-schema-validation infoset· that element information item has a property as follows:

PSVI Contributions for element information items
[identity-constraint table]
one Identity-constraint Binding information item for each ·eligible identity-constraint·, with properties as follows:
PSVI Contributions for Identity-constraint Binding information items
[definition]
The ·eligible identity-constraint·.
[node table]
A ·node table· with one entry for every ·key-sequence· (call it k) and node (call it n) such that one of the following must beis true:
1 There is an entry in one of the ·node tables· associated with the [definition] in an Identity-constraint Binding information item in at least one of the [identity-constraint table]s of the element information item [children] of the element information item whose ·key-sequence· is k and whose node is n;
2 n appears with ·key-sequence· k in the ·qualified node set· for the [definition].
provided no two entries have the same ·key-sequence· but distinct nodes. Potential conflicts are resolved by not including any conflicting entries which would have owed their inclusion to clause 1 above. Note that if all the conflicting entries arose under clause 1 above, this means no entry at all will appear for the offending ·key-sequence·.
Note: The complexity of the above arises from the fact that keyref identity-constraints may be defined on domains distinct from the embedded domain of the identity-constraint they reference, or the domains may be the same but self-embedding at some depth. In either case the ·node table· for the referenced identity-constraint needs to propagate upwards, with conflict resolution.

The Identity-constraint Binding information item, unlike others in this specification, is essentially an internal bookkeeping mechanism. It is introduced to support the definition of Identity-constraint Satisfied (§3.11.4) above. Accordingly, conformant processors may, but are not required to, expose them via [identity-constraint table] properties in the ·post-schema-validation infoset·. In other words, the above constraints may be read as saying ·validation· of identity-constraints proceeds as if such infoset items existed.

3.11.6 Constraints on Identity-constraint Definition Schema Components

All identity-constraint definitions (see Identity-constraint Definitions (§3.11)) must satisfy the following constraint.

Schema Component Constraint: Selector Value OK
All of the following mustmust be true:
1 The {selector} must beis a valid XPath expression, as defined in [XPath].
2 One of the following must beis true:
2.1 It must conformconforms to the following extended BNF:
Selector XPath expressions
[1]   Selector   ::=   Path ( '|' Path )*
[2]   Path   ::=   ('.//')? Step ( '/' Step )*
[3]   Step   ::=   '.' | NameTest
[4]   NameTest   ::=   QName | '*' | NCName ':' '*'
2.2 It must beis an XPath expression involving the child axis whose abbreviated form is as given above.
For readability, whitespace may be used in selector XPath expressions even though not explicitly allowed by the grammar: whitespace may be freely added within patterns before or after any token.
Lexical productions
[5]   token   ::=   '.' | '/' | '//' | '|' | '@' | NameTest
[6]   whitespace   ::=   S

When tokenizing, the longest possible token is always returned.

Schema Component Constraint: Fields Value OK
All of the following mustmust be true:
1 Each member of the {fields} must beis a valid XPath expression, as defined in [XPath].
2 One of the following must beis true:
2.1 It must conformconforms to the extended BNF given above for Selector, with the following modification:
Path in Field XPath expressions
[7]   Path   ::=   ('.//')? ( Step '/' )* ( Step | '@' NameTest )
This production differs from the one above in allowing the final step to match an attribute node.
2.2 It must beis an XPath expression involving the child and/or attribute axes whose abbreviated form is as given above.
For readability, whitespace may be used in field XPath expressions even though not explicitly allowed by the grammar: whitespace may be freely added within patterns before or after any token.

When tokenizing, the longest possible token is always returned.

previous sub-section next sub-section3.12 Assertions

Assertion components constrain the existence and values of related elements and attributes.

Example
<xs:assert test="@min le @max"/>

<xs:report test="@min gt @max"/>
The XML representations for the two kinds of assertions.

The <assert> element requires that the value of the min attribute be less than or equal to that of the max attribute, and fails if that is not the case. The <report> element shown here enforces much the same condition, but expresses it differently; it detects an error if its predicate is true, in this case if the value of the min attribute is greater than that of max.

3.12.1 The Assertion Schema Component

The assertion schema component has the following properties:

{category} controls how assertions impact ·assessment· of the element information item. A {category} with the value assert means the {test} must evaluate to true. A {category} with the value report means the {test} must evaluate to false.

{test} specifies a restricted XPath ([XPath 2.0]) expression:

  • Path steps are restricted to only match information items within the element being ·assessed·
  • XPath predicates are restricted to only refer to attributes on the current element.
  • Operations are limited to those defined in this specification. For example, comparison of ·actual value·s is supported, while general comparison, addition and multiplication are not.
  • Functions are also limited to those whose semantics is within the scope of this specification..

As a result, {test} evaluates to either true or false (if any other value is returned, it's converted to either true or false as if by a call to the XPath fn:boolean function).

See Annotations (§3.14) for information on the role of the {annotations} property.

3.12.2 XML Representation of Assertion Schema Components

The XML representation for an assertion schema component is either an <assert> or a <report> element information item. The correspondences between the properties of those information items and properties of the component they correspond to are as follows:

XML Representation Summary: assert Element Information Item

<assert
  id = ID
  test = a restricted XPath expression, see below
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</assert>

<report
  id = ID
  test = a restricted XPath expression, see below
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</report>

Assertion Schema Component
Property
Representation
 
Either assert or report, depending on the item.
 
A restricted XPath expression corresponding to the ·actual value· of the test [attribute].
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.
Example
<xs:complexType name="intRange">
 <xs:attribute name="min" type="xs:int"/>
 <xs:attribute name="max" type="xs:int"/>
 <xs:assert test="@min le @max"/>
</xs:complexType>
The value of the min attribute must be less than or equal to that of the max attribute.
Example
<xs:complexType name="arrayType">
 <xs:sequence>
  <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"/>
 </xs:sequence>
 <xs:attribute name="length" type="xs:int"/>
 <xs:assert test="@length eq fn:count(./entry)"/>
</xs:complexType>
The value of the length attribute must be the same as the number of occurrences of entry sub-elements.

3.12.4 Assertion Validation Rules

Validation Rule: Assertion Satisfied
For an element information item to be locally ·valid· with respect to an assertion all of the following mustmust be true:
1 The {test}, with the element information item as the context node, evaluates to either true or false (see below) without raising any type error.
2 If the {category} is assert, then {test} evaluates to true.
3 If the {category} is report, then {test} evaluates to false.

Evaluation of {test} is performed as defined in [XPath 2.0], with the following exceptions:

  • If the evaluation returns a node-set, it is converted to either true or false as if by a call to the XPath fn:boolean function.
  • When operands are compared (see Value Comparisons of [XPath 2.0]), values are not converted to other values by casting, promoting, or substitution. When the 2 values are incomparable, the comparison always returns false.

3.12.6 Constraints on Assertion Schema Components

All assertions (see Assertions (§3.12)) must satisfy the following constraints.

Schema Component Constraint: Test Value OK
All of the following mustmust be true:
1 The {test} is a valid XPath expression, as defined in [XPath 2.0].
2 One of the following mustmust be true:
2.1 It conforms to the following extended BNF:
Test XPath expressions
[8]   Test   ::=   OrExpr
[9]   OrExpr   ::=   AndExpr ( 'or' AndExpr )*
[10]   AndExpr   ::=   BooleanExpr ( 'and' BooleanExpr )*
[11]   BooleanExpr   ::=   '(' OrExpr ')'
BooleanFunction |
( ValueFunction | ConstructorFunction ) ValueComp ValueExpr |
UnionExpr ( ValueComp ValueExpr )?
[12]   BooleanFunction   ::=   QName '(' OrExpr? ( ',' OrExpr )* ')'
[13]   ValueComp   ::=   'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge'
[14]   ValueExpr   ::=    ValueFunction | ConstructorFunction | UnionExpr
[15]   ValueFunction   ::=   QName '(' ValueExpr? ')'
[16]   ConstructorFunction   ::=    QName '(' StringLiteral ')'
[17]   StringLiteral   ::=   ('"' (EscapeQuot | [^"])* '"') | ("'" (EscapeApos | [^'])* "'")
[18]   EscapeQuot   ::=   '""'
[19]   EscapeApos   ::=   "''"
[20]   UnionExpr   ::=   PathExpr ( '|' PathExpr )*
[21]   PathExpr   ::=   ('.//')? ( StepExpr '/' )* ( StepExpr | '@' NameTest)
[22]   StepExpr   ::=   ('.' | NameTest ) ( '[' PredicateExpr ']' )*
[23]   PredicateExpr   ::=   PredicateOr | PositionLiteral
[24]   PredicateOr   ::=   PredicateAnd ( 'or' PredicateAnd )*
[25]   PredicateAnd   ::=   PredicateBoolean ( 'and' PredicateBoolean )*
[26]   PredicateBoolean   ::=    '(' PredicateOr ')'
PBooleanFunction |
( PValueFunction | ConstructorFunction ) ValueComp PredicateValue |
'@' NameTest ( ValueComp PredicateValue )?
[27]   PBooleanFunction   ::=   QName '(' PredicateOr? ( ',' PredicateOr )* ')'
[28]   PValueFunction   ::=   QName '(' PredicateValue? ')'
[29]   PredicateValue   ::=    ConstructorFunction | '.' | '@' NameTest
[30]   PositionLiteral   ::=   [0-9]+
2.2 It is an XPath expression involving the child and/or attribute axes whose abbreviated form is as given above.
For readability, whitespace may be used in field XPath expressions even though not explicitly allowed by the grammar: whitespace may be freely added within patterns before or after any token.

When tokenizing, the longest possible token is always returned.

3 If part of the restricted XPath matches QName in the BooleanFunction production or the PBooleanFunction production, then it identifies one of the following functions defined in the [Functions and Operators] specification: fn:true, fn:false, op:boolean-equal and fn:not.
4 If part of the restricted XPath matches QName in the ValueFunction production or the PValueFunction production, then it identifies one of the following functions defined in the [Functions and Operators] specification: fn:data, fn:local-name, fn:nanmespace-uri, op:count, fn:max and fn:min.
5 If part of the restricted XPath matches the ConstructorFunction production, then all of the following must beare true:
5.1 The piece that matches QName identifies a simple type definition.
5.2 The ·normalized value· of the piece that matches StringLiteral is locally ·valid· with respect to the simple type definition identified in the above step, as per String Valid (§3.15.4).
Note:  Implementations may choose to support a bigger subset of XPath 2.0. This specification may also define other commonly used subsets in future working drafts.

previous sub-section next sub-section3.13 Notation Declarations

Notation declarations reconstruct XML 1.0 NOTATION declarations.

Example
<xs:notation name="jpeg" public="image/jpeg" system="viewer.exe">
The XML representation of a notation declaration.

3.13.2 XML Representation of Notation Declaration Schema Components

The XML representation for a notation declaration schema component is a <notation> element information item. The correspondences between the properties of that information item and properties of the component it corresponds to are as follows:

XML Representation Summary: notation Element Information Item

<notation
  id = ID
  name = NCName
  public = token
  system = anyURI
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</notation>

Notation Declaration Schema Component
Property
Representation
 
 
The ·actual value· of the targetNamespace [attribute] of the parent schema element information item.
 
The ·actual value· of the system [attribute], if present, otherwise ·absent·.
 
The ·actual value· of the public [attribute]
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise ·absent·.
Example
<xs:notation name="jpeg"
             public="image/jpeg" system="viewer.exe" />

<xs:element name="picture">
 <xs:complexType>
  <xs:simpleContent>
   <xs:extension base="xs:hexBinary">
    <xs:attribute name="pictype">
     <xs:simpleType>
      <xs:restriction base="xs:NOTATION">
       <xs:enumeration value="jpeg"/>
       <xs:enumeration value="png"/>
       . . .
      </xs:restriction>
     </xs:simpleType>
    </xs:attribute>
   </xs:extension>
  </xs:simpleContent>
 </xs:complexType>
</xs:element>

<picture pictype="jpeg">...</picture>

3.13.5 Notation Declaration Information Set Contributions

Schema Information Set Contribution: Validated with Notation
Whenever an attribute information item is ·valid· with respect to a NOTATION, in the ·post-schema-validation infoset· its parent element information item either has a property as followshas the following properties:
PSVI Contributions for element information items
[notation]
An ·item isomorphic· to the notation declaration whose {name} and {target namespace} match the ·local name· and ·namespace name· (as defined in QName Interpretation (§3.16.3)) of the attribute item's ·actual value·
[notation system]
The value of the {system identifier} of that notation declaration.
[notation public]
The value of the {public identifier} of that notation declaration.
or has a pair of properties as follows:
PSVI Contributions for element information items
[notation system]
The value of the {system identifier} of that notation declaration.
[notation public]
The value of the {public identifier} of that notation declaration.
Note: For compatibility, only one such attribute shouldshould appear on any given element. If more than one such attribute does appear, which one supplies the infoset property or properties above is not defined.

previous sub-section next sub-section3.14 Annotations

Annotations provide for human- and machine-targeted annotations of schema components.

Example
<xs:simpleType fn:note="special">
  <xs:annotation>
   <xs:documentation>A type for experts only</xs:documentation>
   <xs:appinfo>
    <fn:specialHandling>checkForPrimes</fn:specialHandling>
   </xs:appinfo>
  </xs:annotation>
     
XML representations of three kinds of annotation.

3.14.1 The Annotation Schema Component

The annotation schema component has the following properties:

{user information} is intended for human consumption, {application information} for automatic processing. In both cases, provision is made for an optional URI reference to supplement the local information, as the value of the source attribute of the respective element information items. ·Validation· does not involve dereferencing these URIs, when present. In the case of {user information}, indication shouldshould be given as to the identity of the (human) language used in the contents, using the xml:lang attribute.

{attributes} ensures that when schema authors take advantage of the provision for adding attributes from namespaces other than the XML Schema namespace to schema documents, they are available within the components corresponding to the element items where such attributes appear.

Issue (RQ-19i):Issue 2851 (RQ-19 annotations in PSVI)

Out-of-band attributes were not always handled properly during component construction from schema documents. This is fixed by the overall reworking of annotation construction described in (§3.4.1).

Resolution:

See (§3.4.1).

Annotations do not participate in ·validation· as such. Provided an annotation itself satisfies all relevant ·Schema Component Constraints· it cannot affect the ·validation· of element information items.

The name [Definition:]  Annotated Component covers all the different kinds of component which may have annotations.

3.14.2 XML Representation of Annotation 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 and properties of the component it corresponds to are as follows:

XML Representation Summary: annotation Element Information Item

<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>

Annotation Schema Component
Property
Representation
 
A sequence of the <appinfo> element information items from among the [children], in order, if any, otherwise the empty sequence.
 
A sequence of the <documentation> element information items from among the [children], in order, if any, otherwise the empty sequence.
 
A sequence of attribute information items, namely those allowed by the attribute wildcard in the type definition for the <annotation> item itself or for the enclosing items which correspond to the component within which the annotation component is located.

The annotation component corresponding to the <annotation> element in the example above will have one element item in each of its {user information} and {application information} and one attribute item in its {attributes}.

previous sub-section next sub-section3.15 Simple Type Definitions

Note: This section consists of a combination of non-normative versionscopies of normative material from [XML Schema: Datatypes], for local cross-reference purposes, and normative material unique to this specification, relating to the interface between schema components defined in this specification and the simple type definition component.

Simple type definitions provide for constraining character information item [children] of element and attribute information items.

Example
<xs:simpleType name="fahrenheitWaterTemp">
 <xs:restriction base="xs:numberdecimal">
  <xs:fractionDigits value="2"/>
  <xs:minExclusive value="0.00"/>
  <xs:maxExclusive value="100.00"/>
 </xs:restriction>
</xs:simpleType>
The XML representation of a simple type definition.

3.15.1 (non-normative) The Simple Type Definition Schema Component

The simple type definition schema component has the following properties:

{base type definition }
A Simple Type Definition component. Required.

If the datatype has been derived by restriction then the Simple Type Definition component from which it is derived, otherwise the ·simple ur-type definition·.

{primitive type definition}
A Simple Type Definition component. With one exception, required if {variety} is atomic, otherwise must be ·absent·. The exception is ·anyAtomicType·, whose {primitive type definition} is ·absent·.

If non-·absent·, must be a primitive built-in definition.

{item type definition}
A Simple Type Definition component. Required if {variety} is list, otherwise must be ·absent·.
{member type definitions}
A sequence of Simple Type Definition components.

Must not be empty if {variety} is union, otherwise must be ·absent·.

Simple types are identified by their {name} and {target namespace}. Except for anonymous simple types (those with no {name}), since type definitions (i.e. both simple and complex type definitions taken together) must be uniquely identified within an ·XML Schema·, no simple type definition can have the same name as another simple or complex type definition. Simple type {name}s and {target namespace}s are provided for reference from instances (see xsi:type (§2.6.1)), and for use in the XML representation of schema components (specifically in <element> and <attribute>). See References to schema components across namespaces (<import>) (§4.2.3) for the use of component identifiers when importing one schema into another.

Note: The {name} of a simple type is not ipso facto the [(local) name] of the element or attribute information items ·validated· by that definition. The connection between a name and a type definition is described in Element Declarations (§3.3) and Attribute Declarations (§3.2).

A simple type definition with an empty specification for {final} can be used as the {base type definition} for other types derived by either of extension or restriction, or as the {item type definition} in the definition of a list, or in the {member type definitions} of a union; the explicit values extension, restriction, list and union prevent further derivations by extension (to yield a complex type) and restriction (to yield a simple type) and use in constructing lists and unions respectively.

{variety} determines whether the simple type corresponds to an atomic, list or union type as defined by [XML Schema: Datatypes].

As described in Type Definition Hierarchy (§2.2.1.1), every simple type definition is a ·restriction· of some other simple type (the {base type definition}), which is the ·simple ur-type definition· if and only if the type definition in question is one of the built-in primitive datatypes·anyAtomicType· or a list or union type definition which is not itself derived by restriction from a list or union respectively.A type definition has ·anyAtomicType· as its {base type definition} if and only if it is one of the built-in primitive datatypes. Each atomic type is ultimately a restriction of exactly one such built-in primitive datatype, which is its {primitive type definition}.

{facets} for each simple type definition are selected from those defined in [XML Schema: Datatypes]. For atomic definitions, these are restricted to those appropriate for the corresponding {primitive type definition}. Therefore, the value space and lexical space (i.e. what is ·validated· by any atomic simple type) is determined by the pair ({primitive type definition}, {facets}).

As specified in [XML Schema: Datatypes], list simple type definitions ·validate· space separated tokens, each of which conforms to a specified simple type definition, the {item type definition}. The item type specified must not itself be a list type, and must be one of the types identified in [XML Schema: Datatypes] as a suitable item type for a list simple type. In this case the {facets} apply to the list itself, and are restricted to those appropriate for lists.

A union simple type definition ·validates· strings which satisfy at least one of its {member type definitions}. As in the case of list, the {facets} apply to the union itself, and are restricted to those appropriate for unions.

The ·simple ur-type definition· or ·anyAtomicType· must not be named as the {base type definition} of any user-defined atomic simple type definitions: as it hasthey allow no constraining facets, this would be incoherent.

See Annotations (§3.14) for information on the role of the {annotations} property.

3.15.2 (non-normative) XML Representation of Simple Type Definition Schema Components

XML Representation Summary: simpleType Element Information Item

<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)*))
</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>

Simple Type Definition Schema Component
Property
Representation
 
The ·actual value· of the name [attribute] if present on the <simpleType> element, otherwise ·absent·.
 
The ·actual value· of the targetNamespace [attribute] of the parent <schema> ancestor element information item if present, otherwise ·absent·.
 
The appropriate case among the following:
1 If the <restriction> alternative is chosen, then the type definition ·resolved· to by the ·actual value· of the base [attribute] of <restriction>, if present, otherwise the type definition corresponding to the <simpleType> among the [children] of <restriction>.
2 If the <list> or <union> alternative is chosen, then the ·simple ur-type definition··anySimpleType·.
 
As for the {prohibited substitutions} property of complex type definitions, but using the final and finalDefault [attributes] in place of the block and blockDefault [attributes] and with the relevant set being {extension, restriction, list, union}.
 
A subset of {restriction, extension, list, union}, determined as follows. [Definition:]  Let FS be the ·actual value· of the final [attribute], if present, otherwise the ·actual value· of the finalDefault [attribute] of the ancestor schema element, if present, otherwise the empty string. Then the property value is the appropriate case among the following:
1 If ·FS· is the empty string, then the empty set;
2 If ·FS· is "#all", then {restriction, extension, list, union};
3 otherwise Consider ·FS· as a space-separated list, and include restriction if "restriction" is in that list, and similarly for extension, list and union.
 
The appropriate case among the following:
1 If the name [attribute] is present, then ·absent·
2 otherwise the appropriate case among the following:
2.1 If the parent element information item is <attribute>, then the corresponding Attribute Declaration
2.2 If the parent element information item is <element>, then the corresponding Element Declaration
2.3 If the parent element information item is <list> or <union>, then the Simple Type Definition corresponding to the grandparent <simpleType> element information item
2.4 otherwise (the parent element information item is <restriction>), the appropriate case among the following:
2.4.1 If the grandparent element information item is <simpleType>, then the Simple Type Definition corresponding to the grandparent
2.4.2 otherwise (the grandparent element information item is <simpleContent>), the Simple Type Definition which is the {content type} of the Complex Type Definition corresponding to the great-grandparent <complexType> element information item.
 
If the <list> alternative is chosen, then list, otherwise if the <union> alternative is chosen, then union, otherwise (the <restriction> alternative is chosen), then the {variety} of the {base type definition}.
 
The appropriate case among the following:
1 If the <restriction> alternative is chosen, then then a set of Constraining Facet components ·constituting a restriction· of the {facets} of the {base type definition} with respect to a set of Constraining Facet components corresponding to the appropriate element information items among the [children] of <restriction> (i.e. those which specify facets, if any), as defined in Simple Type Restriction (Facets) (§3.15.6).
2 If the <list> alternative is chosen, then a set with one member, a whiteSpace facet with {value} = collapse and {fixed} = true.
3 otherwise the empty set
 
A sequence of Annotation components corresponding to
1 the <annotation> element information item in the [children], if present;
2 If the <restriction> alternative is chosen, then the <annotation> element information item in the [children] of the <restriction>, if present;
3 If the <list> alternative is chosen, then the <annotation> element information item in the [children] of the <list>, if present;
4 If the <union> alternative is chosen, then the <annotation> element information item in the [children] of the <union>, if present;
[Definition:]  The ancestors of a ·type definition· are its {base type definition} and the ·ancestors· of its {base type definition}. (The ancestors of a Simple Type Definition T in the type hierarchy are themselves ·type definitions·; they are distinct from the XML elements which may be ancestors, in the XML document hierarchy, of the <simpleType> element which declares T.)
If the {variety} is atomic, the following additional property mappings also applymapping also applies:
Property
Representation
 
The built-in primitive type definition from which the {base type definition} is derived.From among the ·ancestors· of this Simple Type Definition, that Simple Type Definition which corresponds to a primitive datatype.
 
A set of facet components ·constituting a restriction· of the {facets} of the {base type definition} with respect to a set of facet components corresponding to the appropriate element information items among the [children] of <restriction> (i.e. those which specify facets, if any), as defined in Simple Type Restriction (Facets) (§3.15.6).
If the {variety} is list, the following additional property mappings also applymapping also applies:
List Simple Type Definition Schema Component
Property
Representation
 
The appropriate case among the following:
1 If the <list> alternative is chosen, then the Simple Type Definition ·resolved· to by the ·actual value· of the itemType [attribute] of <list>, if present, otherwise the Simple Type Definition corresponding to the <simpleType> among the [children] of <list>.
2 If the <restriction> option is chosen, then the {item type definition} of the {base type definition}.
 
The appropriate case among the following:
1 If the {base type definition} is ·anySimpleType·, then the Simple Type Definition (a) ·resolved· to by the ·actual value· of the itemType [attribute] of <list>, or (b), corresponding to the <simpleType> among the [children] of <list>, whichever is present.
Note: In this case, a <list> element will invariably be present; it will invariably have either an itemType [attribute] or a <simpleType> [child], but not both.
2 otherwise (that is, the {base type definition} is not ·anySimpleType·), the {item type definition} of the {base type definition}.
Note: In this case, a <restriction> element will invariably be present.
 
If the <restriction> alternative is chosen, a set of facet components ·constituting a restriction· of the {facets} of the {base type definition} with respect to a set of facet components corresponding to the appropriate element information items among the [children] of <restriction> (i.e. those which specify facets, if any), as defined in Simple Type Restriction (Facets) (§3.15.6), otherwise the empty set.
If the {variety} is union, the following additional property mappings also applymapping also applies:
Property
Representation
 
The appropriate case among the following:
1 If the <union> alternative is chosen, then [Definition:]  define the explicit members as the type definitions ·resolved· to by the items in the ·actual value· of the memberTypes [attribute], if any, followed by the type definitions corresponding to the <simpleType>s among the [children] of <union>, if any. The actual value is then formed by replacing any union type definition in the ·explicit members· with the members of their {member type definitions}, in order.
2 If the <restriction> option is chosen, then the {member type definitions} of the {base type definition}.
 
The appropriate case among the following:
1 If the {base type definition} is ·anySimpleType·, then the sequence of Simple Type Definitions (a) ·resolved· to by the items in the ·actual value· of the memberTypes [attribute] of <union>, if any, and (b) corresponding to the <simpleType>s among the [children] of <union>, if any, in order.
Note: In this case, a <union> element will invariably be present; it will invariably have either a memberTypes [attribute] or one or more <simpleType> [children], or both.
2 otherwise (that is, the {base type definition} is not ·anySimpleType·), the {member type definitions} of the {base type definition}.
Note: In this case, a <restriction> element will invariably be present.

Editorial Note: Priority Feedback Request

Note that the rule just given allows unions to be members of other unions. This is a change from version 1.0 of this specification, which prohibited unions in {member type definitions} and replaced any reference to a union M, in the XML declaration of a second union U, with the members of M. This had the unintended consequence that that if M had facets they were lost, and U erroneously accepted values not accepted by M. In order to correct this error, this version of this specification allows unions in {member type definitions} and removes the wording which replaced references to unions with their members. The XML Schema Working Group solicits input from implementors and users of this specification as to whether this change is an acceptable way of repairing the problem in version 1.0 of this specification, or whether it would be preferable to allow unions as members of other unions only if they have an empty {facets} property. If such a change would make this specification more (or less) attractive to users or implementors, please let us know.
 
If the <restriction> alternative is chosen, a set of facet components ·constituting a restriction· of the {facets} of the {base type definition} with respect to a set of facet components corresponding to the appropriate element information items among the [children] of <restriction> (i.e. those which specify facets, if any), as defined in Simple Type Restriction (Facets) (§3.15.6), otherwise the empty set.

3.15.3 Constraints on XML Representations of Simple Type Definitions

Schema Representation Constraint: Simple Type Definition Representation OK
In addition to the conditions imposed on <simpleType> element information items by the schema for schemas, all of the following mustmust be true:
1 The corresponding simple type definition, if any, must satisfysatisfies the conditions set out in Constraints on Simple Type Definition Schema Components (§3.15.6).
2 If the <restriction> alternative is chosen, either it must havehas a base [attribute] or a <simpleType> among its [children], but not both.
3 If the <list> alternative is chosen, either it must havehas an itemType [attribute] or a <simpleType> among its [children], but not both.
4
If the <union> alternative is chosen, either it has a non-empty memberTypes [attribute] or it has at least one simpleType [child].
5 Circular union type definition is disallowed. There are no circular union type definitions. That is, if the <union> alternative is chosen, there must not be anyare no entries in the memberTypes [attribute] at any depth which resolve to simple types with {variety} union which include among their transitive membership the component corresponding to the <simpleType>.
6
With the exception of <enumeration> and <pattern>, the [children] of <restriction> must not contain more than one element information item with the same name.

3.15.4 Simple Type Definition Validation Rules

Validation Rule: String Valid
For a string to be locally ·valid· with respect to a simple type definition all of the following mustmust be true:
1 It is schema-valid with respect to that definition as defined by Datatype Valid in [XML Schema: Datatypes].
2 The appropriate case among the following must beis true:
2.1 If The definition is ENTITY or is validly derived from ENTITY given the empty set, as defined in Type Derivation OK (Simple) (§3.15.6), then the string must beis a ·declared entity name·.
2.2 If The definition is ENTITIES or is validly derived from ENTITIES given the empty set, as defined in Type Derivation OK (Simple) (§3.15.6), then every whitespace-delimited substring of the string must beis a ·declared entity name·.
2.3 otherwise no further condition applies.

[Definition:]  A string is a declared entity name if and only if it is equal to the [name] of some unparsed entity information item in the value of the [unparsedEntities] property of the document information item at the root of the infoset containing the element or attribute information item whose ·normalized value· the string is.

3.15.6 Constraints on Simple Type Definition Schema Components

All simple type definitions other than the ·simple ur-type definition· and the built-in primitive datatype definitions (see Simple Type Definitions (§3.15))↓ must satisfy both the following constraints.

Schema Component Constraint: Simple Type Definition Properties Correct
All of the following mustmust be true:
2 All simple type definitions must beare derived ultimately from the ·simple ur-type definition (so· circular definitions are disallowed). That is, it must beis possible to reach a built-in primitive datatype or the ·simple ur-type definition· by repeatedly following the {base type definition}.
3 The {final} of the {base type definition} must notdoes not contain restriction.
4
There must not be more than one member of {facets} of the same kind.
Schema Component Constraint: Derivation Valid (Restriction, Simple)
The appropriate case among the following mustmust be true:
1 If the {variety} is atomic, then all of the following must beare true:
1.1 TheWith one exception, the {base type definition} must beis an atomic simple type definition or a built-in primitive datatypeThe exception is ·anyAtomicType·, which has ·anySimpleType·, whose {variety} is ·absent·, as its {base type definition}
1.2 The {final} of the {base type definition} must notdoes not contain restriction.
1.3 For each facet in the {facets} (call this DF) all of the following must beare true:
1.3.1 DF must beis an allowed constraining facet for the {primitive type definition}, as specified in the appropriate subsection of 3.2 Primitive datatypes.
1.3.2 If there is a facet of the same kind in the {facets} of the {base type definition} (call this BF), then the DF's {value} must beis a valid restriction of BF's {value} as defined in [XML Schema: Datatypes].
2 If the {variety} is list, then all of the following must beare true:
2.1 The {item type definition} must havehas a {variety} of atomic or union (in which case all the {member type definitions} must be atomicthere must be no types whose {variety} is list among the union's transitive membership).
2.2 The appropriate case among the following must beis true:
2.2.1 If the {base type definition} is the ·simple ur-type definition· , then all of the following must beare true:
2.2.1.1 The {final} of the {item type definition} must notdoes not contain list.
2.2.1.2 The {facets} must only contain contains only the whiteSpace facet component.
2.2.2 otherwise all of the following must beare true:
2.2.2.1 The {base type definition} must havehas a {variety} of list.
2.2.2.2 The {final} of the {base type definition} must notdoes not contain restriction.
2.2.2.3 The {item type definition} must beis validly derived from the {base type definition}'s {item type definition} given the empty set, as defined in Type Derivation OK (Simple) (§3.15.6).
2.2.2.4 Only length, minLength, maxLength, whiteSpace, pattern and enumeration facet components are allowed among the {facets}.
2.2.2.5 For each facet in the {facets} (call this DF), if there is a facet of the same kind in the {facets} of the {base type definition} (call this BF), then the DF's {value} must beis a valid restriction of BF's {value} as defined in [XML Schema: Datatypes].
The first case above will apply when a list is derivedconstructed by specifying an item type, the second when derived by restriction from another list.
3 If the {variety} is union, then all of the following must beare true:
3.1
The {member type definitions} must all have {variety} of atomic or list.
3.2 The appropriate case among the following must beis true:
3.2.1 If the {base type definition} is the ·simple ur-type definition· , then all of the following must beare true:
3.2.1.1 All of the {member type definitions} must have a {final} which does not contain union.
3.2.1.2 The {facets} property must beis empty.
3.2.2 otherwise all of the following must beare true:
3.2.2.1 The {base type definition} must havehas a {variety} of union.
3.2.2.2 The {final} of the {base type definition} must notdoes not contain restriction.
3.2.2.3 The {member type definitions}, in order, must beare each validly derived from the corresponding type definitions in the {base type definition}'s {member type definitions} given the empty set, as defined in Type Derivation OK (Simple) (§3.15.6).
3.2.2.4 Only pattern and enumeration facet components are allowed among the {facets}.
3.2.2.5 For each facet in the {facets} (call this DF), if there is a facet of the same kind in the {facets} of the {base type definition} (call this BF),then the DF's {value} must beis a valid restriction of BF's {value} as defined in [XML Schema: Datatypes].
The first case above will apply when a union is derivedconstructed by specifying one or more member types, the second when derived by restriction from another union.
3.3
3.4
The Simple Type Definition is not a member of its own transitive membership.
[Definition:]  If this constraint Derivation Valid (Restriction, Simple) (§3.15.6) holds of a simple type definition, it is a valid restriction of its {base type definition}.

[Definition:]  A simple type definition T is a valid restriction of its {base type definition} if and only if T satisfies constraint Derivation Valid (Restriction, Simple) (§3.15.6).

The following constraint defines relations appealed to elsewhere in this specification.

Schema Component Constraint: Type Derivation OK (Simple)
For a simple type definition (call it D, for derived) to be validly derived from a type definition (call this B, for base) given a subset of {extension, restriction, list, union} (of which only restriction is actually relevant) one of the following mustmust be true:
1 They are the same type definition.
2 All of the following must beare true:
2.1 restriction is not in the subset, or in the {final} of its own {base type definition};
2.2 One of the following must beis true:
2.2.1 D's {base type definition} is B.
2.2.2 D's {base type definition} is not the ·ur-type definition· and is validly derived from B given the subset, as defined by this constraint.
2.2.3 D's {variety} is list or union and B is the ·simple ur-type definition·.
2.2.4
B's {variety} is union and D is validly derived from in B's {member type definitions} given the subset, as defined by this constraint.
All of the following are true:
2.2.4.1 B's {variety} is union.
2.2.4.2 D is validly derived from a type definitionan ·unshadowed type definition· M in B's transitive membership given the subset, as defined by this constraint.
2.2.4.3 The {facets} property of B and of any intervening union datatypes is empty.
Note: It is a consequence of this requirement that the value space, lexical space, and lexical mapping of D will be subsets of those of B.

Editorial Note: Priority Feedback Request

The requirement that B and any unions intervening between B and D have no constraining facets is introduced in version 1.1 of this specification. Version 1.0 had no such restriction and thus allowed members of any union to be treated for some purposes as if derived from the union. The rules of 1.0 also did not ensure that values accepted by the member would also be datatype-valid with respect to the union, thus providing an unintended loophole which allowed values to be accepted which ought to have been invalid. The XML Schema Working Group solicits input from implementors and users of this specification as to whether the additional constraint introduced here is an acceptable way of achieving the goal of closing the loophole, or whether it is important that the loophole be closed without excluding facet-based restrictions of unions from the use of clause 2.2.4.

[Definition:]  A type definition S in the {member type definitions} of a union is shadowed if and only if its lexical space overlaps with the lexical space of some other simple type definition O which precedes it in that {member type definitions}, and S is not validly derived from O as defined by this constraint.
Note: With respect to clause 1, see the Note on identity at the end of (§3.4.6) above.
Schema Component Constraint: Simple Type Restriction (Facets)
For a simple type definition (call it R) to restrict another simple type definition (call it B) with a set of facets (call this S) all of the following mustmust be true:
1 The {variety} of R is the same as that of B.
2 If {variety} is atomic, the {primitive type definition} of R is the same as that of B.
3
The {facets} of R are the union of S and the {facets} of B, eliminating duplicates. To eliminate duplicates, when a facet of the same kind occurs in both S and the {facets} of B, the one in the {facets} of B is not included, with the exception of enumeration and pattern facets, for which multiple occurrences with distinct values are allowed.

The {facets} of R ·constitute a restriction· of the {facets} of B with respect to S.

Additional constraint(s) may apply depending on the kind of facet, see the appropriate sub-section of 4.3 Constraining Facets

[Definition:]  If clause 3 above holds, the {facets} of R constitute a restriction of the {facets} of B with respect to S.

[Definition:]   Given three sets of facets R, B, and S, R constitutes a restriction of B with respect to S if and only if all of the following are true:
1 Every facet in S is in R.
2 Every facet in B is in R, unless it is of the same kind as some facet in S.
3 Every facet in R is required by clause 1 or clause 2 above.

3.15.7 Built-in Simple Type Definitions

There is a simple type definition nearly equivalent to the ·simple ur-type definition·The Simple Type Definition of anySimpleType is present in every schema by definition. It has the following properties:

The ·simple ur-type definition·definition of ·anySimpleType· is the root of the simple type definition hierarchy, and as such mediates between the other simple type definitions, which all eventually trace back to it via their {base type definition} properties, and the ·ur-type definition··anyType·, which is its {base type definition}. This is why the ·simple ur-type definition· is exempted from the first clause of Simple Type Definition Properties Correct (§3.15.6), which would otherwise bar it because of its derivation from a complex type definition and absence of {variety}.

The Simple Type Definition of anyAtomicType is present in every schema. It has the following properties:

Simple type definitions forcorresponding to all the built-in primitive datatypes, namely string, boolean, float, double, numberdecimal, precisionDecimal, dateTime, duration, time, date, gMonth, gMonthDay, gDay, gYear, gYearMonth, hexBinary, base64Binary, anyURI, QName and NOTATION (see the Primitive Datatypes section of [XML Schema: Datatypes]