From: http://www.w3.org/1999/05/06-xmlschema-1/structures.xml Date: 1999-05-07 XML Schema: Structures"> XML Schemas: Datatypes"> ]>
XML Schema Part 1: Structures &XSP1.version; W3C Working Draft &draft.day; &draft.month; &draft.year; &XSP1.base;&XSP1.URI;.xml &XSP1.URI;.html &XSP1.URI;.xsd &XSP1.URI;.dtd http://www.w3.org/TR/xmlschema-1/ David Beech Oracle dbeech@us.oracle.com Scott Lawrence Agranat Systems lawrence@agranat.com Murray Maloney Commerce One murray@muzmo.com Noah Mendelsohn Lotus noah_mendelsohn@lotus.com Henry S. Thompson University of Edinburgh ht@cogsci.ed.ac.uk

This is a W3C Working Draft for review by members of the W3C and other interested parties in the general public.

It has been reviewed by the XML Schema Working Group and the Working Group has agreed to its publication. Note that not that all sections of the draft represent the current consensus of the WG. Different sections of the specification may well command different levels of consensus in the WG. Public comments on this draft will be instrumental in the WG's deliberations.

Please review and send comments to www-xml-schema-comments@w3.org

The facilities described herein are in a preliminary state of design. The Working Group anticipates substantial changes, both in the mechanisms described herein, and in additional functions yet to be described. The present version should not be implemented except as a check on the design and to allow experimentation with alternative designs. 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".

XML Schema: Structures is part one of a two part draft of the specification for the XML Schema definition language. This document proposes 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.)

Boston, Mountain View, Toronto, et al.: World-Wide Web Consortium, XML Working Group, 1999.

Created in electronic form using XML.

English Extended Backus-Naur Form (formal grammar) Extensible Markup Language (XML) 1999-05-03: MCM: Updated schema and DTD. Package and test. 1999-05-03 Integration of final editors' concerns for WD1. Includes HT work on constraints. 1999-05-02 NRM General cleanup of first few chapters. Remove chapter 4 redundancy (tuple discussion) with new validity rules. 1999-05-02: HST: still chipping away at validity. Redefined the XSDL/XDTL entities. 19940502: MCM: mostly annotating the schema. Also moved info about abstract grammar into Chapter 2. Chapter 3 now starts right into defining a schema. Edited text entities to make them easier to manage. 19940501: HST: various 1999-04-30: NRM : revisions to chapter 4 1999-04-28: DB (pp HST) : promised edits for improved consistency and definition of 'schema'; suggested modifications to 3.4.9/10 and 3.5 1999-04-39: HST : integrated DB's edits, completely rewrote 6.1, replaced virtually all <B> with correct <...ref> 1999-04-28: DB (pp HST) : promised edits for improved consistency and definition of 'schema'; suggested modifications to 3.4.9/10 and 3.5 1999-04-23: HST : Got all productions sorted using 'nt' and correct IDs. 1999-04-21 : HST : Added lots of IDs and constraint heads: Validates w/o error 1999-04-21 : HST : Converted with no content changes to speak of from MCM-XSDL-19990416.html. This version has only ID/IDREF related errors left.
Introduction

This structural part (&XSP1;) of the XML Schema definition language is a distillation of eight months of work by the &SchemaWG;, including four weeks of intensive work by a group of five editors. This Working Draft draws heavily on the work of , , , and . Requirements for &XSP1; can be found in .

Chapter 2 presents a for &XSP1;, including an introduction to schema constraints, types, schema composition, and symbol spaces. The abstract and concrete syntax of &XSP1; are introduced, along with other terminology used throughout the specification.

Chapter 3 reconstructs the core functionality of XML 1.0, plus a number of extensions, in line with our stated requirements . This chapter discusses the declaration and use of datatypes, archetypes, element types, content models, attributes, attribute groups, model groups, refinement, entities and notations.

Chapter 4 presents , including the validation of namespace qualified instance documents, import, inclusion and export of declarations and definitions, schema paths, access to schemas, and related rules for schema-based validity.

Chapter 5 is a placeholder for , which will eventually provide a standardized means for including documentation in the definition of a schema.

Chapter 6 discusses , including the rules by which instance documents are validated, and responsibilities of schema-aware processors.

The normative addenda include a and a , which is an XML Schema schema for &XSP1;, a and . Non-normative appendixes include a and acknowledgments [].

Documentation Conventions

This Working Draft document was produced using an DTD and an stylesheet.

The following highlighting is used to present technical material in this document:

A term is something we use a lot.

Sample Abstract Syntax Production left right1 right2

A non-normative example illustrating use of the schema language, or a related instance.

<schema name='http://www.muzmo.com/XMLSchema/1.0/mySchema.xsd' >

And an explanation of the example.

The following highlighting is used for non-normative commentary in this document:

A recorded issue.

Notes shared among the editorial team.

General comments directed to all readers.

Purpose

The purpose of &XSP1; is to provide an inventory of XML markup constructs with which to write schemas.

The purpose of an &XSP1; schema is to define and describe a class of XML documents by using these constructs to constrain and document the meaning, usage and relationships of their constituent parts: datatypes, elements and their content, attributes and their values, entities and their contents and notations. Schema constructs may also provide for the specification of implicit information such as default values. Schemas are intended to document their own meaning, usage, and function through a common documentation vocabulary.

Thus, &XSP1; 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 &XSP1; formalism to express syntactic, structural and value constraints applicable to its document instances. The &XSP1; formalism will allow a useful level of constraint checking to be described and validated for a wide spectrum of XML applications.

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.

Relationship To Other Work

The definition of &XSP1; is a part of the W3C XML Activity. It is in various ways related to other ongoing parts of that Activity and other W3C WGs

&XSP1; has a dependency on the data typing mechanisms defined in its companion , published simultaneously with this recommendation.

&XSP1; has not yet identified requirements or dependencies.

&XSP1; has a requirement to support modularization of HTML.

See http://www.w3.org/XML/Group/1999/03/xml-schema-i18n-notes

&XSP1; has not yet documented requirements or dependencies.

&XSP1; has a requirement to support accessibility.

&XSP1; has significant dependencies on .

&XSP1; defines its own Information Set Contributions.

&XSP1; will have requirements for subsequent Information Set Working Drafts .

&XSP1; has not yet identified requirements or dependencies.

&XSP1; must interoperate with XML 1.0 and subsequent revisions.

&XSP1; has a requirement to support dimensions and aggregate datatypes.

Terminology

The terminology used to describe &XSP1; is defined in the body of this specification. The terms defined in the following list are used in building those definitions and in describing the actions of &XSP1; processors:

Conforming documents and processors are permitted to but need not behave as described.

Conforming documents and processors are required to behave as described; otherwise they are in error.

A violation of the rules of this specification; results are undefined. Conforming software may detect and report an error and may recover from it.

An error which a conforming processor must detect and report to the application.

(Of strings or names:) Two strings or names being compared must be character for character the same.

(Of URIs or schemaNames:) identical, according to the rules for identity in .

Conceptual Framework

This specification uses a number of terms that are common to many of the fields of endeavor that have influenced the development of XML Schema. Unfortunately, it is often the case that these terms do not have the same definitions in all of those fields. This section attempts to provide definitions of terms as they are used to describe the conceptual framework, and the remainder of the specification.

Kinds of XML Documents

Since XML schemas are themselves specified as XML documents, it is useful to clarify the relationships between certain kinds of XML documents:

An XML document whose structure conforms to some schema. See for the means by which an instance identifies the schema(s) to which it conforms.

A set of rules for constraining the structure and articulating the information set of XML documents.

An XML document that defines a schema. See for the means by which schema definition documents are accessed during processing. The term "Schema Definition" may also be abbreviated to "schema" where no confusion is likely.

Note that it is possible to specify a schema definition to which schema definitions themselves must conform, and this is given in . An XML 1.0 DTD to which schema definitions must conform is also provided in .

Any schema definition is therefore also an instance. The editors will make an attempt to always use the most precise of these terms, but the reader should note that rules specified herein for instances do apply to all of the following kinds of XML document:

Documents that are not schema definitions;

Schema definitions applicable to documents that are not schema definitions;

The schema definition applicable to schema definitions.

Likewise, rules for schemas do apply to the schema definition for schema definitions, which is an instance of itself.

On schemas, constraints and contributions

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

Three kinds of normative statements about the impact of &XSP1; components on instances are distinguished in this specification:

Constraints on the form and content of schemas themselves, above and beyond those expressed in ;

Constraints on the form of instances which they must satisfy to be schema-valid;

Augmentations to the information sets of instances which follow as a consequence of schema-validation.

Schema Information Set Contributions are not as new as might at first appear: XML 1.0 validation augments the XML 1.0 information set in similar ways, e.g. by providing values for attributes not present in instances, and by implicitly exploiting type information for normalization or access, e.g. consider the effect of NMTOKENS on attribute whitespace, and the semantics of ID and IDREF. By including Schema Information Set Contributions, we are trying to make explicit something XML 1.0 left implicit.

&XSP1; not only reconstructs the DTD constraints of XML 1.0 using XML instance syntax, it also adds the ability to define new kinds of constraints. For example, although the author of an XML 1.0 DTD may declare an element type as containing character data, elements, or mixed content, there is no mechanism with which to constrain the contents of elements to only character data of a particular form, such as only integers in a specified range.

This specification supports the expression of just such constraints by including in the mechanism for the declaration of element types the option of specifying that its contents must consist of a valid string expression of a particular datatype. A number of other mechanisms are added which improve the expressive power, usability and maintainability of schemas as a means to defining the structure of XML documents.

On 'types'

The use of the word 'type' has caused confusion in earlier discussions of schema technologies. Here, the word is used in several different contexts for a constraint on the form of (parts of) an element or attribute in an instance document. So, there are types that are suitable for constraining individual attributes, others that apply to entire elements (of which attributes may be a part), and so on. We use the words 'define' and 'definition' when speaking of types, and the words 'declare' and 'declaration' when specifying for an attribute or element type the type which constrains its form in instance documents.

Schemas and their component parts

The next chapter sets out the &XSP1; approach to schemas and formal definitions of their component parts. Here we informally summarize the key constructs used in defining schemas. An asterisk (*) in the 'Named?' column indicates that the name will appear in instances -- other names are for schema use only.

&XSP1; Feature Purpose Named?
A wrapper containing all the definitions and declarations comprising a schema document. Yes
A type (content constraint), such as 'integer', that applies to character data in an instance document, whether it appears as an attribute value or the contents of an element. The mechanisms for defining datatypes are set out elsewhere, in &XSP2;. Yes
A complete set of constraints for elements in instance documents, applying to both contents and attributes. Yes
An association between a name for an element and an archetype. An element type declaration for 'A' is comparable to a DTD declaration <!ELEMENT A .....>. Yes* (local or global)
An association between a a name for an attribute and a datatype, together with occurrence constraints such as 'required' or 'default'. The association is local to its surrounding archetype. Yes* (local)
Content type Either a datatype or a content model. A content type applies to the contents of elements in an instance document (but not their attribute values). It provides a unifying abstraction for the constraints which apply to the contents of elements, but introduces no additional features. No
A type (content constraint) that applies to the contents of elements in an instance document. Content models do not include attribute declarations. No
Components for constructing content models which allow only element content. Includes facilities for grouping, sequencing, as well as for declaration of and reference to element types. No (but see below)
An association between a name and a reusable collection of attribute declarations. Yes
Model groups are part of the content model building block abstraction, but are unnamed and cannot be referenced for reuse. A named model group is an association between a name and a model group, allowing for reuse. Yes
One archetype may be defined as refining one or more other archetypes, acquiring content type and/or attributes therefrom. Yes
Extends the current schema with definitions and/or declarations from an external schema, retaining the association with the original schema. No
Integrates definitions and/or declarations from an external schema into the schema being defined, as if they had been defined locally. No
Names and Symbol Spaces

As indicated in the third column of the tables above, most of the components listed are given names, which provide for references within the schema, and sometimes from one schema to another. For example, an attribute definition can refer to a named datatype, such as 'integer'. A content model can refer to an element type, and so on.

If all such names were assigned from the same 'pool', then it would be impossible to have e.g. a datatype named 'integer' and an element type with the name 'integer' in the same schema. Accordingly we introduce the idea of a symbol space (avoiding 'name space' to avoid confusion with 'Namespaces in XML' ).

There is a single distinct symbol space within a given schema for each of the abstractions named above other than 'Attribute' and 'Element type': within a given symbol space, names are unique, but the same name may appear in more than one symbol space without conflict. In particular note that the same name can refer to both an archetype and an element type, without conflict or necessary relation between the two.

Attributes and local element type declarations are special, in that every archetype defines its own attribute and local element type symbol spaces.

Abstract and Concrete Syntax

&XSP1; is presented here primarily in the form of an abstract syntax, which provides a formal specification of the information provided for each declaration and definition in the schema language. The abstract syntax is presented using a simplified BNF. Defined terms are to the left. Their components are to the right, with a small amount of meta-syntax: ()s for grouping, | to separate alternatives, ? for optionality, * and + for iteration. Terms in italics are primitives, not expanded here, either because they are defined elsewhere (e.g. URI, defined by ) or because they can only be grounded once a concrete syntax is decided on (e.g. choice).

An abstract syntax production prefixed with a number in brackets (e.g. [3]) is normative; other abstract syntax is either for purposes of explanation, or is a duplicate (for convenience) of a normative definition to be found elsewhere.

The abstract syntax illustrates the expressive power of the language, and the relationships among its component parts. The abstract syntax can be used to evaluate the expressive power of &XSP1;, but not its look and feel. In particular, please note that neither ordering within or between productions or choice of names is significant, and that any particular concrete syntax is not constrained by these.

The concrete syntax of &XSP1;, the exact element and attribute names used in a schema, are a key feature of its proposed design. The concrete syntax is the form in which the schema language is used by schema authors. Though its elements and attributes are often different from the terms of the abstract syntax bnf, the features and expressive power of the two are congruent. The concrete syntax profoundly affects the convenience and usability of the schema language.

We include a preliminary concrete syntax in this draft, via examples and in and . The emphasis in this version has been to stay quite close to the abstract syntax.

Schema Definitions and Declarations

The principal purpose of &XSP1; is to provide a means for defining schemas that constrain the contents of instance documents and augment the information sets thereof.

The Schema

A schema contains some preamble information and a set of definitions and declarations.

Schema top level schema preamble dds* dds datatypeDefn | archetypeDefn | elementTypeDecl | attrGroupDefn | modelGroupDefn | notationDecl | entityDecl preamble xmlSchemaRef schemaIdentity schemaVersion model export? import? include? xmlSchemaRef URI schemaIdentity URI schemaVersion string-value model open | refinable | closed

preamble consists of an xmlSchemaRef specifying the URI for &XSP1;; the schemaIdentity specifying the URI by which this schema is to be identified; and a schemaVersion specification for private version documentation purposes and version management.

<!DOCTYPE schema PUBLIC '-//W3C//DTD XML Schema Version 1.0//EN' SYSTEM '&XSP1.URI;.dtd' > <schema name='file:/usr/schemas/xmlschema/mySchema.xsd' version='M.n' xmlns='&XSP1.URI;.xsd'> ... </schema>

Note that the abstract syntax xmlSchemaRef is realised via a default namespace declaration in the concrete syntax.

The schema's model property is discussed in . The schema's export, import and include properties are discussed in .

The schema's declarations and definitions, discussed in detail in , provide for the creation of new schema components:

Summary of Definitions and Declarations datatypeDefn NCName datatypeSpec archetypeDefn NCName archetypeSpec elementTypeDecl NCName elementTypeSpec modelGroupDefn NCName modelGroupSpec attrGroupDefn NCName attrGroupSpec entityDecl NCName entitySpec notationDecl NCName notationSpec

The following illustrates the basic model for declaring all &XSP1; components:

<datatype name='myDatatype'> ... </datatype> <archetype name='myArchetype'> ... </archetype> <elementType name='myElementType'> ... </elementType> <attrGroup name='myAttrGroup'> ... </attrGroup> <modelGroup name='myModelGroup'> ... </modelGroup> <notation name='myNotation' ... /> <textEntity name='myTextEntity'> ... </textEntity> <externalEntity name='myExternalEntity' ... /> <unparsedEntity name='myUnparsedEntity' ... /> </schema>

When creating a new component, we declare that its name is associated with the specification for that component. Each new component definition creates a new entry in the symbol space for that kind of component.

Unique Definition

The same NCName must not appear in two definitions or declarations of the same type.

This draft does not deal with the requirement "for addressing the evolution of schemata" (see ).

The Document and its Root

We have not so far seen any need to reconstruct the XML 1.0 notion of root. For the connection from document instances to schemas, see .

References to Schema Constructs

Uniform means are provided for reference to a broad variety of schema constructs, both within a single schema and to features imported () from external schemas. The name used to reference any component of &XSP1; from within a schema consists of an NCName and an optional schemaRef, a reference to an external schema definition. In a few cases, some qualification may be added to a reference: this is made clear as the individual reference forms are introduced below.

Example: Component Names and References schemaRef (schemaAbbrev | schemaName) schemaAbbrev NCName schemaName URI datatypeRef datatypeName datatypeQual datatypeName NCName schemaRef? archetypeRef archetypeName archetypeName NCName schemaRef? elementTypeRef elementTypeName elementTypeName NCName schemaRef? attrGroupRef attrGroupName attrGroupQual attrGroupName NCName schemaRef? modelGroupRef modelGroupName modelGroupName NCName schemaRef? entityRef entityName entityName NCName schemaRef? notationRef notationName notationName NCName schemaRef?

The BNF above illustrates the reference mechanisms used in this specification.

<archetypeRef name='Address'/> <elementTypeRef name='BLOCKQUOTE' schemaAbbrev='HTML'/> <datatypeRef name='quantityi' schemaName='http://www.w3.org/xsl.xsd'/>

The first of these is a local reference, the other two refer to schemas elsewhere. The elementTypeRef example assumes the schemaAbbrev HTML has been declared for import; the datatypeRef example similarly assumes that the given (imaginary as of this writing) URL has been declared for import. See for a discussion of importing.

Consistent Import

A schemaAbbrev or schemaName in a schemaRef must be declared in an of the current schema, and the NCName qualified by that schemaRef must be an import () of the appropriate type per that declaration.

One Reference Only

The concrete syntax uses schemaAbbrev and schemaName attributes to realise schemaName. It is an error for both these attributes to appear on the same element in a schema.

A ...Ref identifies a ...Spec provided there is a definition or declaration of that ...Spec in the appropriate schema whose NCName matches the NCName of the ...Ref's ...Name. If there is no schemaRef in the ...Name, the appropriate schema is the current schema or a schema it eventually includes; if there is a schemaRef, the URI contained in or abbreviated by it must resolve successfully to a schema, which is then the appropriate schema. The Constraint on Schemas may also obtain.

Types, Elements and Attributes

Like XML 1.0 DTDs, &XSP1; provides facilities for constraining the contents of elements and the values of attributes, and for augmenting the information set of instances, e.g. with defaulted values and type information. We refer hereafter to the combination of schema constraints and information set contributions with the abbreviation SC. Compared to DTDs, &XSP1; provides for a richer set of SCs, and improved capabilities for sharing SCs across sets of elements and attributes.

Datatype Definition

We start with the simple datatypes whose expression in XML documents consists entirely of character data. As in the current draft of &XSP2;, wherever we speak of datatypes in this draft, we shall mean these simple datatypes. The treatment of aggregate datatypes (collections and structures) has not yet been resolved.

Datatypes datatypeDefn NCName datatypeSpec datatypeSpec [defined by XML Schemas: Datatypes] exportControl? datatypeQual specialize? valueConstraint? specialize facet+ facet is defined by XML Schemas: Datatypes. It might be a range restriction, min/max constraint, etc. valueConstraint default | fixed datatypeRef datatypeName datatypeQual datatypeName NCName schemaRef? schemaRef (schemaAbbrev | schemaName) schemaAbbrev NCName schemaName URI

&XSP1; incorporates the datatype definition mechanisms specified by in order to express SCs on attribute values and the character data contents of elements.

The first production above is for defining datatypes; datatypeSpec serves to indicate where this chapter connects with &XSP2;. exportControl is defined in .

The other productions provide for using datatypes once they have been defined, see below under contentType and attrDecl.

We assume that it is appropriate to allow for some local specialization of datatypes at the point of use, and provide for that here (specialize).

As explained in , a schemaRef, if included allows for the referenced definition to be located in some other schema.

<datatype name='myDatatype'> <basetype name="..."/> [ ... TBD] </datatype> <datatypeRef name='myDatatype'/> <datatypeRef name='integer'/> <datatypeRef name='quantity' schemaName='http://www.w3.org/xsl.xsd'> <fixed>12pt</fixed> </datatypeRef>

The first example awaits the &XSP2; concrete syntax to be filled in.

The first datatypeRef example references the definition above it. The second references a datatype pre-defined by &XSP2;. The third references a datatype in an (imaginary) XSL schema and fixes its value.

Avoid Built-ins

The NCName must not be the same as the name of any of the built-in datatypes (see ).

A string (possibly empty) dt-satisfies a datatypeSpec and an optional datatypeQual if

The string is a valid instance of the datatype defined by that datatypeSpec, as specialized by the datatypeQual's specialize (if present) (see for a definition of when a string is a valid instance of a (possibly specialized) datatypeSpec;

and

If there is a datatypeQual and it includes a fixed, the string matches that fixed value.

Datatype Info

When a string dt-satisfies a datatypeSpec and an optional datatypeQual, the containing attribute or element information item will be augmented to indicate the datatypeSpec and the specialize (if any) which it satisfied.

Timing constraints were such that this text may not align completely with &XSP2;

Archetype Definition

Archetype definitions gather together all SCs pertinent to elements in instance documents, their attributes and their contents. They are called archetypes because there may be more than one element type which shares the same SCs (see ), and which therefore can be constrained by a common archetype.

Archetypes archetypeDefn NCName archetypeSpec archetypeSpec refinement* contentType ( attrDecl | attrGroupRef )* model exportControl contentType datatypeRef | contentModel | modelGroupRef model open | refinable | closed archetypeRef archetypeName archetypeName NCName schemaRef?

The first three productions above provide the basic structure of the definition, the last two provide for reference to the things defined. But note that the name of an archetype is not ipso facto the name of elements whose appearance in instances will be associated with the SCs of that type. The connection between an element type name and an archetype is made by an elementTypeDecl, see below.

Alongside for permitted attributes, SCs for contents are defined in an archetype (contentType). For elements which may contain only character data, content type SCs are specified by reference to a . Note that doing this by way of datatypeRef means that the character data SCs may provide for specialization and even defaulting in a manner similar to attribute values. For other kinds of elements, a is required.

The extension of defaulting to element content is tentative.

<archetype name='myArchetype'> <datatypeRef name='myDatatype'/> <attrDecl ...>. . .</attrDecl> </archetype> A simple archetype with character data content constrained by reference to a datatype defined in the same schema and one attribute.

AttrGroup Unique

The same attrGroupDefn must not be referenced by two or more attrGroupRefs in the same archetypeSpec.

AttrGroup Identified

Every attrGroupRef in a archetypeSpec must identify an attrGroupSpec.

The attribute declaration set of an archetypeSpec consists of all its effective attrDecls together with all the attrDecls contained in the attrGroupSpecs identified by any attrGroupRefs it contains.

The full name of an attrDecl in an attribute declaration set is its NCName plus its schemaName, i.e. if it appeared directly in the archetypeSpec, the empty string, if it was acquired by refinement or if it came from an attrGroupSpec, then the schemaName from the schemaRef which identified the relevant archetypeSpec or attrGroupSpec respectively, if any, otherwise the empty string.

Attribute Locally Unique

The same full name must not appear more than once in any archetypeSpec's attribute declaration set.

An element item a-satisfies an archetypeSpec if the element item's attribute items taken together as a set attrs-satisfy the archetypeSpec's attribute declaration set, and either

The archetypeSpec's contentType is a datatypeRef, the datatypeRef identifies a datatypeSpec, the element item contains only comment, processing instruction and character information items and the string formed by concatenating the characters of each of the character information item children, if any, or else the empty string, dt-satisfies that datatypeSpec as qualified by the datatypeRef's datatypeQual if any;

or

the contentType is a contentModel, and the sequence of character and element items contained by the element item model-satisfies its effective contentModel.

The above definitions do not provide for handling a default on an archetype's datatypeRef. Preferred solution: empty element items ipso facto satisfy datatypeRefs with defaults and are augmented with the default value. This would have the consequence that you cannot provide the empty string as the explicit value of an element item if it's governed by a datatypeRef with a default.

Archetype Info

When an element item a-satisfies a archetypeSpec, that element information item will be augmented to indicate the archetypeSpec which it satisfied.

Why is the separation of element type and archetype provided for? In certain XML instance documents, the same attribute and content SCs are appropriate for more than one named element. Consider the following instance fragment:

<ShippingAddress id='a32' saleable='yes'> <Street>1 Main Street</Street> <City>New York</City> <Zip NineDigit='FALSE'>12345</Zip> </ShippingAddress> <BillingAddress id='a29' saleable='no'> <Street>2 Rose Lane</Street> <City>Anytown</City> <Zip NineDigit='TRUE'>12345-6789</Zip> </BillingAddress>

This fragment contains two elements, ShippingAddress and BillingAddress, that have similar attributes and content. By defining a single appropriate archetype and declaring two element types which reference it, that commonality can be precisely expressed.

This draft does not provide any mechanism for applying any SCs to element items whose namespace does not nominate a schema. This may be addressed in a later draft: in the meantime a workaround is possible as follows:

Suppose we wish to use some Dublin Core terms in a schema, but all we know is the URI for the Dublin Core document. Perhaps we want to schema-validate <mybook><dc:creator xmlns:dc='...'>Rafael Sabattini</dc:creator></mybook> where mybook is already known to be covered by my schema. The workaround is to replace the real Dublin Core URI with a local URL for a tiny schema which simply defines creator, and references the real URI for documentation.

Attribute Declaration

Attribute declarations associate a name (which will appear as an attribute in start tags in instances) with SCs for the presence and value thereof.

Attributes attrDecl NCName datatypeRef? required exportControl datatypeRef datatypeName datatypeQual datatypeQual specialize? valueConstraint? valueConstraint default | fixed datatypeName NCName schemaRef? schemaRef (schemaAbbrev | schemaName)

Note that the datatypeRef productions are repeated here for easy reference.

Attribute declarations provide for:

Requiring instances to have attributes;

Constraining attribute values to express a datatype;

<attrDecl name='myAttribute'/> <attrDecl name='anotherAttribute'> <datatypeRef name='integer'> <default>42</default> </datatypeRef> </attrDecl> <attrDecl name='yetAnotherAttribute' required='true'> <datatypeRef name='integer'/> </attrDecl> <attrDecl name='stillAnotherAttribute'> <datatypeRef name='string'> <fixed>Hello world!</fixed> </datatypeRef> </attrDecl>

Four attributes are declared: one with no explicit SCs at all; two defined by reference to a built-in type, one with a default and one required to be present in instances; and one with a fixed value.

When attribute declarations are used in an archetype specification, each archetype provides its own symbol space for attribute names. E.g. an attribute named title within one archetype need not have the same datatypeRef as one declared within another archetype.

An attribute item attr-satisfies an attrDecl if

The attrDecl contains no datatypeRef and the attribute item's value string dt-satisfies the default datatypeSpec for attributes

or

the attrDecl's datatypeRef identifies a datatypeSpec and the attribute item's value string dt-satisfies that datatypeSpec as qualified by the datatypeRef's datatypeQual if any

where the attribute item's value consists of only character information items and by its "value string" is meant the string formed by concatenating the characters of each of those character information item children, if any, or else the empty string.

What is the default attribute datatypeSpec?

The attribute items of an element item attrs-satisfy an attribute declaration set if

1) for each attribute item either

1a) there is an attrDecl in the attribute declaration set whose full name consists of an NCName which matches the attribute item's name and either

1a1) the attribute item has no namespace and the attrDecl's full name has no schemaName

or

1a2) the attribute item's namespace and the attrDecl's full name's schemaName are identical

and the attribute item attr-satisfies the declaration

or

1b) the archetypeSpec being a-satisfied by the attribute item's parent element item is open

and

2) every attrDecl in the attribute declaration set which is required is used to attr-satisfy an attribute item in the context of (1a) above

Attribute Value Default

For every attrDecl in the attribute declaration set not used to attr-satisfy an attribute item in the context of (1a) above which has a datatypeRef which has a default, an attribute item with the default value is added to the parent element item.

We've got a problem with namespace declarations: they're not attributes at the infoset level, so they can appear without compromising validity, EXCEPT if there is a fixed or required declaration, and defaults should have the apparently desired effect.

Attribute Group Definition

&XSP1; can name a group of attributes so that they may be incorporated as a whole into archetype definitions:

Attribute groups attrGroupDefn NCName attrGroupSpec attrGroupSpec attrDecl* exportControl attrGroupRef attrGroupName attrGroupQual attrGroupName NCName schemaRef? attrGroupQual attrDecl

Attribute group definitions:

provide a construct to replace some uses of parameter entities.

allow for the definition of SCs that relate values of one attribute to others within the group.

<attrGroup name='myAttrGroup'> <attrDecl .../> ... </attrGroup> <archetype name='myElementType'> <empty/> <attrGroupRef name='myAttrGroup'/> </archetype>

Define and refer to an attribute group. The effect is as if the attribute declarations in the group were present in the archetype definition.

There needs to be a Constraint on Schema which constrains the attrDecls which appear with an attrGroupRef: the name is the same as one of the attrDecls in the group, datatype and defaulting preserves substitutability, etc.

Element Content Model

When content of elements is not constrained by reference to a datatype (), it can have any, empty, element-only or mixed content. In the latter cases, the form of the content is specified in more detail.

Content model contentModel any | empty | mixed | eltOnly

A content model constrains the content of an archetype or an element type: it says nothing about attributes.

<any/> <empty/> <mixed>...</mixed> [Element only content -- see element-only below]

Content models do not have names, but appear as a part of the definition of an archetype, which does have a name. Model groups can be named and used by name, see below.

A sequence of character and element items (call this CESeq) model-satisfies an effective contentModel if

the sequence is empty and the effective contentModel is empty;

the effective contentModel is any and every element item in CESeq is independently valid, and for every element item in CESeq such that the schema which its namespace item resolves to is not the current schema there is an import whose schemaName is identical to that element item's namespace item's URI and that import must either be allElementTypes or contain an elementTypeRef whose NCName matches that element item's name;

the effective contentModel is mixed and every element item in CESeq mixed-satisfies the effective mixed

or

the effective contentModel is eltOnly and the only character items in CESeq are whitespace character items and the sub-sequence of CESeq consisting of all the element items therein eo-satisfies the effective eltOnly.

Mixed Content

A content model for mixed content provides for mixing elements with character data in document instances. The allowed element types are named, but neither their order or their number of occurrences are constrainted.

Mixed content mixed ( elementTypeRef | elementTypeDecl )*

The elementTypeRefs and elementTypeDecls determine the element types which may appear as children along with character data.

<mixed> <elementTypeRef name='name1'/> <elementTypeRef name='name2'/> <elementTypeRef name='name3'/> </mixed>

Allows character data mixed with any number of name1, name2 and name3 elements.

The fact that mixed allows for there to be no elementTypeRefs or elementTypeDecls makes it similar to XML 1.0's Mixed production. Indeed an empty mixed is the only way a schema can allow character data content with no datatype constraint at all.

Element Type Unique in Mixed

A given NCName must not appear two or more times among the elementTypeDecls and elementTypeRefs with no schemaRefs; a given elementTypeName must not appear two or more times among the elementTypeRefs.

See for discussion and examples of the appearance of elementTypeDecl above.

An element item mixed-satisfies a mixed if

the mixed contains an elementTypeRef which the element item ref-satisfies

or

the mixed contains an elementTypeDecl whose NCName matches the element item's name, in which case the element item must e-satisfy that elementTypeDecl

or

the archetypeSpec which effectively contains the mixed is open and the element item is independently valid.

There's an implicit change in current schema in the definition of satisfy-mixed above which should be made explicit.

Element-Only Content

A content model for element-only content specifies only child elements (no immediate character data content other than white space is allowed). The content model consists of a simple grammar governing the allowed types of child elements and the order in which they must appear.

Element-only content eltOnly modelElt modelElt occur ( modelGroup | modelGroupRef | elementTypeRef | elementTypeDecl ) occur min max? modelGroup compositor modelElt modelEltSeq compositor sequence | choice | all modelEltSeq modelElt modelEltSeq?

The grammar for element-only content is built on model elements and model groups (modelElt and modelGroup above). A model element provides for some number of occurrences in an instance of either a single element (via elementTypeRef or elementTypeDecl) or a group of elements (via modelGroup or modelGroupRef). A model group is two or more model elements plus a compositor.

A compositor for a model group specifies for a given group whether it is a sequence of its model elements, a choice between its model elements or a set of its model elements which must appear in instances. These options reconstruct the XML 1.0 , connector, the XML 1.0 | connector and the SGML & connector respectively. In the first case (sequence) all the model elements must appear in the order given in the group; in the second case (choice), exactly one of the model elements must appear in the element content; and in the third case (all), all the model elements must appear in the element content, but may appear in any order.

The occur specification governs how many times the instance material allowed by a modelElt may occur at that point in the grammar. The absence of a max specification means that no upper bound is placed on the number of occurrences.

See for further discussion and examples of the appearance of elementTypeDecl within modelElt above.

<elementTypeRef name='paragraph'/> <sequence> <elementTypeRef name='name1'/> <elementTypeRef name='name2' prefix='HTML'/> </sequence> <choice minOccur='3' maxOccur='9'> <elementTypeRef name='name1'/> <elementTypeRef name='name2'/> </choice> <all minOccur='3'> <elementTypeRef name='name1'/> <elementTypeRef name='name2'/> </all> <choice> <all> <elementTypeRef name='name1'/> <elementTypeRef name='name2'/> </all> <all> <elementTypeRef name='name3'/> <elementTypeRef name='name4'/> </all> </choice>

A minimal model which simply requires a paragraph (the default is minOccur=maxOccur=1; a sequence of two elements (one from another schema); between 3 and 9 elements, each a choice between two; at least three pairs, in any order; one of two pairs, the elements in the chosen pair in any order.

A sequence of element items eltOnly-satisfies an effective eltOnly if

it is possible to trace out a path through the content model, obeying the compositor and occur specifications and accepting each element item in the sequence with an elementTypeRef or elementTypeDecl in the content model. Accepting an element item from the sequence with an elementTypeRef requires that it ref-satisfy that elementTypeRef; accepting an element item with an elementTypeDecl requires that the elementTypeDecl's NCName matches the element item's name, in which case the element item must e-satisfy that elementTypeDecl.

The above definition of eltOnly-satisfy does not explicitly incorporate the modifications required when the containing archetype is open, as set out at the end of , but it should be understood as doing so.

Element Consistency

A given NCName must not appear both among the elementTypeDecls and among the elementTypeRefs with no schemaRefs, or more than once among the elementTypeDecls.

Note that the above permits repeated use of the same elementTypeRef, analogous to DTD usage.

Unambiguous Content Model

For compatibility, it is an error if a content model is such that there exist element item sequences within which some item can match more than one occurrence of an elementTypeRef or elementTypeDecl in the content model.

Should this compatibility constraint be preserved?

Named Model Group

This reconstructs another common use of parameter entities.

Named model groups modelGroupDefn NCName modelGroupSpec modelGroupSpec ( modelGroup | modelGroupRef ) exportControl modelGroupRef modelGroupName modelGroupName NCName schemaRef? <modelGroup name='myModelGroup'> <elementTypeRef name='myElementType'/> </modelGroup> <elementType name='myElementType'> <modelGroupRef name='myModelGroup'/> <attrDecl ...>. . .</attrDecl> </elementType> <elementType name='anotherElementType'> <choice> <elementTypeRef name='yetAnotherElementType'/> <modelGroupRef name='myModelGroup'/> </choice> <attrDecl ...>. . .</attrDecl> </elementType>

A minimal model group is defined and used by reference, first as the whole content model, then as one alternative in a choice.

Element Type Declaration

An element type declares the association of an element type name with an archetype, either by reference or by incorporation.

Element type declaration elementTypeDecl NCName elementTypeSpec elementTypeSpec ( archetypeRef | archetypeSpec ) exportControl global? elementTypeRef elementTypeName elementTypeName NCName schemaRef?

An element type declaration associates a name with an . This name will appear in tags in instance documents; the archetype definition provides SCs on the form of elements tagged with the specified name. An element type declaration is comparable to an <!ELEMENT ...> declaration in an XML 1.0 DTD.

The last two productions above provide for element types to be referenced by name from content models.

As noted above element type names are in a separate symbol space from the symbol space for the names of archetypes, so there can (but need not be) an archetype with the same name as a top-level element type.

The full name of a top-level elementTypeDecl is its NCName plus its schemaName, i.e. if it appeared directly in the current schema or an include, the empty string, if it was imported, then the schemaName of that import, which must successfully resolved to its containing schema.

An elementTypeDecl may also appear within a modelElt. See above ( and ) for where this is allowed. This declares a locally-scoped association between an element type name and an archetype. As with attribute names, locally-scoped element type names reside in symbol spaces local to the archetype that defines them. Note however that archetype names are always top-level names within a schema, even when associated with locally-scoped element type names.

It is not yet clear whether an archetype defined implicitly by the appearance of an archetypeSpec directly within an elementTypeSpec will have an implicit name, or if so what that name would be, or if not how, if at all, it might be referred to.

<elementType name='myElementType'> <datatypeRef name='myDatatype'/> </elementType> <elementType name='et0'> <archetypeRef name='myArchetype'/> </elementType> <elementType name='et1'> <all>. . .</all> <attrDecl ...>. . .</attrDecl> </elementType> <elementType name='et2'> <any/> </elementType> <elementType name='et3'> <empty/> <attrDecl ...>. . .</attrDecl> </elementType> <elementType name='et4'> <choice>. . .</choice> <attrDecl ...>. . .</attrDecl> </elementType> <elementType name='et5'> <sequence>. . .</sequence> <attrDecl ...>. . .</attrDecl> </elementType> <elementType name='et6' model='open'> <mixed/> </elementType>

A pretty complete set of alternatives. Note the last one is intended to be equivalent to the idea sometimes called WFXML, for Well-Formed XML: it allows any content at all, whether defined in the current schema or not, and any attributes.

<elementType name='contextOne'> <sequence> <elementType name='myLocalElementType' <archetypeRef name='myFirstArchetype'/> </elementType> <elementTypeRef name='globalElementType'/> </sequence> </elementType> <elementType name='contextTwo' <sequence> <elementType name='myLocalElementType' <archetypeRef name='mySecondArchetype'/> </elementType> <elementTypeRef name='globalElementType'/> </sequence> </elementType>

Instances of myLocalElementType within contextOne will be constrained by myFirstArchetype, while those within contextTwo will be constrained by mySecondArchetype.

The possibility that differing attribute definitions 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.

Nested May Not Be Global

An elementTypeSpec in a nested elementTypeDecl must not be global.

Cannot Shadow Global

If a top-level elementTypeSpec is global, then the NCName of its elementTypeDecl must not be redeclared by any nested elementTypeDecl in the same schema or any schema it eventually includes.

An element item e-satisfies an elementTypeDecl if the elementTypeDecl:

contains an archetypeSpec directly, and the element item arch-satisfies that archetypeSpec;

or

the archetypeRef alternative is used in that elementTypeDecl and it identifies an archetypeSpec and the element item a-satisfies that archetypeSpec.

An element item is independently valid if there is a top-level elementTypeDecl whose NCName matches its name in the schema its namespace item resolves to (or a schema that schema includes, in which case see the definition of identify for details on which declaration is used if there is more than one), and the element item must e-satisfy that elementTypeDecl.

An element item ref-satisfies an elementTypeRef if

the elementTypeRef identifies an elementTypeDecl whose NCName matches the element item's name and either

the elementTypeDecl's full name has no schemaName, in which case the element item's namespace must be the same as its parent's namespace

or

the element item's namespace and the elementTypeDecl's full name's schemaName are identical

in which case the element item must also e-satisfy the elementTypeDecl.

or

the elementTypeRef identifies an elementTypeDecl whose NCName matches the element item's name (call this ETD1 and there is a top-level elementTypeDecl (call this ETD2) which contains or identifies an archetypeSpec which has an ancestor which is itself identified by ETD1, in which case EDT1 must be e-satisfied by the element item.

The last clause above is much too complex, it needs to be split apart and built up in stages. It is this which allows elements based on refining archetypes to appear in place of those based on their ancestors.

Archetype Refinement

This section articulates what has only been hinted at above, namely a considerable increase in the power and expressiveness of schema declarations, by explaining what was provided for in the abstract syntax in the previous section, but not explained much if at all at that point.

We provide for the refinement of archetypes declared in a schema. An archetype definition may identify one or more other archetypes from which it specifies the creation of a (joint) refinement.

We provide for interpreting archetypes as imposing constraints on instance elements in either a closed, refinable or open fashion.

The closed interpretation is as per XML 1.0, where content type and attribute declarations specify all and only what must be present in instances.

The open interpretation removes the 'and only', i.e. it interprets the content type and attribute declarations as requiring (non-optional) items to be present, but not as excluding others.

The refinable interpretation requires the declared (non-optional) items to be present, and also admits such others as have been explicitly declared in refinements.

The relevant abstract syntax productions are as follows:

Refinement preamble xmlSchemaRef schemaName schemaVersion model export? import? include? archetypeSpec refinement* contentType ( attrDecl | attrGroupRef )* model exportControl model open | refinable | closed refinement archetypeRef <archetype name='chair' model='refinable'> <refines> <archetypeRef name='furniture'/> </refines> <attrDecl name='noOfSeats'>. . .</attrDecl> </archetype>

An archetype which not only refines another by adding an attribute, but also is itself (further) refinable. The furniture archetype must have been declared refinable(or open).

We distinguish between explicit, acquired and effective validation constraints for any archetype. Explicit constraints are those explicitly present, via attrDecls or contentType, in the definition of the archetype. Acquired constraints come from the ancestors of an archetype, if it has any refinements. The effective constraints are the union of the explicit and the acquired. The effective constraints are what actually constrain any element type declared with reference to a refining archetype.

Allowed Refinements

An archetype must not refine one or more other archetypes unless all of the latter have been declared with either open or refinable (explicitly or by default: the default for model on any archetype which does not explicitly specify one is provided by the model of the schema itself, which in turn defaults to closed for compatibility). The same archetype must not be referenced more than once in the refinements list.

Should the default model be open, refinable or closed?

For the present, the permitted refinements and the resulting effective constraints are as follows:

For attribute declarations, any attribute name defined in the explicit constraints must not also be defined in any of the acquired constraints, and any attribute name defined in a constraint acquired from one ancestor must not also be defined in a constraint acquired from another, unless they both acquired it from a common ancestor.

The effective attribute declarations are defined by the simple set union of the explicit and the acquired attribute definitions.

For content models, either

all the explicit and acquired content models are vacuous in which case the effective model is vacuous;

or

all but one of the explicit and the acquired content models are vacuous, in which case that one becomes the effective model;

or

No element type is referenced by more than one of the explicit and acquired content models (unless two or more acquired models share modelElts acquired from a common ancestor, in which case such modelElts shall be ignored in all but the first for the purpose of constructing the effective model), in which case if the non-vacuous explicit and acquired models are all eltOnly the effective model is a sequence of all the non-vacuous acquired models, in the order in which they are specified in the refinements list, followed by the explicit model (if it is non-vacuous), or else if the non-vacuous explicit and acquired models are all mixed, the effective model is a mixed whose elementTypeRefs and elementTypeDecls are the union of the elementTypeRefs and elementTypeDecls of all the non-vacuous explicit and acquired models.

A refinable or open mixed content model is called vacuous if it has no declared elementTypeRefs or elementTypeDecls within it. This is because any archetype is substitutable for an archetype with a vacuous content model and no declared attributes.

An archetype AT1 is said to refine an archetype AT2 if and only if AT1 is declared to refine either AT2 or (recursively) some archetype that refines AT2. AT2 is then said to be an ancestor of AT1.

Refinements are by definition substitutable for any of their ancestors.

We define a substitutability relation between two archetypes as follows:

One archetype is substitutable for another if any schema-valid instance of the former is necessarily a schema-valid instance of the latter.

Some simple cases:

Any archetype with no attributes is substitutable for an archetype with no attributes and a contentModel of any;

Any archetype which differs from another only by the specialization of one or more of its attributes (and/or of its datatype if its content is character data) is substitutable for that archetype;

Any archetype which differs from another only by allowing only character data content (i.e. whose contentType is datatypeRef) where the other has mixed content is substitutable for that archetype.

Refinement by definition creates substitutable archetypes:

<archetype name='Address' model='refinable'> <sequence> <elementTypeRef name='street'/> <elementTypeRef name='city'/> </sequence> </archetype> <archetype name='USAddress'> <refines> <archetypeRef name='Address'/> </refines> <sequence> <elementTypeRef name='state'/> <elementTypeRef name='zip'/> </sequence> </archetype>

USAddress is substitutable for Address: the effective content model (simplifying in the obviously legitmate way) is

<sequence> <elementTypeRef name='street'/> <elementTypeRef name='city'/> <elementTypeRef name='state'/> <elementTypeRef name='zip'/> </sequence>

Here is a richer example:

<archetype name='transclude' model='refinable'> <mixed/> <attrDecl name='xml:link'> <fixed>simple</fixed> </attrDecl> <attrDecl name='actuate'> <fixed>auto</fixed> </attrDecl> <attrDecl name='href' required='true'> <datatypeRef name='uri'/> </attrDecl> </archetype> <archetype name='anchor' interp='open'> <mixed/> <attrDecl name='id'> <datatypeRef name='ID'/> </attrDecl> </archetype> <archetype name='nestHere'> <refines> <archetypeRef name='transclude'/> <archetypeRef name='anchor'/> </refines> <empty/> <attrDecl name='show'> <fixed>embed</fixed> </attrDecl> </archetype> <elementType name='nestHere' archetype='nestHere'/> <nestHere href='http://www.ltg.ed.ac.uk/~ht/password.xml' id='mpw'/>

The final instance element satisfies all the effective constraints associated with the nestHere archetype: its xml:link, actuate and href attributes are constrained by constraints acquired from transclude, its id attribute is constrained by a constraint acquired from anchor and its show attribute is constrained by its own explicit constraint.

The effective content model for nestHere is empty, under the second clause of the discussion above: only the explicit content model is there at all, so it gets to be the effective one.

Note that because they are refinable and open respectively, both transclude and anchor are satisfied by the nestHere instance, i.e. the substitutability requirement on refining archetypes is satisfied.

Here's a case which merges content models and specializes an attribute definition:

<archetype name='polygon' model='refinable'> <elementTypeRef name='bbox'/> <attrDecl name='n' required='yes'/> <attrDecl name='regular'> <datatypeRef name='enumeratedSymbol'> <enumeration> <literal>yes</literal> <literal>no</literal> </enumeration> </datatypeRef> </attrDecl> </archetype> <elementType name='regularPolygon'> <refines> <archetypeRef name='polygon'/> </refines> <elementTypeRef name='side'/> <attrDecl name='regular'> <fixed>yes</fixed> </attrDecl> </elementType>

Here we see not only the merging of two content models, with the two elementTypeRefs being concatenated to produce the effective sequence model for the refined archetype, but also the provision in an explicit constraint of a fixed value for an attribute consistent with its acquired constraint. (Strictly speaking, this goes beyond the constraints on refinement set out above, but it obviously preserves substitutability, and will be allowed as soon as more detailed constraints are drafted.)

<regularPolygon n='3'> <bbox>...</bbox> <side length='3cm'/> </regularPolygon>

The intention of the formal validity definition ref-satisfies is that element item should be valid with respect to an archetypeSpec that is refinable if it is valid with respect to that archetypeSpec itself or any archetypeSpec that refines it. It might them be possible for validating parser to begin by checking daughters with respect to the declared archetypeSpec if it is element only, since any refinement can only add to the end of a sequence of daughters.

There follows a semi-formal definition of validity with respect to an open content model.

To parse against an open content model:

ignore all daughters which are NOT mentioned explicitly anywhere in the content model: what's left must match the model in the old, deterministic, XML 1.0 way.

Consider the edge-labelled FSM for recognizing the declared content model under a 'closed' (i.e. deterministic, XML 1.0) interpretation.

Call the set of all transition labels anywhere in the FSM (i.e. the tags mentioned anywhere anywhere in the model) T.

For each state s in the FSM, call the set of tags which label transitions from that state T[s].

Then to turn the FSM into one which interprets the content model as open, for each state s

add a transition to failure for every label in T-T[s];

add a transition to s for the complement of T, i.e. a default loopback.

Does refinement need this, or is it covered already?

Entities and Notations Entities and notations entityDecl NCName entitySpec entitySpec ( textEntitySpec | externalEntitySpec | unparsedEntitySpec ) exportControl? textEntitySpec string-value externalEntitySpec systemID publicID? exportControl? unparsedEntitySpec systemID notationRef publicID? exportControl? entityRef entityName entityName NCName schemaRef? notationDecl NCName notationSpec notationSpec systemID notationRef publicID? exportControl? systemID URI publicID see notationRef notationName notationName NCName schemaRef? Internal Parsed Entity Declaration

Internal parsed entities are a feature of XML that enables reuse of text fragments by direct reference in an instance document.

In &XSP1; documents, internal parsed entities are declared by using the textEntitySpec production.

<textEntity name='flavor'>Fresh mint</textEntity'>

flavor can now be used in an entity reference in instances of the containing schema.

See for SCs covering entities and entity references.

External Parsed Entity Declaration

External parsed entities are a feature of XML that offers a method for including well-formed XML document fragments, including text and markup, by direct reference to the storage object of the parsed entity.

In schemas, external parsed entities are declared by using the externalEntitySpec production.

<externalEntity name='FrontMatter' system='FrontMatter.xml' /> <externalEntity name='Chapter1' system='chapter1.xml' /> <externalEntity name='Chapter2' system='Chapter2.xml' /> <externalEntity name='BackMatter' system='BackMatter.xml' />

These four external entities represent the supposed contents of a book:

<book> &FrontMatter; &Chapter1; &Chapter2; &BackMatter; </book>

In an instance, the external entities take their familiar XML form. The processor expands the entities for their content.

Again, See for SCs covering entities and entity references.

Unparsed Entity Declaration

External unparsed entities are a feature of XML that offers a baroque method for including binary data by indirect reference to both the storage object and the the notation type of the unparsed entity. In schemas, external parsed entities may be declared by using the unparsedEntitySpec production.

<unparsedEntity name='SKU-5782-pic' system='http://www.vendor.com/SKU-5782.jpg' notation='JPEG' /> <picture location='SKU-5782-pic'/>

The picture element carries an attribute which is (presumably) governed by the unparsed entity declaration.

Attribute is Entity

When an attribute value is interpreted as a reference to an unparsed entity [How?!], the attribute value must identifies an unparsedEntitySpec (note that no schemaRef can be specified in this case); the NCName of the notationRef of that unparsedEntitySpec must identify a notationSpec; the resource specified by the systemID and publicID attribute must be available.

There are lots of gaps and little problems in this design for unparsed entities.

Notation Declaration

A notation may be declared by specifying a name and an identifier for the notation. A notation may be referenced by name in a schema as part of an external entity declaration.

<notation name='jpeg' public='image/jpeg' system='viewer.exe' /> <elementType name='picture> <attrDecl name='entity'> <datatypeRef name='NOTATION'/> </attrDecl> </elementtype> <picture entity='SKU-5782-pic'/>

The notation need not ever be mentioned in the instance document.

We need to synchronise with XML Schemas: Datatypes regarding how we declare attributes as unparsed entities!

Schema Composition and Namespaces

This chapter describes facilities to provide for validation of namespace-qualified instance document elements and attributes, and potentially (subject to enhancements to the Namespaces recommendation), entities and notations.

'Namespaces in XML' provides an enabling framework for modular composition of schemas. From that document:

We envision applications of Extensible Markup Language (XML) where a single XML document may contain elements and attributes (here referred to as a 'markup vocabulary') that are defined for and used by multiple software modules. One motivation for this is modularity; if such a markup vocabulary exists which is well-understood and for which there is useful software available, it is better to re-use this markup rather than re-invent it. Such documents, containing multiple markup vocabularies, pose problems of recognition and collision. Software modules need to be able to recognize the tags and attributes which they are designed to process, even in the face of 'collisions' occurring when markup intended for some other software package uses the same element type or attribute name. These considerations require that document constructs should have universal names, whose scope extends beyond their containing document. This specification describes a mechanism, XML Schema namespaces, which accomplishes this.

&XSP1; provides facilities to enable declaration and modular composition of schemas.

Each schema is identified by a schema name, which is a namespace-compatible .

A schema can identify archetypes, datatypes, element types, attribute definitions, attribute groups, named model groups, entities, and notations to be exported for use in other schemas.

A schema can import declarations and definitions exported from other schemas. Means are provided for using the imported features in the importing schema.

Namespace-compatible validation rules are defined for instance documents using imported elements and attributes.

Conventions are proposed for use of namespace-qualified entities and notations in instance documents. Standardized implementation of these features will depend on corresponding enhancements to the recommendation. (To be supplied in a future draft of this specification.)

As specified herein, namespace-qualified attribute definitions are validated only in the context of a corresponding validated elementType. A non-normative appendix proposes changes to the recommendation that would support more generalized export of attributes. (To be supplied in a future draft of this specification.)

As described in , full validation is supported in the case where the transitive closure of all schemas referenced by an instance document is available to the validating processor. Furthermore, the schema language is compatible with partial validation, in which validation is done only with respect to a subset of the schemas applicable to a document, or in which a well formed document (I.e. one for which no overall schema is provided) makes selective use of features imported from schemas which are available.

Associating Instance Document Constructs with Corresponding Schemata

During validation, the standard mechanisms of are interpreted to create associations between instance document prefixes and schema definitions. Thus, there is in each valid instance document a namespace associated with each schema to which the instance conforms. Each namespace qualified element (or eventually entity or notation), its attributes and its content, is validated against its declaration in the corresponding URI-named schema. In that sense, each schema defines and is coextensive with a namespace. The means by which schemas are located during processing is discussed below in . Comprehensive rules for validation are discussed in .

For example (refer to schema definitions in the previous example):

<SomeDocument xmlns='http://coolbits.com/someschema.xsd' xmlns:o='http://xyzcorp.com/otherschema.