Copyright ©1999-2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
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. The schema language, which is itself represented in XML 1.0, provides a superset of the capabilities found in XML 1.0 document type definitions (DTDs). This specification depends on XML Schema Part 2: Datatypes.
This is a public working draft of XML Schema 1.0 for review by the public and by members of the World Wide Web Consortium.
It has been reviewed by the XML Schema Working Group, and the Working Group has agreed to its publication. The WG believes this draft to be `feature-complete': the functionality included here is substantially complete and is expected to be stable. We do not expect to add major new functionality, or to make major changes to the functionality described in this draft. Some sections of the draft (in particular those on conformance), and some aspects of the design (in particular details of the transfer syntax for schemas), on the other hand, are still rough and are expected to be revised.
Following a period of review and polishing, it is the WG's intent to issue a Last Call for Review by other W3C working groups sometime during March, 2000, and to submit this specification thereafter for publication as a Candidate Recommendation. This schedule may vary, depending on the comments of the public and of other W3C working groups on this draft. Such comments are instrumental in the WG's deliberations, and we encourage readers to review the draft and send comments to www-xml-schema-comments@w3.org
This working draft has been substantially restructured since the previous public release. This structural reorganisation is not yet complete. In this draft, unrestructured material is distinguished as follows:
[Unrestructured material elided]
The restructuring of Chapters 1 through 3 is largely completed: Attributes and Attribute groups give the clearest picture of how Chapters 5 and 6 will eventually look.
The lengthy introductory example material from the old Chapter 2 has been moved out of line into a non-normative companion document ([XML Schema: Exposition] and expanded considerably. Pointers to this will in due course be added to this document.
Although the Working Group does not anticipate further substantial changes to the functionality described here, this is still a working draft, subject to change. The present version should be implemented only by those interested in providing a check on its design or by those preparing for an implementation of the Candidate Recommendation. The Schema WG will not allow early implementation to constrain its ability to make changes to this specification prior to final release.
A list of current W3C working drafts can be found at http://www.w3.org/TR/. They may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress".
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 a formal specification of 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.
Chapter 4, XML Representation of Schemas and Schema Components (§4), presents the XML representation that maps to the abstract model, in the form of a DTD and XML Schema for an XML Schema document type, along with rules and conventions for identifying the components needed for any particular validation.
Chapter 5 presents Schema Access and Composition (§5), including the connection between documents and schemas, the import and inclusion of declarations and definitions and the foundations of schema-validity.
Chapter 6 discusses Conformance * (§6), including the rules by which documents are validated, and responsibilities of schema-aware processors.
The normative appendices include a (normative) DTD for Schemas (§B) and a (normative) Schema for Schemas (§A) for the transfer syntax, a Glossary (normative) * (§C) [not yet written] and References (normative) * (§D).
The purpose of XML Schema: Structures is to define the nature of XML schemas and their component parts, provide an inventory of XML markup constructs with which to represent schemas, and define the application of schemas to XML documents.
The purpose of an XML Schema: Structures schema is to define and describe a class of XML documents by using schema components to constrain and document the meaning, usage and relationships of their constituent parts: datatypes, elements and their content and attributes and their values. Schemas may also provide for the specification of additional document information, such as default values for attributes and elements. Schemas have facilities for self-documentation. Thus, XML Schema: Structures can be used to define, describe and catalogue XML vocabularies for classes of XML documents.
Any application that consumes well-formed XML can use the XML Schema: Structures formalism to express syntactic, structural and value constraints applicable to its document instances. The XML Schema: Structures formalism allows a useful level of constraint checking to be described and validated for a wide spectrum of XML applications. However, the language defined by this specification does not attempt to provide all the facilities that might be needed by any application. Some applications may require constraint capabilities not expressible in this language, and so may need to perform their own additional validations.
The definition of XML Schema: Structures depends on the following specifications: [URI], [XML-Infoset], [XML-Namespaces], [XPath], and [XML Schemas: Datatypes].
The following highlighting and typography is used to present technical material in this document:
Special terms are defined at their point of introduction in the text; hyperlinks connect other uses of the term to the definition. For example, a definition of term might read: [Definition:] A term is something we use a lot. The definition is labeled as such and the term is highlighted typographically. The end of the definition is not specially marked in the displayed or printed text.
The following terms are used in building definitions and describing the actions of XML Schema: Structures processors:
[Unrestructured material elided]
Non-normative examples are set off typographically and accompanied by a brief explanation:
Example
<schema targetNamespace="http://www.muzmo.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]
- Definition of the 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,
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 component,
are given. 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. The allowed content of the information item is
shown as a grammar fragment, using the Kleene operators ?,
* and +. The property correspondences are normative, but
the illustration of the XML representation element information items is not.
XML Representation Summary: exampleElement Information Item<example
count = integer
size = large | medium | small : medium>
Content: (child1 | child2*)
</example>
Example Schema Component
Property Representation {example property} Description of what the property corresponds to, e.g. the value of the size[attribute]
The following highlighting is used for non-normative commentary in this document:
Issue (dummy): A recorded issue.
Ed. Note: Notes from the editors to themselves or the Working Group.
NOTE: General comments directed to all readers.
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, and subsequent chapters define 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: Exposition] and then consult XML Representation of Schemas and Schema Components (§4), using the sections below as a guide to the underlying formal structure of the schema language.
An XML Schema defines a set of schema-valid XML documents. At a minimum, it consists of type definitions and element declarations. It identifies a set of well-formed element 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 default values for attributes and elements and the types of element and attribute information items.
The process of schema validation consists of determining whether an element information item is a member of the set defined by an XML Schema, and if so of adding any appropriate augmentations.
This specification builds on [XML] and [XML-Namespaces]. 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]) and namespace conformance (as defined in [XML-Namespaces]) for all candidates for schema-validity.
Just as [XML] and [XML-Namespaces] 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 interchange format for schemas is described in XML Representation of Schemas and Schema Components (§4)
Ed. Note: The datatype spec's use of the word "component" makes things somewhat confusing next to this specification's use of the same word. Perhaps the terminology in the datatype spec should be revised?
[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 12 kinds of component in all, falling into three groups. The primary components are as follows. They may have names, and (except for some element declarations) may be independently accessed:
The secondary components are as follows. Like the primary components, they may have names and be independently accessed:
Finally, the "helper" components provide small parts of other components; they are not independent of their context and cannot be independently accessed:
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 have and be identified by names, which are NCNames as defined by [XML-Namespaces].
[Definition:] Several kinds of component have a target namespace, which is either null or a namespace URI, also as defined by [XML-Namespaces]. 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 URI 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 schema-validation 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 Schemas and Schema Components (§4), in which each schema document contributes definitions and declarations to a single target namespace.
Schema-validity, defined in detail in Conformance * (§6), is a relation between information items and schema components. For example, an attribute information item may be schema-valid with respect to an attribute declaration, a list of element information items may be schema-valid 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 the overall definition of schema-validity.
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. First we describe characteristics of that hierarchy, then provide an introduction to simple and complex type definitions themselves.
[Definition:] Except for a distinguished ur-type definition, every type definition is, by construction, either a restriction, an extension of some other type definition. Collectively, the graph of these relationships forms a tree known as the Type Definition Hierarchy.
[Definition:] A type definition whose declarations or facets are in a one-to-one relation with those of another type definition, with each in turn restricting the possibilities of the one it corresponds to, is said to be a restriction. The specific restrictions 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.
[Definition:] A complex type definition which allows element or attribute content in addition to that allowed by another type definition is said to be an extension.
[Definition:] A distinguished ur-type definition is present in each XML Schema, serving as the root of the type definition hierarchy for that schema. The ur-type definition has the unique characteristic that it can function as a complex or a simple type definition, according to context. Specifically, restrictions of the ur-type definition can themselves be either simple or complex type definitions.
[Definition:] A type definition used as the basis for an extension or restriction is known as the base type definition of that definition.
Ed. Note: Should use this as a target for other references throughout the text.
A simple type definition is a set of constraints on strings and information about the values they encode, applicable to the [children] of an attribute information item or of an element information item with no element children. Informally, it applies to attribute values and text-only content of elements.
Each simple type definition, whether built-in (that is, defined in [XML Schemas: Datatypes]) or user-defined, is a restriction of some particular simple base type definition, which can be the ur-type definition.
For details on the composition and schema-validation contributions of simple type definitions, see Simple Type Definition Details (§3.12) and [XML Schemas: Datatypes]. The latter also defines an extensive inventory of pre-defined simple types. See XML Representation of Simple Type Definition Schema Components (§4.4.11) for the XML representation of simple type definitions, and Simple Type Definition Constraints (§6.3.12) for constraints on simple type definition components as such.
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 be empty, to be a string which is schema-valid with respect to particular simple type or to contain element information items which is schema-valid with respect to a particular model group, with or without character information items as well.
Each is complex type definition is either a:
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.
See Complex Type Definition Details (§3.3) for the composition and schema-validation contributions of complex type definition schema components, XML Representation of Complex Type Definition Schema Components (§4.4.3) for the XML representation of complex type definitions and Complex Type Definition Constraints (§6.3.11) for constraints on complex type definition components as such.
There are three kinds of declaration component: element, attribute, and notation. Each described in a section below. Also included is a discussion of element equivalence classes, which is a feature provided in conjunction with element declarations.
An element declaration is an association of a name with a type definition, either simple or complex, an (optional) default value and a set of identity-constraint definitions. The association is either global or scoped to a containing complex type definition. A global element declaration with name 'A' is broadly comparable to a pair of DTD declarations as follows, where the associated type definition fills in the ellipsis:
<!ELEMENT A . . .> <!ATTLIST A . . .>
Element declarations contribute to schema-validity as part of model group validation, when their defaults and type components are checked against an element information item with a matching name and namespace, and by triggering identity-constraint definition validation.
See Element Declaration Details (§3.2) for the composition and schema-validation contributions of element declaration schema components, XML Representation of Element Declaration Schema Components (§4.4.2) for the XML representation of element declarations and Element Declaration Constraints (§6.3.2) for constraints on element declaration components as such.
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 equivalence classes, XML Schemas provides a more powerful model supporting substitution of one named element for another. Any global element declaration can serve as the defining element, or exemplar, for an element equivalence class. Other global element declarations, regardless of target namespace, can be designated as members of the class defined by the exemplar. In a suitably enabled content model, a reference to the exemplar validates not just the exemplar itself, but elements corresponding to any member of the equivalence class as well.
All such members must have type definitions which are either the same as the exemplar'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 equivalence class are defined, the content of member elements is strictly limited according to the type definition of the equivalence class exemplar.
Note that element equivalence classes are not represented as separate components. They are specified in the property values for element declarations (see Element Declaration (§2.2.2.1)).
An attribute declaration is an association between a name and a simple type definition, together with occurrence information and (optionally) a default value. The association is local to its containing complex type definition. Attribute declarations contribute to schema-validity as part of complex type definition validation, when their occurrence, defaults and type components are checked against an attribute information item with a matching name and namespace.
See Attribute Declaration Details (§3.1) for the composition and schema validation contributions of attribute declaration schema components, XML Representation of Attribute Declaration Schema Components (§4.4.1) for the XML representation of attribute declarations and Attribute Declaration Constraints (§6.3.1) for constraints on attribute declaration components as such.
A notation declaration is an association between a name and an identifier for a
notation. For an attribute information item to be schema-valid with respect to a
NOTATION simple type definition, its value must have been declared
with a notation declaration.
See Notation Declaration Details (§3.10) for the composition and schema validation contributions of notation declaration schema components, XML Representation of Notation Declaration Schema Components (§4.4.9) for the XML representation of notation declarations and Notation Constraints (§6.3.8) for constraints on notation declaration components as such.
The model group, particle, and wildcard components contribute to the portion of a complex type definition that controls an element information item's content type.
A model group is a constraint in the form of a grammar fragment that applies to lists of element information items. It consists of a list of particles, i.e. element declarations, wildcards and model groups. There are three varieties of model group:
See Model Group Details (§3.6) for the composition and schema-validation contributions of model group schema components, Complex Type Definition Details (§3.3) for the use of model groups as content models, XML Representation of Model Group Schema Components (§4.4.6) for the XML representation of model groups and Model Group Constraints (§6.3.7) for constraints on model group components as such.
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 schema-validity as part of complex type validation, when they allow anywhere from zero to many element information items or sequences thereof, depending on their contents and occurrence constraints.
[Definition:] A particle can be used in a complex type definition to express a validity constraint on 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] content models; unlike [XML], XML Schema: Structures applies content models to the validation of both mixed and element-only content.
See Particle Details (§3.7) for the composition and schema-validation contributions of particle schema components, XML Representation of Model Group Schema Components (§4.4.6) for the XML representation of particles and Particle Constraints (§6.3.10) for constraints on particle components as such.
A wildcard is a special kind of particle which matches element information items dependent on their namespace URI, independently of their local names.
See Wildcard Details (§3.8) for the composition and schema-validation contributions of wildcard schema components, XML Representation of Wildcard Schema Components (§4.4.7) for the XML representation of wildcards and Wildcard Constraints (§6.3.5) for constraints on wildcard components as such.
A 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 schema-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.
See Identity-constraint Definition Details (§3.9) for the composition and schema-validation contributions of identity-constraint definition schema components, XML Representation of Identity-constraint Definition Schema Components (§4.4.8) for the XML representation of identity-constraint definitions and Identity-constraint Definition Constraints (§6.3.3) for constraints on identity-constraint definition components as such.
There are two kinds of convenience definitions available for use in reusing pieces of complex type definitions: model group definitions and attribute group definitions.
A model group definition is an association between a name and a model group, for use in reusing the same model group in several complex type definitions.
See Model Group Definition Details (§3.5) for the composition and schema validation contributions of model group definition schema components, XML Representation of Model Group Definition Schema Components (§4.4.5) for the XML representation of model group definitions and Model Group Definition Constraints (§6.3.6) for constraints on model group definition components as such.
An attribute group definition is an association between a name and a set of attribute declarations, for use in reusing the same set in several complex type definitions.
See Attribute Group Definition Details (§3.4) for the composition and schema-validation contributions of attribute group definition schema components, XML Representation of Attribute Group Definition Schema Components (§4.4.4) for the XML representation of attribute group definitions and Attribute Group Definition Constraints (§6.3.4) for constraints on attribute group definition components as such.
An annotation is information for human and/or mechanical consumers. The interpretation of such information is not defined in this specification.
See Annotation Details (§3.11) for the composition and schema-validation contributions of annotation schema components, XML Representation of Annotation Schema Components (§4.4.10) for the XML representation of annotations and Annotation Constraints (§6.3.9) for constraints on annotation components as such.
Ed. Note: We need a Chapter 2 intro to the interchange syntax.
The [XML] 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 focussed on schema-validity, 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 schema-validation of information items:
Schema information set
contributions are not new. 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 normalisation or access.
(As an example of the latter case, consider the
effect of NMTOKENS on attribute whitespace, and the semantics of
ID and IDREF.) By including schema
information set contributions, this specification makes explicit some features
that XML 1.0 left implicit.
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 Constraints on Schemas, Validity Contributions, and Schema Information Set Contributions contained in this specification.
[Definition:] Processors which accept schemas in the form of XML documents as described in XML Representation of Schemas and Schema Components (§4) are additionally said to provide conformance to the XML Representation of Schemas. 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 XML Representation of Schemas and Schema Components (§4) for mapping the contents of such documents to schema components for use in validation.
NOTE: By separating the conformance requirements relating to the concrete syntax of XML schema documents, this specification admits processors which validate using schemas stored in optimised 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.
[Definition:] Fully conforming processors are network-enabled processors which support both levels of conformance described above, and which must additionally be capable of accessing schema documents from the World Wide Web according to Representation of Schemas on the World Wide Web (§2.7) and XXX. .
Ed. Note: A a reference to the rules for handling schema location, dereference of namespace Uris, etc.
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 recommendation to define such additional levels of conformance.
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.
This specification therefore introduces the term [Definition:] symbol space to represent 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]. 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.
Attribute declarations and locally scoped element declarations are special with regard to symbol spaces. Every complex type definition defines its own attribute declaration symbol space and local element declaration symbol space, where these symbol spaces are distinct from each other and from any of the other symbol spaces. So, for example, several complex type definitions having the same target namespace can contain an attribute declaration for the unqualified name "priority", or contain a local element declaration for the name "address", without conflict or necessary relation between the two.
The XML representation of schema components uses a vocabulary
identified by the namespace URI http://www.w3.org/1999/XMLSchema.
XML Schema: Structures also defines several attributes for direct use in XML documents. These attributes are in a different namespace,
which has the namespace URI http://www.w3.org/1999/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.
The Simple Type Definition (§2.2.1.2) or Complex Type Definition (§2.2.1.3) used to validate an element is usually
determined by reference to the appropriate schema components.
However, when permitted by those components, an element can
explicitly assert its type using the attribute xsi:type.
The value of this attribute is a QName; see QName Interpretation (§4.3) for
the means by which the QName is
associated with a type definition.
XML Schema: Structures introduces a distinguished null value for XML document elements. An
element has the null value if it has no [children] and carries the attribute xsi:null.
Ed. Note: Are other attributes allowed? Must sync with validation rules.
On the World Wide Web, schemas are conventionally represented as documents of MIME type "text/xml", conforming to the specifications in XML Representation of Schemas and Schema Components (§4).
The following sections provide full details on the properties and significance of each kind of schema component. For each property, its range, that is the kinds of values it may have, is defined. This can be understood as defining a schema as a labelled directed graph, where every vertex is a schema component or a literal (string, boolean, number) and every labelled edge a property. Any property not identified as optional is required to be present, optional properties which are absent are taken to have null 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 null. Any property value identified as subset of some set may be equal to that set, unless a proper subset is explicitly called for. By 'string' here and below is meant a sequence of ISO 10646 character codes identified as legal XML character codes in [XML].
Ed. Note: Or the UNICODE 3 addendum, where/when?
Throughout the following sections, when we refer to the [value] of some attribute information item, we mean by this a string composed of, in order, the [character code] of each character information item in the [children] of that attribute information item.
Many properties of schema components are identified below as having other schema 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 discharged. This specification addresses the matter of missing components in a uniform manner, described in Missing Sub-components (§6.2): no mention of handling missing components will be found in the individual component descriptions below.
NOTE: Schema components are an idealisation 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 above of language such as "properties . . . having . . . components as values".
NOTE: Readers whose primary interest is in the XML representation of schemas may wish to skip this chapter on the first reading, concentrating on XML Representation of Schemas and Schema Components (§4) and [XML Schema: Exposition].
Ed. Note: Due to time constraints in preparing this draft, the {annotation} properties are not explicitly described for the components below. In all cases, the property is an annotation (see "Annotation Details" below).
Attribute declarations provide for:
The attribute declaration schema component has the following properties:
Schema Component: Attribute Declaration
- [name]
- An NCName as defined by [XML-Namespaces].
- [target namespace]
- Either null or a namespace URI, as defined in [XML-Namespaces].
- [simple type definition]
- A simple type definition.
- [min occurs]
- 0 or 1
- [max occurs]
- 0 or 1
- [value constraint]
- Optional. A pair consisting of a string and one of default, fixed.
- [annotation]
- Optional. An annotation
The {name} property must match the local part of the names of attributes being validated.
A "qualified" attribute name is one that appears with a namespace prefix which is itself declared with a
value other than the empty string. A non-null value of the {target namespace} property provides for validation of
such attributes qualified with an identical namespace URI. Null values of {target namespace} provide for validation of local
(unprefixed) attributes. Each complex type definition provides its own symbol space for the
names of its associated local attribute declarations. (E.g. an attribute
named title within one type definition need not have the same
simple type definition as one declared within another complex
type; neither of these need agree with the declaration for a similarly named qualified attribute.)
A {min occurs} of 1 specifies that the corresponding attribute must be present; a value of 0 allows for optional attributes. Similarly, a {max occurs} of 0 indicates an attribute that must not be present; a value of 1 (the normal case) allows the attribute to occur explicitly.
The value of the attribute must conform to the supplied {simple type definition}.
{value constraint} reproduces the functions of XML 1.0 default and #FIXED attribute values. fixed indicates that the attribute value must match the supplied constraint string; default specifies that the attribute is to appear unconditionally in the post-schema-validation information set, with the supplied value used whenever the attribute is not actually present.
NOTE: A more complete and formal presentation of the semantics of {name}, {target namespace}, {min occurs}, {max occurs} and default {value constraint} is provided in conjunction with other aspects of complex type validation (see Element Children and Attributes Valid (§3.3).)
[XML-Infoset] distinguishes namespace declarations such as xmlns or xmlns:xsl from
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 (§6.3.1). No means is provided to supply a
default value for a namespace declaration.
See XML Representation of Attribute Declaration Schema Components (§4.4.1) for the XML representation of attribute declarations and Attribute Declaration Constraints (§6.3.1) for constraints on attribute declaration components as such.
Element declarations provide for:
The element declaration schema component has the following properties:
Schema Component: Element Declaration
- [name]
- An NCName as defined by [XML-Namespaces].
- [target namespace]
- Either null or a namespace URI, as defined in [XML-Namespaces].
- [scope]
- Optional. Either global or a complex type definition.
- [type definition]
- Either a simple type definition or a complex type definition.
- [nullable]
- A boolean
- [value constraint]
- Optional. A pair consisting of a string and one of default, fixed.
- [identity-constraint definitions]
- A set of constraint definitions.
- [equivalence class affiliation]
- Optional. A global element definition.
- [equivalence class exclusions]
- A subset of {extension, list, restriction, reproduction}.
- [disallowed substitutions]
- A subset of {equivClass, extension, list, restriction, reproduction}.
- [abstract]
- A boolean
- [annotation]
- Optional. An annotation
The {name} property must match the local part of the names of elements being validated.
A {scope} of global declares elements available for use in content models throughout the schema. Locally scoped elements are available for use only within the complex type identified by the {scope} property. For globally scoped element declarations, a non-null value of the {target namespace} property provides for validation of namespace qualified elements. Null values of {target namespace} validate unqualified elements, including locally scoped elements. This property is also null in the case of non-global declarations within named model groups: their scope will be determined when they are used in the construction of complex type definitions.
An element is schema-valid if it obeys the schema validity constraints of the {type definition}. For such an element, the schema information set contributions from the {type definition} are applied to the corresponding element information item in the post-schema-validation information set. {type definition} must not be an abstract type definition.
If {nullable} is true, then the element is also schema valid if it has
no text or element content, and
carries the namespace qualified attribute with [local name] null from namespace http://www.w3.org/1999/XMLSchema/instance (see xsi:null (§2.6.2)). Formal details of element validation are described in Element Valid (Explicit) (§3.2).
{value constraint} establishes a default or fixed value for an element. If default is specified, and if the element being validated is empty, then the supplied constraint string becomes [character] [children] 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 it must match the supplied constraint string.
{identity-constraint definitions} express constraints establishing uniquenesses and reference relationships among the values of related elements and attributes. See Identity-constraint Definition Details (§3.9).
Element declarations are members of the equivalence class, if any, identified by {equivalence class affiliation}. Membership is transitive; an element declaration is implicitly a member of any class of which its {equivalence class affiliation} is a member.
An empty {equivalence class exclusions} creates an equivalence class admitting other element declarations having the same {type definition} or types derived therefrom. The explicit values of {equivalence class exclusions} exclude from the equivalence class elements having types which are extensions, lists, restrictions or reproductions respectively of {type definition}. If all values are specified, then no equivalence class is possible based on this element 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, list, restriction and/or reproduction of the type of the declared element, and/or (b) from validating elements which are in the same equivalence class (equivClass) as the declared element. If {disallowed substitutions} is empty, then all derived types and equivalence class members are valid.
Element declarations for which {abstract} is true can appear in content models only when equivalence class substitution is allowed; such declarations may not themselves ever be used to validate element content.
See XML Representation of Element Declaration Schema Components (§4.4.2) for the XML representation of element declarations and Element Declaration Constraints (§6.3.2) for constraints on element declaration components as such.
| 1.1 |
If {nullable} is false there is no attribute information item among the element
information item's [attributes] whose [namespace URI] is identical to http://www.w3.org/1999/XMLSchema/instance and whose [local name] is null;
|
||||
| 1.2 |
If {nullable} is true and there is such an attribute
information item and its [value] is true, then
|
If there is an attribute information item among the element information item's [attributes] whose [namespace URI] is identical to
http://www.w3.org/1999/XMLSchema/instance and whose [local name] is type, then
| 2.1 | The [value] of that attribute information item is schema-valid with respect to the built-in QName simple type, as defined by String Valid (§3.12); |
| 2.2 | The local name and namespace URI (as defined in QName Interpretation (§4.3)), of the [value] of that attribute information item resolve to a type definition, as defined in QName resolution (§4.3) -- [Definition:] call this type definition the item type definition; |
| 2.3 | The item type definition is validly derived from the {type definition} given the {disallowed substitutions} as defined in Type Derivation OK (Simple) (§6.3.12) (if it is a simple type definition) or as defined in Type Derivation OK (Complex) (§6.3.11) (if it is a complex type definition). |
If the declaration has a {value constraint}, then provided clause 1.2 has not obtained
| 3.1 | If the element information item has no character information item [children] and the actual type definition is a local type definition, the {value constraint} string is schema-valid with respect to the actual type definition as defined by String Valid (§3.12) (if the actual type definition is a simple type definition) or else (the actual type definition is a complex type definition) the string must be a valid default for the actual type definition as defined in Element Default Valid (Immediate) (§6.3.2); |
| 3.2 | If the {value constraint} is fixed, the element information item must have no element information item [children], and the string composed of the element information item's character information item [children] in order must be either empty or match the string of the {value constraint}; |
Otherwise (the element information item has character information item [children] or there is no {value constraint}) if the actual type definition is a simple type definition, then
| 4.1.1 | The element information item's [attributes] must be empty,
excepting those whose [namespace URI] is identical to http://www.w3.org/1999/XMLSchema/instance and whose [local name] is one of type, nullable or schemaLocation; |
| 4.1.2 | The element information item must have no element information item [children]; |
| 4.1.3 | the string composed of the [character code] of each of the element information item's character information item [children] in order must be schema-valid with respect to the actual type definition as defined by String Valid (§3.12) |
| 4.2.1 | The element information item must be schema-valid with respect to the actual type definition as per Element Children and Attributes Valid (§3.3); |
| 4.2.2 | The element information item must be schema-valid with respect to each of the {identity-constraint definitions} as per Identity-constraint Satisfied (§3.9). |
Issue (nullRequiresEmpty): Is it a precondition for being nullable that the element's contentType allow no content? If not, then more needs to be said in Chapter 6, if so, this needs to be spelled out.
Ed. Note: The above also allows null elements to have attributes, i.e. it's their CONTENT which is null. Was that the designers' intention? See related ednote under xsi:null in chapter 2.
NOTE: The {name} and {target namespace} properties are not mentioned above because they are checked during particle validation, as per Element Sequence Valid (Particle) (§3.7).
Ed. Note: Should we add a property to indicate THAT the value was supplied by default?
Complex Type Definitions provide for:
A complex type definition schema component has the following properties:
Schema Component: Complex Type Definition
- [name]
- Optional. An NCName as defined by [XML-Namespaces].
- [target namespace]
- Either null or a namespace URI, as defined in [XML-Namespaces].
- [base type definition]
- Either a simple type definition or a complex type definition.
- [derivation method]
- One of extension, restriction, reproduction
- [final]
- A subset of {extension, restriction, reproduction}.
- [abstract]
- A boolean
- [attribute declarations]
- A set of attribute declarations.
- [attribute wildcard]
- Optional. One of any; a pair of not and a namespace URI or null; or a set whose members are either namespace URIs or null.
- [content type]
- One of empty, a simple type definition or a pair consisting of a content model (I.e a Particle (§2.2.3.2)) and one of mixed, element-only.
- [prohibited-substitutions]
- A subset of {extension, restriction, reproduction}.
- [annotation]
- Optional. An annotation
Complex types are identified by their {name} and {target namespace}. Except for anonymous complex types (those with no {name}), complex type definitions must be uniquely identified within an XML Schema. 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 Schemas and Schema Components (§4) (specifically in element and attribute). See References to schema components across namespaces (§5.2.2) 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 Declaration Details (§3.2).
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 any of extension, restriction or reproduction; the explicit values extension, restriction and reproduction prevent further derivations by extension, restriction and reproduction respectively. If all values are specified, then the complex type is said to be [Definition:] final: no further derivations are possible.
A complex type for which {abstract} is true must not appear as the {type definition} of an Element Declaration (§2.2.2.1), and must not be referenced from an xsi:type (§2.6.1) attribute in an instance document; such abstract complex types can be used as {base type definition}s, but they are never used directly to validate element content.
{attribute declarations} are a set of individual Attribute Declaration (§2.2.2.3)s to be used for schema-validating the [attributes] of element information items. See Element Children and Attributes Valid (§3.3) and Attribute Valid (§3.1) for details of attribute validation.
{attribute wildcard}s provide a more flexible specification for validation of attributes not explicitly included in {attribute declarations}. Informally, the specific values of {attribute wildcard} are interpreted as follows:
See Element Children and Attributes Valid (§3.3) and Wildcard allows Namespace URI (§3.8) for formal details of attribute wildcard validation.
{content type} determines the schema-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 elements with an xsi:type (§2.6.1) attribute that identifies an extension, restriction or reproduction of the type of the declared element. If {prohibited-substitutions} is empty, then all such substitutions are valid.
See Element Children and Attributes Valid (§3.3) for a formal specification of element content validation.
See XML Representation of Complex Type Definition Schema Components (§4.4.3) for the XML representation of complex type definitions and Complex Type Definition Constraints (§6.3.11) for constraints on complex type definition components as such.
| 1.1 | {abstract} is false; | ||||||||
| 1.2 |
|
||||||||
| 1.3 |
For each attribute information item in the element information
item's [children] excepting those whose [namespace URI] is identical to http://www.w3.org/1999/XMLSchema/instance and whose [local name] is one of type, nullable or schemaLocation, if
there is among the {attribute declarations} one whose
{name} matches the attribute information item's [local name] and whose {target namespace} is identical to the attribute information item's [namespace URI]
|
||||||||
| 1.4 |
Each attribute declaration in the {attribute declarations} with a {min occurs} of 1 matches one of the attribute information items in the element information item's [children] as per clause 3 above.
|
0 which has a {value constraint} and does not match one of the attribute information items in the element information item's [children] as per clause 3 of Element Children and Attributes Valid (§3.3) above, the post-schema
validation infoset has an attribute information item whose [local name] is that attribute declaration's {name}
whose [namespace URI] is the attribute declaration's {target namespace} and whose [children] are a list of character information items, one per character
in the declaration's {value constraint} string, added to the
[attributes] of the element information item .
There is a complex type definition version of the ur-type definition present in every schema by definition. It has the following properties:
| Complex Type Definition of the Ur-Type | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Ed. Note: This should be handled with a generic tableau markup
The mixed content specification together with the
unconstrained wildcard content model and attribute specification produce the defining property for the
complex ur-type definition, namely that every complex type definition is
either an extension of a simple type definition or (eventually) a restriction
of the complex ur-type definition: its permissions and requirements are
the least restrictive possible.
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 schema-validation as such, but the {attribute declarations} and {attribute wildcard} of one or more complex type definitions may be constructed in whole or part by reference to an attribute group. Attribute group definitions are provided primarily for reference from the XML Representation of Schemas and Schema Components (§4) (see complexType and attributeGroup). Thus, attribute group definitions provide a replacement for some uses of XML's parameter entities.
The attribute group definition schema component has the following properties:
Schema Component: Attribute Group Definition
- [name]
- An NCName as defined by [XML-Namespaces].
- [target namespace]
- Either null or a namespace URI, as defined in [XML-Namespaces].
- [attribute declarations]
- A set of attribute declarations.
- [attribute wildcard]
- Optional. One of any; a pair of not and a namespace URI or null; or a set whose members are either namespace URIs or null.
- [annotation]
- Optional. An annotation
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 (§5.2.2) for the use of component identifiers when importing one schema into another.
{attribute declarations} is a set of attribute declarations specifically identified as members of the attribute group.
{attribute wildcard} provides for an attribute wildcard to be included in an attribute group. See above under Complex Type Definition Details (§3.3) for the interpretation of attribute wildcards during validation.
See Element Children and Attributes Valid (§3.3) and Wildcard allows Namespace URI (§3.8) for formal details of attribute wildcard validation. See XML Representation of Attribute Group Definition Schema Components (§4.4.4) for the XML representation of attribute group definitions, and Attribute Group Definition Constraints (§6.3.4) for constraints on attribute group definition components as such.
A model group definition associates a name and optional annotations with a Model Group (§2.2.3.1). 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 Definition Schema Components (§4.4.3) (see complexType and group). Thus, model group definitions provide a replacement for some uses of XML's parameter entities.
The model group definition schema component has the following properties:
Schema Component: Model Group Definition
- [name]
- An NCName as defined by [XML-Namespaces].
- [target namespace]
- Either null or a namespace URI, as defined in [XML-Namespaces].
- [model group]
- A model group.
- [annotation]
- Optional. An annotation
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 (§5.2.2) for the use of component identifiers when importing one schema into another.
Model group definitions per se do not participate in schema-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 (§2.2.3.1) for which the model group definition provides a name.
See XML Representation of Model Group Definition Schema Components (§4.4.5) for the XML representation of model group definitions and Model Group Definition Constraints (§6.3.6) for constraints on model group definition components as such.
When the [children] of element information items are not constrained to be empty or by reference to a simple type definition (Simple Type Definition Details (§3.12)), 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.
The model group schema component has the following properties:
Schema Component: Model Group
- [compositor]
- One of all, choice or sequence.
- [particles]
- A list of particles
- [annotation]
- Optional. An annotation
{compositor}determines whether the element information item [children] validated by the model group must:
{annotation}Description to be supplied in a future draft.
A sequence (possibly empty) of element information items is schema-valid with respect to a model group if
| 1.1 |
The {compositor} is sequence and there is 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 schema-valid
with respect to the corresponding particle in the {particles} as defined in Element Sequence Valid (Particle) (§3.7);
|
| 1.2 | The {compositor} is choice and there is a particle among the {particles} such that the sequence is schema-valid with respect to that particle as defined in Element Sequence Valid (Particle) (§3.7); |
| 1.3 |
The {compositor} is all and there is 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 schema-valid with respect to the corresponding particle as defined in Element Sequence Valid (Particle) (§3.7);
|
Nothing in the above should be understood as ruling out groups whose {particles} is empty: although no sequence can be schema-valid with respect to such a group whose {compositor} is choice, the empty sequence is schema valid with respect to empty groups whose {compositor} is sequence or all.
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, particles is restricted to a list of local and global element declarations (see Model Group Constraints (§6.3.7)). A much simpler implementation is possible for than would arise from a literal interpretation of the definition above; informally, the content is valid when each declared element occurs exactly once, and each is valid with respect to its corresponding declaration. The elements can occur in arbitrary order. <