W3C

XML Schema: Component Designators

W3C Working Draft 16 July 2004

This version:
http://www.w3.org/TR/2004/WD-xmlschema-ref-20040716/
Latest version:
http://www.w3.org/TR/xmlschema-ref/
Previous versions:
http://www.w3.org/TR/2004/WD-xmlschema-ref-20040309/ http://www.w3.org/TR/2003/WD-xmlschema-ref-20030109/
Editors:
Mary Holstege, Mark Logic, Inc.
Asir S. Vedamuthu, webMethods

This document is also available in these non-normative formats: XML.


Abstract

XML Schema: Component Designators defines a scheme for identifying XML Schema components as specified by XML Schema Part 1: Structures and XML Schema Part 2: Datatypes.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This is a W3C Working Draft of the XML Schema: Component Designators document for review by members and other interested parties. It has been produced by the W3C XML Schema Working Group (WG) as part of the XML Activity. It has been reviewed by the working group and the working group has agreed to publication. Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Comments on this document are welcome. Send them to www-xml-schema-comments@w3.org mailing list (archived at http://lists.w3.org/Archives/Public/www-xml-schema -comments/). Commenters are requested to put the string "[XSCD]" at the beginning of the subject field of email messages. Note that all outstanding issues against this document are documented in the Working Group running issues list.

The following changes were made since the last working draft:

This document was produced under the 5 February 2004 W3C Patent Policy. The Working Group maintains a public list of patent disclosures relevant to this document; that page also includes instructions for disclosing [and excluding] a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) with respect to this specification should disclose the information in accordance with section 6 of the W3C Patent Policy.

Table of Contents

1 Introduction (Non-Normative)
2 Goals and Use Cases (Non-Normative)
    2.1 Candidate Requirements
    2.2 Use Cases
3 Schema Component Designators
    3.1 Schema Component Designator Syntax
    3.2 Canonical Schema Component Designators
    3.3 Equality of Schema Component Designators
4 Schema Component Paths
    4.1 Schema Component Graph Traversal
    4.2 Schema Component Path Syntax
    4.3 Canonical Schema Component Paths
    4.4 Equality of Schema Component Paths
5 Conformance
    5.1 Schema Component Path Conformance
    5.2 Schema Component Designator Conformance
6 Example (Non-Normative)

Appendices

A Schema Component Properties (Non-Normative)
B Glossary (Non-Normative)
C References
    C.1 Normative References
    C.2 Non-normative Informational References


1 Introduction (Non-Normative)

This document defines a system for designating XML Schema components. Part 1 of the W3C XML Schema recommendation [XSD1] defines these schema components. Section 2.2 lays out the inventory of schema components into three classes:

In addition there is a master schema component, the schema component representing the schema as a whole.

Finally, there are schema components for the facets defined in Part 2 of the W3C XML Schema recommendation [XSD2]:

At first blush, a QName (prefix:localname) may seem sufficient to the task of designating any schema component. This is incorrect for various reasons:

  1. A QName is only meaningful in the context of particular namespace bindings so that the QName can be resolved to a particular extended name, or {namespace name, local name} pair.

  2. The same extended name can be used in a particular schema to refer to an element declaration, an attribute declaration, a complex type or simple type definition, a model group definition, an attribute group definition, an identity constraint definition, and a notation declaration.

  3. Locally scoped element and attribute declarations cannot be uniquely named by an extended name.

  4. Anonymous type definitions have no extended name, or they have an extended name that is dependent upon the particular schema processor interpreting the schema.

  5. Certain schema components (annotation, particle, wildcard) are purely subordinate to some other schema component, and have no name of their own.

  6. Certain schema components (attribute use and model group) are subordinate to some other schema component, and any name they might be construed to have is a reference to some other schema component (attribute declaration and model group definition, respectively).

  7. The schema-as-a-whole schema component has no name at all.

  8. The redefinition schema composition feature creates the situation where there are two variants of the 'same' schema component, both with the same name, one of which is derived from the other. If it is necessary to be able to name the base component, the same name cannot be used for both.

A key technical challenge to obtaining a useful system of naming XML Schema components is to address these issues or decide that certain cases need not be addressed. In particular:

  1. Designators must either include full extended names, or define namespace bindings.

  2. Designators must distinguish named components in different symbol spaces from one another.

  3. Designators must provide a means of distinguishing locally scoped element and attribute declarations with the same name.

  4. Designators must provide for any designatable unnamed components, such as anonymous type definitions, wildcards, and the schema-as-a-whole component.

  5. Designators must function in the face of redefinitions.

The schema-as-a-whole schema component may represent the amalgamation of several distinct schema documents, or none at all. It may be associated with any number of target namespaces, including none at all. It may have been obtained for a particular schema assessment episode by de-referencing URIs given in schemaLocation attributes, or by an association with the target namespace or by some other application-specific means. In short, there are substantial technical challenges to defining a reliable designator for the schema-as-a-whole, particularly if that designator is expected to serve as a starting point for the other components encompassed by that schema.

This specification divides the problem of constructing schema component designators into two parts: defining a designator for an assembled schema, and defining a designator for a particular schema component or schema components, understood relative to a designated schema.

2 Goals and Use Cases (Non-Normative)

2.1 Candidate Requirements

Basic Functionality
  1. Designators should be unambiguous, designating exactly one component within a schema. However, certain abbreviation and wildcarding constructs may designate collections of components. In any case, each component should have at least one unambiguous designator that designates that component and no other.

  2. It should be possible to designate any schema component within a schema. However, some exceptions will be made for certain of the helper components.

  3. Designators should provide (or assure) a URI for the unique identification of a schema.

  4. If there is more than one designator for a construct, there should be exactly one canonical form of the designator.

Properties of the Designator
  1. Designators should be human-readable.

  2. Given a designator, it should be possible to get the extended name for the designated component, if one exists for that component.

  3. It should be possible to algorithmically and consistently generate the canonical designator for each component, either against an assembled schema or as the schema is assembled.

  4. Designators should be parsable with compositional semantics (or, in other words, they should have expressive notation).

  5. There should be a formal specification of what constitutes a legal designator.

Compatibility
  1. Designators should be URI references.

  2. Designators should work well in a RDDL environment.

Non-goals
  1. It is not a requirement to designate particle components as distinct from terms.

  2. It is not a requirement to tie schema component validity to namespace validity.

  3. It is not a requirement that it be possible to construct designators to refer to arbitrary schema components without any knowledge of schema internals.

  4. It is not a requirement to be able to tell, from a schema component designator for an element declaration, whether instances of that element declaration must appear in document instances with qualified or unqualified names.

  5. It is not a requirement to uniquely assign schema component designators (element, attribute, and type designators) to information items in a document instance given only a set of schema component designators.

2.2 Use Cases

Type references

In general Schema Component Designators can be used to provide references to arbitrary types, whether they are named global types or local or anonymous types. These use cases all benefit from being able to refer to any type declaration.

  • Describing the type of an expression, where the type might be an anonymous or local type and a QName is therefore inadequate. There are a number of examples where this could be valuable:

    • Naming the type of something that has been selected, as in XQuery, XPath 2.0, or XSLT 2.0

    • For use wherever types are named, for example to specify a type in an XPath 2.0 or XQuery expression. e,g. element-of(type-t)

    • Enabling DOM3 to expose anonymous types

  • Identifying types for TREAT AS (in Query) specifically wrt anonymous and local types.

  • Identifying types for function signatures for XQuery, XSLT 2.0 and related specifications.

Element declaration references

These use cases benefit from being able to refer to any element declaration.

  • Naming an element declaration which is matched by an arbitrary expression. e.g. Given XPath /one/two/foo, naming that it only matches local element 'foo'.

Stand-off Schema Annotation

Schema component designators can be used to refer to specific parts of a schema to provide an out-of-band annotation capability, for commentary, error reporting, or the association of layered semantics with schema components.

  • Writing error messages. There are two classes of error messages in view: errors in an instance and errors in the schema. For example, if an instance has a quantity which violates the constraints of a particular type, such as a range constraint, it is valuable for the error message to be able to name and refer to the specific type whose constraints were violated, even if that is a local element with an anonymous types. An example of a schema error would be that one type is not a valid restriction of another type. This use case benefits from being able to name and refer to type, element, and attribute declarations, as well as element and attribute uses, groups, and possibly facets and particles. It is unclear whether being able to separately refer to particles versus groups is important. Being able to separately refer to attribute and element uses versus attribute and element declarations may be important.

  • Schema documentation. The transfer syntax for W3C XML Schema allows for documentation to be attached to components in-line. In many cases it may be preferable to keep the documentation separate from the active definitions, to save bandwidth, to provide for alternative documentation for different communities, and so on. Being able to refer to any schema component that can support an annotation (all but annotation itself) supports this use case.

  • Commentary on schemas, such as best practices documents, reviews and comparisons of particular schemas, and so on.

  • Associating an additional layer of semantics with schema components, for example, providing information to programming language or application environments to identify code to execute. For example, certain XML data binding frameworks today reference complex types and elements using their own path syntax for the purpose.

Miscellaneous text-based uses within schema-based tools

Having a simple textual way to refer to the abstract components of a schema enables certain kinds of text-based schema-related processing.

  • A tool that creates interlinked HTML pages describing a schema.

  • String-based tests of type equivalence. Such tests can be used for comparing serialized PSVIs to provide for interoperable tests of type equivalence and processor comparisons.

  • String-based comparisons of processors generally, making it possible, for example, to ask and answer the question "Did two validations of the same document on different machines use the same type for a given element?"

  • input/output

  • user reports

  • glue/interfaces among

Other
  • Simple selection queries, such as "the type that is the base type of X" without knowledge of its name.

  • Creation or initial drafting of a new schema or schema document by selecting components from existing schema.

  • RDF assertions about types, etc.

  • Formal description requires unique identifier for each declaration and definition component used within the context of the validation episode.

  • Enumerating dependencies among schema components. For example, where one complex type restricts another, the local elements in one depend on the local elements of the other.

3 Schema Component Designators

Schema component designators rely on a layered model of schema component reference. Schema component paths designate components in the context of a particular schema assembly. Full blown schema designators build on this by applying the schema component paths in the context of a URI reference, where the URI identifies the schema, and the fragment part encapsulates a schema component path to designate components in the context of that schema.

This section describes schema component designators as a whole. The details of schema component paths are described in 4 Schema Component Paths.

[Definition: A schema designator is a single URI for a resource representing an assembled schema.]

Many possible conventions for obtaining a single URI to refer to a schema are possible. In the simplest case, where there is one root schema document, the URI of that document suffices. In other cases a schema may have been assembled from multiple schema documents, or from components obtained via other representations, and some representation of that collection or of the assembled results will be required.

We expect that it will be highly desirable for the community to evolve one convention for referring to an assembled schema to ensure consistency of global schema component designators. This specification declines to specify what that one way should be.

Note:

The representation of a resource obtained by dereferencing a schema URI must allow for the fragment identifier syntax defined here. The representation of the resource either needs to be an XML encoding to fit with the XPointer framework, or its definition needs to explicitly entail a compatible fragment identifier syntax.

The schema component reference core defines reference to a schema component in the context of an assembled XML Schema. 4 Schema Component Paths defines this relationship between an assemblage of schema components and component paths. Schema assembly is described in Section 4 of XML Schema Part 1: Structures.

For the purposes of component paths, a missing component cannot be used to construct a valid path; nor can a schema component be successfully referenced through a path that references a missing component.

[Definition: An absolute schema component designator consists of two parts: a designator for the assembled schema (a schema designator), and a designator for a particular schema component or schema components relative (a relative schema component designator) to that assembled schema.]

Syntactically, the first part is a URI, and the second part is an XPointer fragment identifier. An absolute schema component designator therefore is a URI reference.

[Definition: The relative schema component designator is an XPointer scheme xscd() that uses a schema component path as the scheme data.] This XPointer scheme may be used in combination with the XPointer xmlns() scheme. It must not be used in combination with other XPointer schemes. The construction and syntax of schema component paths are described in 4 Schema Component Paths.

3.1 Schema Component Designator Syntax

EBNF
[1]   SchemaComponentDesignator   ::=   AbsoluteSchemaComponentDesignator | RelativeSchemaComponentDesignator
[2]   AbsoluteSchemaComponentDesignator   ::=   SchemaDesignator '#' RelativeSchemaComponentDesignator
[3]   SchemaDesignator   ::=   URI
[4]   RelativeSchemaComponentDesignator   ::=   XmlnsPointerPart* XscdPointerPart
[5]   XmlnsPointerPart   ::=    'xmlns' '(' XmlnsSchemeData ')'
[6]   XscdPointerPart   ::=   'xscd' '(' SchemaComponentPath ')'

3.2 Canonical Schema Component Designators

[Definition: A canonical schema component designator is an absolute schema component designator that is a URI that has been canonicalized according to the rules given in the update to RFC2396 and where the relative schema component designator consists of an xmlns XPointer pointer part (if required) followed by a canonicalized xscd XPointer pointer part. ]

[Definition: A canonicalized xscd XPointer pointer part is an xscd XPointer pointer part where the pointer data is a canonical schema component path. ]

3.3 Equality of Schema Component Designators

Many use cases for schema component designators call for them to be compared for equality. A simple string comparison cannot be used with this scheme because namespace prefixes may vary. However, comparison is still straightforward.

[Definition: Two schema component designators are equal if they are absolute and their URIs are equal or if they are relative to the same schema, and their schema component paths are equal.]

4 Schema Component Paths

An assembled schema forms a graph of schema components, where certain schema component properties contain other schema components as their values (or part of their values). Schema component paths can be regarded as being constructed step-by-step by traversing the schema component properties, starting at the schema-as-a-whole schema component. Within this graph there may be more than one path to a particular schema component. This section describes the general procedure for traversing the graph and constructing paths, and then defines which path is the canonical one.

For the purposes of schema component paths, presume the existence of an {identity constraint definitions} property of the schema-as-a-whole component whose value is the union of all identity constraint components in the assembled schema. Future revisions of the XML Schema specification may define this property.

[Definition: A schema component path is a series of [step] pieces, each of which corresponds to a particular schema component along the path from the schema-as-a-whole schema component.] Each step has a concrete syntactic representation, which is described in 4.2 Schema Component Path Syntax.

[Definition: A [step] represents a schema component along the path from the schema-as-a-whole schema component. Each [step] has a possibly empty [target namespace], a possibly empty [name], and possible empty [predicate], and a [schema component kind].] The values for these properties are defined for specific schema components, below, but in general the [target namespace] will have the same value as the {target namespace} property of the schema component and the [name] will have the value as the {name} property of the schema component. The value of [schema component kind] is a label for the kind of schema component involved. The [predicate] is used to select schema components that have no name to distinguish them or where the name does not suffice to distinguish them, such as instances of element declarations within a term.

4.1 Schema Component Graph Traversal

An assembled schema consists of a graph of schema components. The following schema component properties have as their values (or a part of their values) other schema components, thus creating the links in the graph which may be traversed to construct a schema component path.

Traversal through the schema component graph occurs through any of the properties by taking a member of one of these lists as the basis for the next [step]:

{type definitions}
{attribute declarations}
{element declarations}
{attribute group definitions}
{model group definitions}
{notation declarations}
{identity constraint definitions}
{facets}
{fundamental facets}
{member type definitions}
{attribute uses}
{particles}

Traversal through the schema component graph occurs through any of the following properties by taking that schema component as the basis for the next [step].

{type definition}
{item type definition}
{attribute wildcard}
{model group}
{attribute declaration}
{term}
{base type definition}
{primitive type definition}
{substitution group affiliation}
{referenced key}

Traversal through the schema component graph occurs to the following properties, but in a somewhat special way, as referring to a collection of annotations as a group, rather than to an individual annotation component. This is because we cannot distinguish between individual annotations.

{annotations}
{annotation}

Traversal through the schema component graph occurs through the following properties, but in different ways depending on what kind of value it has:

{content type}
{scope}

Traversal will proceed through the particle of the {content type} property if a content model is present, or through the {content type} property directly if it is a simple type definition. Traversal will proceed through the {scope} property unless it has the value "global".

4.2 Schema Component Path Syntax

In general the syntax of a step of the schema component path has the following form:

Syntax: [schema component kind]([ns-prefix:[name]])[[predicate]]

where ns-prefix is bound to [target namespace]. In the context of schema component designators the namespace prefixes will be bound via the xmlns XPointer scheme; in the context of an XML document the namespace prefixes will be bound in the conventional way (using the [in-scope namespaces] of the element information item); other host languages (such as XQuery) will define their own namespace binding rules.

The syntax provides various abbreviations as defined below.

Steps in the path are separated by a slash:

Syntax: /

except in the case of the schema-as-a-whole component, which is represented by a bare slash already, so no additional separator is necessary.

4.2.1 Schema-as-a-whole Component

The [step] for the schema-as-a-whole schema component has the properties:

[target namespace]
[name]
[schema component kind]schema
[predicate]
Syntax: /

4.2.2 Attribute Declaration

The [step] for an attribute declaration schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]attribute
[predicate]
Syntax: attribute(prefix:name) or @prefix:name

4.2.3 Element Declaration

The [step] for an element declaration schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]element
[predicate]None if the {scope} is global. Otherwise, the pair {position, n} where n is the position of the element declaration among other element declarations with the same {target namespace} and {name} property values among the {particles} in the superordinate model group.
Syntax: element(prefix:name)[n] or prefix:name[n] where the [n] will be absent if the {scope} of the element declaration is global and may be absent if the value of n is 1.

4.2.4 Simple Type Definition

The [step] for a simple type definition schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]simpleType
[predicate]If the superordinate component is a simple type schema component (call it S) and S's {variety} property is union, the pair {position, n} where n is the position of this simple type definition among S's {member type definitions}
Syntax: type(prefix:name)[n] where prefix:name will be empty for anonymous types. The [n] will be absent if the {variety} of the S is not union and may be absent if the value of n is 1.

4.2.5 Complex Type Definition

The [step] for a complex type definition schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]complexType
[predicate]
Syntax: type(prefix:name) where prefix:name will be empty for anonymous types.

4.2.6 Attribute Group Definition

The [step] for an attribute group definition schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]attributeGroup
[predicate]
Syntax: attributeGroup(prefix:name)

4.2.7 Model Group Definition

The [step] for a model group definition schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]group
[predicate]
Syntax: group(prefix:name)

4.2.8 Identity-constraint definition

The [step] for an identity-constraint definition schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]identityConstraint
[predicate]
Syntax: identityConstraint(prefix:name)

4.2.9 Notation declaration

The [step] for a notation declaration schema component has the properties:

[target namespace]Value of {target namespace}
[name]Value of {name}
[schema component kind]notation
[predicate]
Syntax: notation(prefix:name)

4.2.10 Annotations

Annotation components are referenced as a collection. If the [step] derives from an {annotations} property, the collection is the collection of all the annotations given in that property. If the [step] derives from an {annotation} property, the collection is the collection with just that annotation in it.

The [step] for an annotation schema component has the properties:

[target namespace]
[name]
[schema component kind]annotations
[predicate]
Syntax: annotations()

4.2.11 Model Group

The [step] for a model group schema component has the properties:

[target namespace]
[name]
[schema component kind]The value of the {compositor} property, one of sequence, choice, or all
[predicate]The pair {position, n} where n is the position of the model group with respect to other model groups among {particles} with the same {compositor} property value if this model group is one particle of a superordinate model group.
Syntax: sequence()[n] or choice()[n] or all()[n] where the [n] may be absent if the value of n is 1 (as it always is for the all compositor).

4.2.12 Particle

Particle schema components are skipped over in the traversal through the graph, do not contribute a step, and have no reflection in the path syntax.

4.2.13 Wildcard

The [step] for a wildcard schema component has the properties:

[target namespace]
[name]
[schema component kind]If the wildcard is the {term} of some particle, then any, otherwise anyAttribute
[predicate]If the [schema component kind] is any, the pair {position, n} where n is the position of the wildcard with respect to other wildcards among {particles} of the superordinate model group.
Syntax: any()[n] or anyAttribute() where the [n] may be absent if the value of n is 1.

4.2.14 Attribute Use

Attribute use schema components are skipped over in the traversal through the graph, do not contribute a step, and have no reflection in the path syntax.

4.2.15 Fundamental Facets

The [step] for a fundamental facet schema component has the properties:

[target namespace]
[name]The facet name, one of ordered, bounded, cardinality, or numeric
[schema component kind]facet
[predicate]
Syntax: facet(name)

4.2.16 Constraining Facets

The [step] for a constraining facet schema component has the properties:

[target namespace]
[name]The facet name, one of whiteSpace or minInclusive or maxInclusive or minExclusive or maxExclusive or totalDigits or fractionDigits or length or minLength or maxLength or pattern or enumeration
[schema component kind]facet
[predicate]
Syntax: facet(name)

4.2.17 Examples of Schema Component Paths (Non-Normative)

The following examples assume the namespace prefixes have been properly bound.

A schema component path referring to the type (either simple or complex) whose local name is title and which is in the namespace denoted by the prefix my:

/type(my:title)

A schema component path referring to the globally declared element whose local name is title and which is in the namespace denoted by the prefix my:

/element(my:title)

A schema component path referring to the globally declared attribute whose local name is title and which is in the namespace denoted by the prefix my:

/attribute(my:title)

A schema component path referring to the globally declared attribute group whose local name is title and which is in the namespace denoted by the prefix my:

/attributeGroup(my:title)

A schema component path referring to the pattern facet of the globally declared simple type whose local name is title which is in the namespace denoted by my:

/type(my:title)/facet(pattern)

Given this schema fragment for a schema whose target namespace is denoted by the prefix my:

<xs:complexType name="articleType">
   <xs:sequence>
      <xs:element ref="my:section"/>
      <xs:element name="appendix" type="my:sectionType"/>
   </xs:sequence>
</xs:complexType>

<xs:element name="chapter">
   <xs:complexType>
      <xs:sequence>
         <xs:element ref="my:title" minOccurs="0" maxOccurs="unbounded"/>
         <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string"/>
      <xs:anyAttribute namespace="##other" use="optional"/>
   </xs:complexType>
</xs:element>

The following schema component path refers to the first element of the named complex type:

/type(my:articleType)/sequence()/element(my:section)

And the following schema component path refers to the second:

/type(my:articleType)/sequence()/element(my:appendix)

A schema component path referring to the (anonymous) complex type of the globally defined element:

/element(my:chapter)/type()

A schema component path that refers to the wildcard in the globally defined element:

/element(my:chapter)/type()/sequence()/any()

A schema component path that refers to the attribute of the globally defined element:

/element(my:chapter)/type()/attribute(name)

4.2.18 Optional Intermediate Steps

An intermediate step is a [step] piece that is neither the first step nor the last step in a schema component path. There are intermediate steps that correspond to complex type, model group and other components.

The following three types of intermediate step sequences are optional in the schema component path syntax:

  1. An intermediate step that corresponds to a complex type component.
  2. A series of intermediate model group steps. This series begin and end with a model group step and contain all the consecutive model group steps. Where, model group step is a step that corresponds to model group component.
  3. A combination of the above two intermediate step sequences in that order.
4.2.18.1 Examples of Optional Intermediate Steps (Non-Normative)

/r:purchaseReport/type()/@period designates an attribute declaration whose local name is period in an anonymous complex type. Omitting its optional intermediate step sequence, this path reduces to /r:purchaseReport/@period.

/type(ipo:USAddress)/sequence()/sequence()[1]/name designates an attribute declaration whose local name is name in a globally defined type. Omitting its optional intermediate step sequence, this path reduces to /type(ipo:USAddress)/name.

/r:purchaseReport/type()/sequence()/r:regions designates an element declaration whose local name is regions in an anonymous complex type. Omitting its optional intermediate step sequence, this path reduces to /r:purchaseReport/r:regions

4.2.19 Abbreviations: // and *

// is an abbreviation for head steps or a sequence of intermediate steps in a schema component path. * is an abbreviation for any step in a schema component path.

An intermediate step is a [step] piece that is neither the first step nor the last step in a schema component path. Head steps are a series of steps in a schema component path, begin with the first step and end with any step that is not the last step in a schema component path.

4.2.19.1 Examples of Abbreviations in Schema Component Path (Non-Normative)

//quantity designates global or local element declarations whose local name is quantity.

/type(Items)//quantity designates global or local element declarations whose local name is quantity, and these declarations are in the sub graph represented by the global complex type component whose local name is Items.

/type(Items)//@partNum designates global or local attribute declarations whose local name is partNum and these declarations are in the sub graph represented by the global complex type component whose local name is Items.

/type(Items)/item/* designates schema components that are traversable as next steps in the sub graph represented by the element declaration whose schema component path is /type(Items)/item.

4.2.20 EBNF for Schema Component Path Syntax

Path EBNF
[7]   SchemaComponentPath   ::=   SchemaStep | StepSepator RelativeSchemaComponentPath
[8]   SchemaStep   ::=   '/'
[9]   RelativeSchemaComponentPath   ::=   Step | Step StepSeparator RelativeSchemaComponentPath
[10]   StepSeparator   ::=   '/' | '//'
[11]   Step   ::=   AttributeStep | ElementStep | SimpleTypeStep | ComplexTypeStep | AttributeGroupStep | GroupStep | IdentityConstraintStep | NotationStep | AnnotationsStep | ModelGroupStep | WildcardStep | FacetStep | AbbreviatedStep
[12]   AbbreviatedStep   ::=   '*'
[13]   AttributeStep   ::=   AttributeFullform | AttributeShortform
[14]   AttributeFullform   ::=   'attribute' '(' QName ')'
[15]   AttributeShortform   ::=   '@' QName
[16]   ElementStep   ::=    ( ElementFullform | ElementShortform ) Predicate?
[17]   ElementFullform   ::=   'element' '(' QName ')'
[18]   ElementShortform   ::=   QName
[19]   SimpleTypeStep   ::=   'type' '(' QName? ')' Predicate?
[20]   ComplexTypeStep   ::=   'type' '(' QName? ')'
[21]   AttributeGroupStep   ::=   'attributeGroup' '(' QName ')'
[22]   GroupStep   ::=   'group' '(' QName ')'
[23]   IdentityConstraintStep   ::=   'identityConstraint' '(' QName ')'
[24]   NotationStep   ::=   'notation' '(' QName ')'
[25]   AnnotationsStep   ::=   'annotations' '(' ')'
[26]   ModelGroupStep   ::=   ('sequence' | 'choice' | 'all') '(' ')' Predicate?
[27]   WildcardStep   ::=    ( 'any' '(' ')' Predicate? ) | ('anyAttribute' '(' ')')
[28]   FacetStep   ::=   'facet' '(' FacetName ')'
[29]   FacetName   ::=   'ordered' | 'bounded' | 'numeric' | 'cardinality' | 'whiteSpace' | 'minInclusive' | 'maxInclusive' | 'minExclusive' | 'maxExclusive' | 'totalDigits' | 'fractionDigits' | 'length' | 'minLength' | 'maxLength' | 'pattern' | 'enumeration'
[30]   Predicate   ::=   '[' [0-9]+ ']'

Editorial note21-Jun2-2004
Do we want to allow things like type(*) and element(*)?

4.3 Canonical Schema Component Paths

[Definition: The canonical schema component path of a component is a distinguished valid component path that uniquely identifies that particular component, that has as few steps as possible, and that can be deterministically constructed. ]

The remainder of this section consists of a constructive definition of canonical schema component paths: a path produced by this construction will be the canonical one.

[Definition: The current schema component is a schema component for which there is a valid canonical path through the schema component graph.]

[Definition: The target schema component is a schema component linked to the current schema component via one of the schema component properties defined previously.]

[Definition: The component relationship is the name of the schema component property on the current schema component which references the target schema component. ]

[Definition: The ancestor set of the target schema component is the set of schema components on the valid canonical path to the current schema component together with the current schema component.]

[Definition: The base type set of a schema component is the set consisting of the {base type definition} of that schema component and the {base type definition} of every member of the set. ]

Constructively, this set can be computed by adding the {base type definition} to the set, and iterating on that type component, until you see a component whose {target namespace} property is "http://www.w3.org/2001/XMLSchema" and whose {name} property is "anyType".

[Definition: The extended base type set of a schema component is the set consisting of the {base type definition} of that schema component if its {derivation} method is "extension" and the {base type definition} of every member of the set whose {derivation} method is "extension". ]

[Definition: The base facet set of a schema component is the set consisting of all members of the {facets} property of members of the base type set of that schema component.]

[Definition: Two facets are the same if they are the same kind of component (e.g. both are length facets) and their {value} properties have identical values.]

[Definition: The base attribute use set of a schema component is the set consisting of all members of the {attribute uses} property of members of the base type set of that schema component.]

[Definition: Two attribute uses are the same if the {name} and {target namespace} of their {attribute declaration} properties are equal. ]

(Note that this is not equality which requires checking the {type definition} as well. However, the rules for component consistency will ensure that checking the {name} and {target namespace} suffices for our purposes here.)

[Definition: The particle set of a schema component is the set consisting of the {content type} of that schema component with the members of the {particles} property of the {term} of any member of the set.]

[Definition: The base particle set of a schema component is the union of all particle sets of all the members of the extended base type set of that schema component.]

[Definition: Two particles are the same if the implementation reports them as the same.] Informally, implementations will report particles that are "inherited" from base types as "the same" as the corresponding particle in the base type. Future revisions of the XML Schema recommendation will specify more precisely the conditions under which particles should be regarded as "the same".

Traversal where the current schema component is the schema-as-a-whole component to any target schema component is always permitted in the construction of a canonical path. If the current schema component is not the schema-as-a-whole schema component, then traversal from the current schema component to the target schema component is forbidden in the construction of a canonical path if any of the following conditions is met:

  1. the target schema component is an identity constraint definition

  2. the target schema component is a simple or complex type definition whose {name} property is not absent

  3. the target schema component is an element or attribute declaration whose {scope} property is global

  4. the target schema component has a {scope} property whose value is a schema component and that schema component is not a member of the ancestor set of the target schema component

  5. the component relationship is {scope}, {substitution group affiliation}, {base type definition}, {primitive type definition}, or {referenced key}

  6. the target schema component is a facet and there exists some facet in its base facet set of the target schema component that is the same as the facet

  7. the current schema component is a complex type, the target schema component is the {attribute declaration} of an attribute use component and there exists some attribute use in the base attribute use set of the current schema component that is the same as the attribute use whose {attribute declaration} is the target schema component

  8. the target schema component is the {term} of a particle and there exists some particle in the base particle set of the current schema component that is the same as the target schema component

Informally, the first two conditions ensure that the canonical path to an identity constraint or a named type is the one that flows directly from the schema-as-a-whole component, the third condition ensures that the canonical path to element and attribute declarations is likewise the global one (if there is one), the last condition accounts for element and attribute declarations stemming from named model groups and attribute groups, the fifth ensures that the canonical path doesn't follow "backwards" paths, and the final three conditions ensure the canonical path to "inherited" components goes through their component of origin.

In general, it is not possible to obtain the canonical path for a schema component without access to the schema component graph. In particular, canonicalizing some non-canonical path, or determining whether a schema component path is canonical cannot be performed without such access.

For example, consider the path /type(x:foo)/element(x:bar).

For this schema fragment, this represents a canonical path to the local element bar:

<complexType name="foo">
  <sequence>
     <element name="bar" type="x:barType"/>
  </sequence>
</complexType>

But for this schema fragment, it represents a non-canonical path. The canonical path would be /group(x:barGroup)/element(x:bar).

<group name="barGroup">
  <sequence>
     <element name="bar" type="x:barType"/>
  </sequence>
</group>
<complexType name="foo">
  <sequence>
    <group ref="x:barGroup"/>
  </sequence>
</complexType>

4.3.1 Canonical Syntax

The concrete syntax allows certain abbreviations, such as eliding the positional predicate when the position is 1, eliding optional intermediate steps, abbreviations // and *, and using short forms for element and attribute declarations. Canonical path syntax forbids all these abbreviations.

Editorial note4-March-2004
Do we need to specify --A-- specific namespace prefix? Say, 'ns'.

4.4 Equality of Schema Component Paths

[Definition: Two schema component paths are equal if they have the same number of steps, and each step in one path is equal to the corresponding step in the other. Steps are equal if all of their properties have the same value.]

Note: This definition of equality neither relies on the notion of 'the same component' nor defines component equivalence. A schema component may have multiple schema component paths. Although these schema component paths address 'the same component', they are not equal. It is true, however, that two canonical paths to the same component will be equal.

5 Conformance

5.1 Schema Component Path Conformance

Schema component paths may be used by other specifications. For such usage, this specification does not define any criteria for conformance and relies on other specifications to specify criteria for conformance of implementations.

5.2 Schema Component Designator Conformance

Conforming XPointer processors claiming to support the xscd() scheme must conform to the behavior defined in this specification and XPointer xmlns() scheme specification.

6 Example (Non-Normative)

This section walks through an example XML Schema Document from the XML Schema Part 0: Primer and enumerates the abbreviated and canonical schema component designators for schema components.

All schema constructs in this section are considered to be in the following schema document and its URI is schema-URI,

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</xsd:schema>

The canonical schema component designator for this schema-as-a-whole component is schema-URI#xscd(/).

<xsd:annotation>
 <xsd:documentation xml:lang="en">
  Purchase order schema for Example.com.
  Copyright 2000 Example.com. All rights reserved.
 </xsd:documentation>
</xsd:annotation>

The canonical schema component designator for this annotation schema component is schema-URI#xscd(/annotations()).

The following is a global element declaration,

<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>

The abbreviated schema component designator for this element declaration component is schema-URI#xscd(/purchaseOrder) and the canonical is schema-URI#xscd(/element(purchaseOrder)).

The following is another global element declaration,

 <xsd:element name="comment" type="xsd:string"/>

The abbreviated schema component designator for this element declaration component is schema-URI#xscd(/comment) and the canonical is schema-URI#xscd(/element(comment)).

This following is a global complex type definition component,

<xsd:complexType name="PurchaseOrderType">
 <xsd:sequence>
  <xsd:element name="shipTo" type="USAddress"/>
  <xsd:element name="billTo" type="USAddress"/>
  <xsd:element ref="comment" minOccurs="0"/>
  <xsd:element name="items"  type="Items"/>
 </xsd:sequence>
 <xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>

The abbreviated schema component designator for this complex type definition and its element and attribute declaration components are,

schema-URI#xscd(/type(purchaseOrderType))
schema-URI#xscd(/type(purchaseOrderType)/shipTo)
schema-URI#xscd(/type(purchaseOrderType)/billTo)
schema-URI#xscd(/comment)
schema-URI#xscd(/type(purchaseOrderType)/items)
schema-URI#xscd(/type(purchaseOrderType)/@orderDate)

The canonical schema component designator for this complex type definition and its element and attribute declaration components are,

schema-URI#xscd(/type(purchaseOrderType))
schema-URI#xscd(/type(purchaseOrderType)/sequence()/element(shipTo))
schema-URI#xscd(/type(purchaseOrderType)/sequence()/element(billTo))
schema-URI#xscd(/element(comment))
schema-URI#xscd(/type(purchaseOrderType)/sequence()/element(items))
schema-URI#xscd(/type(purchaseOrderType)/attribute(orderDate))

The following is another global complex type definition component,

<xsd:complexType name="USAddress">
 <xsd:sequence>
  <xsd:element name="name"   type="xsd:string"/>
  <xsd:element name="street" type="xsd:string"/>
  <xsd:element name="city"   type="xsd:string"/>
  <xsd:element name="state"  type="xsd:string"/>
  <xsd:element name="zip"    type="xsd:decimal"/>
 </xsd:sequence>
 <xsd:attribute name="country" type="xsd:NMTOKEN"
     fixed="US"/>
</xsd:complexType>

The abbreviated schema component designator for this complex type definition and its element and attribute declaration components are,

schema-URI#xscd(/type(USAddress))
schema-URI#xscd(/type(USAddress)/name)
schema-URI#xscd(/type(USAddress)/street)
schema-URI#xscd(/type(USAddress)/city)
schema-URI#xscd(/type(USAddress)/state)
schema-URI#xscd(/type(USAddress)/zip)
schema-URI#xscd(/type(USAddress)/@country)

The canonical schema component designator for this complex type definition and its element and attribute declaration components are,

schema-URI#xscd(/type(USAddress))
schema-URI#xscd(/type(USAddress)/sequence()/element(name))
schema-URI#xscd(/type(USAddress)/sequence()/element(street))
schema-URI#xscd(/type(USAddress)/sequence()/element(city))
schema-URI#xscd(/type(USAddress)/sequence()/element(state))
schema-URI#xscd(/type(USAddress)/sequence()/element(zip))
schema-URI#xscd(/type(USAddress)/attribute(country))

The following is a global complex type definition with anonymous complex type and simple type definition components,

<xsd:complexType name="Items">
 <xsd:sequence>
  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
   <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="productName" type="xsd:string"/>
     <xsd:element name="quantity">
      <xsd:simpleType>
       <xsd:restriction base="xsd:positiveInteger">
        <xsd:maxExclusive value="100"/>
       </xsd:restriction>
      </xsd:simpleType>
     </xsd:element>
     <xsd:element name="USPrice"  type="xsd:decimal"/>
     <xsd:element ref="comment"   minOccurs="0"/>
     <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
    </xsd:sequence>
    <xsd:attribute name="partNum" type="SKU" use="required"/>
   </xsd:complexType>
  </xsd:element>
 </xsd:sequence>
</xsd:complexType>

The abbreviated schema component designator for this complex type definition and its element and attribute declaration, simple type definition, and facet components are,

schema-URI#xscd(/type(Items))
schema-URI#xscd(/type(Items)/item)
schema-URI#xscd(/type(Items)/item/type())
schema-URI#xscd(/type(Items)/item/productName)
schema-URI#xscd(/type(Items)/item/quantity)
schema-URI#xscd(/type(Items)/item/quantity/type())
schema-URI#xscd(/type(Items)/item/quantity/type()/facet(maxExclusive))
schema-URI#xscd(/type(Items)/item/USPrice)
schema-URI#xscd(/comment)
schema-URI#xscd(/type(Items)/item/shipDate)
schema-URI#xscd(/type(Items)/item/@partNum)

The canonical schema component designator for this complex type definition and its element and attribute declaration, simple type definition, and facet components are,

schema-URI#xscd(/type(Items))
schema-URI#xscd(/type(Items)/sequence()/element(item))
schema-URI#xscd(/type(Items)/sequence()/element(item)/type())
schema-URI#xscd(/type(Items)/sequence()/element(item)/type()/sequence()/element(productName))
schema-URI#xscd(/type(Items)/sequence()/element(item)/type()/sequence()/element(quantity))
schema-URI#xscd(/type(Items)/sequence()/element(item)/type()/sequence()/element(quantity)/type())
schema-URI#xscd(/type(Items)/sequence()/element(item)/type()/sequence()/element(quantity)/type()/facet(maxExclusive))
schema-URI#xscd(/type(Items)/sequence()/element(item)/type()/sequence()/element(USPrice))
schema-URI#xscd(/element(comment))
schema-URI#xscd(/type(Items)/sequence()/element(item)/type()/sequence()/element(shipDate))
schema-URI#xscd(/type(Items)/sequence()/element(item)/type()/attribute(partNum))

The following is a global simple type definition component,

<!-- Stock Keeping Unit, a code for identifying products -->
<xsd:simpleType name="SKU">
 <xsd:restriction base="xsd:string">
  <xsd:pattern value="\d{3}-[A-Z]{2}"/>
 </xsd:restriction>
</xsd:simpleType>

The canonical schema component designator for this simple type definition and its facet component are,

schema-URI#xscd(/type(SKU))
schema-URI#xscd(/type(SKU)/facet(pattern))

A Schema Component Properties (Non-Normative)

Schema component paths rely on the schema component graph implicit in the assembled collection of schema components and their properties. The following table details which properties are used for defining schema component paths, and whether they are used to define links in the graph (traversed) or just referenced for some other purpose.

ComponentPropertyUse
Attribute Declaration
{type definition}traversed
{annotation}traversed (special)
{name}referenced
{target namespace}referenced
{scope}traversed
{value constraint}none
Element Declaration
{type definition}traversed
{identity-constraint definitions}traversed
{annotation}traversed (special)
{name}referenced
{target namespace}referenced
{scope}traversed
{value constraint}none
{nillable}none
{substitution group affiliation}traversed
{substitution group exclusions}none
{disallowed substitutions}none
{abstract}none
Complex Type Definition
{base type definition}traversed
{attribute uses}traversed
{attribute wildcard}traversed
{content type}traversed
{annotations}traversed (special)
{name}referenced
{target namespace}referenced
{derivation method}none
{final}none
{abstract}none
{prohibited substitutions}none
Attribute Use
{attribute declaration}traversed
{value constraint}none
{required}none
Attribute Group Definition
{attribute uses}traversed
{attribute wildcard}traversed
{annotation}traversed (special)
{name}referenced
{target namespace}referenced
Model Group Definition
{model group}traversed
{annotation}traversed (special)
{name}referenced
{target namespace}referenced
Model Group
{particles}traversed
{annotation}traversed (special)
{compositor}referenced
Particle
{term}traversed
{min occurs}none
{max occurs}none
Wildcard
{annotation}traversed (special)
{namespace constraint}none
{process contents}none
Identity-constraint Definition
{annotation}traversed (special)
{name}referenced
{target namespace}referenced
{identity-constraint category}none
{selector}none
{fields}none
{referenced key}traversed
Notation Declaration
{annotation}traversed (special)
{name}referenced
{target namespace}referenced
{public identifier}none
{system identifier}none
Annotation
{application information}none
{user information}none
{attributes}none
Schema
{type definitions}traversed
{attribute declarations}traversed
{element declarations}traversed
{attribute group definitions}traversed
{model group definitions}traversed
{identity constraint definitions}traversed
{annotations}traversed (special)
Simple Type Definition
{base type definition}traversed
{facets}traversed
{fundamental facets}traversed
{item type definition}traversed
{member type definitions}traversed
{annotations}traversed (special)
{name}referenced
{target namespace}referenced
{variety}referenced
{final}none
{primitive type definition}traversed
Facets
{annotation}traversed (special)
{value}none
{fixed}none

B Glossary (Non-Normative)

The listing below is for the benefit of readers of a printed version of this document: it collects together all the definitions which appear in the document above.

Editorial note 
An XSL macro is used to collect definitions from throughout the spec and gather them here for easy reference. Should talk to Henry for details.

C References

C.1 Normative References

RFC 2396
Tim Berners-Lee et al, RFC 2396: Uniform Resource Identifiers, Internet Engineering Task Force, 1995, available at http://www.ietf.org/rfc/rfc2396.txt with an update available at http://gbiv.com/protocols/uri/rev-2002/rfc2396bis.html.
XSD2
Paul V. Biron and Ashok Malhotra, XML Schema Part 2: Datatypes, World Wide Web Consortium, 2001, available at http://www.w3.org/TR/xmlschema-2/
XML
Tim Bray and Jean Paoli and C. M. Sperberg-McQueen, Extensible Markup Language (XML) 1.0, World Wide Web Consortium, 1998, available at http://www.w3.org/TR/REC-xml/
XPTR XMLNS
Steven J. DeRose, Ron Daniel Jr., Eve Maler, Jonathan Marsh, XPointer xmlns() Scheme, World Wide Web Consortium, 2003, available at http://www.w3.org/TR/xptr-xmlns/
XPTR
Paul Grosso, Eve Maler, Jonathan Marsh, Norman Walsh, XPointer Framework, World Wide Web Consortium, 2003, available at http://www.w3.org/TR/xptr-framework/
XSD1
Henry S. Thompson, David Beech, Murray Maloney and Noah Mendelsohn, XML Schema Part 1: Structures, World Wide Web Consortium, 2001, available at http://www.w3.org/TR/xmlschema-1/

C.2 Non-normative Informational References

XPath
James Clark and Steve DeRose, XML path language (XPath) version 1.0, World Wide Web Consortium, 1999, available at http://www.w3.org/TR/xpath
XSD0
David C. Fallside, XML Schema Part 0: Primer, World Wide Web Consortium, 2001, available at http://www.w3.org/TR/xmlschema-0/