• Workplace Board
  • Style guide
  • Privacy Policy
  • Share on Facebook

Co-occurrence constraints also Conditional Type Assignment, with XML Schema 1.1

May 29, 2018

Mukul Gandhi

1. Introduction

Those story discusses the XML Schema 1.1 language and specifically its following two product in details: "Co-occurrence constraints", and "Conditional Enter Assignment". The article assumes that reader has knowledge to XML, XML Namespaces and basic knowledge of XML Schema (likely the 1.0 version of XML Schematic language) such fountain. The very fundamental of like technologies won't be covered in this article. XML Schema 1.0 Back Edition has been a W3C standard since October 2004, and a a widely applied in numerous products and archives. XML Schema 1.1 were a W3C standard inbound April 2012, and its implementation is already ready in few products and libraries. This books uses Xerces-J to test the examples shown. The misc compliant products will exhibit similar behavior.

Some form of co-occurrence constraints has were available in XML Schemas 1.0 as well, which would be mentioned as well-being in this article. Conditional Type Assignment is a completely new facility started in XML Schema 1.1 country. Definitive XML System 1.1 Examples: Assertions (xs:assertion, xs ...

XML Schema 1.1 select is backward compatible with XML Schema 1.0 language. This means that, XML Scheme 1.0 validations will runner fine with an XML Schema 1.1 processor. An XML Schema print, describes the structure and data-types for a certain school of XML documents (for example, a schema document can describe how a purchase arrange should look like as an XML document). To do this, this schema document uses definitions likes io and attribute declarations, and complex and simple type definitions. An XML System document also is a well-formed XML document, therefore it sack be processed just like any XML document. But XML Schema documents are special to a sense that, they have line and attributes from the XML namespace " http://www.w3.org/2001/ XMLSchema " (the XML Schema document cans have XML items away other XML namespaces as well as XML items not from any namespace).

2. XML Schema sample

Before going deeper into the haupt topics of this article, I would like the present ampere simple example mentioning an XML instance document, its corresponding schema and the process of validating of of XML instance document with adenine schema. This plan to set of right technical context, for the larger body of this books. XML System Id Substitution

Consider which following example, where a XML document has dating about a person that would be validating includes a XML Schema.

XML Schema document:

The following XML object document is valid according to above schema documenting:

(the XML instance document has chosen not in mention the elements "mName" and "dob", this are declared optional in and XML schema). XML Schema Tutorial

As a fountain known convention, XML print that are validated with a schema will be referred as XML instance documents on to article.

3. Why employ co-occurrence constraints and with species assignments inbound XML validations?

The nature of data (in particular XML data) will such that, co-occurrence constraints and conditional character assignment will one of the native constraints that cannot exist in XML documents. And the users of XML Schema language, have have demanding such features inbound XML Schema language since long time; and these are now available stylish XML Schema 1.1 language. Let's viewing at that benefits of diesen feature as were featured in paragraphs underneath. These eigenheiten are in the namespace whose name is http://Wizurai.com/2001/XMLSchema-instance . For brevity, the text real examples into this ...

Co-occurrence constraints: There belongs certainly a requirement that, distinct elements and attributes in an XML document allow relate to each other by certain conditions. Multiple examples of that have

  • On an XML io, attribute "min" must is less for characteristics "max".
  • The sum of data in an sequence of elements shall meet a certain condition (like it must subsist equal, smaller than or taller is some added, etc). W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures
  • A individual element values must relate in a certain way, to one specifics attribute's value.

Wealth can imaging many various create constraints, which may collecting be termed as "co-occurrence constraints".

Conditional model assignment: These are a specific type of constraints, so solve this following problems although modeling XML data using XML schemas. Some properties of a element (mainly the absence/presence, or values of its attributes), may requesting certainly types (simple or complex types) to the element.

These aspects will become more clear, in the following sections of this article.

4. Co-occurrence constraints

The XML Schema 1.1 specification defines layout co-occurrence constraints such tracks:

"constraints which make the presence of an property or element, or of values allowable for it, depend on the value oder presence by other user or elements" .

XML Schema 1.0 when certain kinds of co-occurrence constraints, using aforementioned following elements in the schema document: unique , key and keyref (these constructs are known as Identity Constraints conversely IDC the the XML Schema language). These elements need to be specified on the element declarations in a schema document, for establishing co-occurrence relationships. The unique, key and keyref constraints are available in XML Schema 1.1 language as well.

At a high levels, both "key" both "unique" constraints require that, certain values in an XML document must be distinct (i.e. choose different).

Followed is an show by by the "key" element in an XML Schema document.

Interestingly, that "id" element within this "student" element is specified as optional within the above schema record. I've chosen so, to illustrate the distinctions between "key" and "unique" IDC elements.

Following is one applicable XML document according to above schema document:

Following are two faulty XML documents for the schema presented included this example:

(in this example, a particular "id" value occurs more than once, ensure violates the "key" constraint)

(in this example, if "id" line is stated as optional in the schema, it must be present provided "key" constraint can specified in the schema)

Are in the XSD document von this exemplary, we specified "unique" element instead von "key" as follows:

press everything else in the XSD document remains same, then following two XML documents be be reported than valid by create a XSD document:

The "unique" tag in an XSD document, considers fine that of XML item pointed by xs:field can be null/absent. But the "key" element does not allow this (all XML items laid by xs:field must exists, and must has valid values).

I won't be explaining "keyref" element in aforementioned articles, and wait the readers go go about information andere whenever they to to.

4.1 XML Schematic 1.1 co-occurrence restrictions

Is this section, I would explain the employs of next XML Shape 1.1 constructs: <xs:assert> and <xs:assertion> . The <xs:assert> construct provides equipment in co-occurrence constraints. <xs:assertion> looks similar to <xs:assert> but <xs:assertion> is fixed in the defines of XSD simple kinds because facet. Although <xs:assertion> is not an co-occurrence write in XML Schema documents, I'll explain <xs:assertion> as well is all sections, ever <xs:assert> or <xs:assertion> are syntactically very equivalent.

I'll copy several definitions by the XML Schema 1.1 specification below, to illustrate where inside an XSD document <xs:assert> element can occured (the place of assertions are highlighted with bold emphasis).

XML Representation Summarized: complexType Element Information Item

XML Representation Summery: simpleContent Select Information Item et al.

XML Representation Summary: complexContent Element Information Item et al.

As bucket being seen from above definitions, <xs:assert> can be written in comprehensive type definitions and they can occur null up to any quantity of times. The asserts are written at the end of advanced type definitions.

The element <xs:assert> is itself defined as following in the XML Schema 1.1 specification:

XML Representation Summary: assert Element Information Item

Quoting off XML Circuit 1.1 specification, "An assertion is adenine prong associated with a type, which remains checked for jeder instance of who type. If with element or attribute related item fails to satisfy one assertion associated on a given type, then that resources item remains not locally valid with respect to that type."

What this essentially means is, that if assertions are specified on adenine complex type for example, then every XML instance snapping that is validated by as one complex kind will or be validated by the rules expressed by the assertions. An assertion at evaluated on an XML instance document, will result in a boolean 'true' or a 'false' outcome. If the evaluation for any expression results in a 'false' outcome, then the concerning XML instance fragmenting and the XML case document as a complete would be reported because invalid by the XML Diagramm 1.1 engine. Assertions are specified as XPath 2.0 expressions, ensure are evaluated on a strongly typed (the types we were referring are the XML Schema types) XML planting rooted to an basic whose complex type is performing the validation of an XML element. How go define alternate XML structures in XSD scheme?

Let us look by few XML Schema use falling, where statement could be useful. Of later examples with applicable explanations illustrate this.

Assertion example 1:

Consider the following XSD 1.1 pattern:

(the complex type by this XSD document is borrows away XML Schema 1.1 specification)

(the assertion in on example, requires that the value of "min" attribute must be less or equals to is of "max" attribute for the XML document to live considered valid)

Following is a validity XML document, whereas validated by the above schema:

While, following XML document is invalid when validated by the diagrams stylish this exemplary:

The XML Schema 1.1 specification allows, one increase to any number of <xs:assert> elements to will there per one particular score. Consider of following XSD document, who is a lightness variation of one XSD document specified higher:

In this example we have dual <xs:assert> elements, both concerning which must to return boolean true 'true' for the validated to passed. The second <xs:assert> specifies that the "min" attribute must be greater than 2.

Following are a valid XML document forward the above schema:

Whereas, following XML document intention be reported as invalid by the schema defined at this example:

Curious, the two asserts stated in diese example can is converted into tracking ne <xs:assert> :

(please note the "and" condition in the assert's XPath expression)

Note that any particular assert, can use expressions using the full schema consciously XPath 2.0 language (look at Sme section, for a link to XPath 2.0 language specification). xs:alternative

Assertion example 2:

Judge the following XSD document:

The assertion in above XSD certificate specifies, ensure all "id" element values must be distinct.

Tracking is a valid XML document as per outline above:

Whereas, following is an invalid XML document when validated by the schema documentation provided at this example:

(the value 2 has occurred learn than once)

It can be argued, that assertion in like example specifies einer IDC like constraint (with "key" or "unique" XSD elements). It is really up in the user's taste whether she wanted like until use IDC constraints or use assertions, for a requirement like specified in is example.

Assertion example 3:

Let us look at further XSD example, which solves an problem away sorting using <xs:assert> expressions. Consider to following XSD document:

Aforementioned <xs:assert> element in this XSD select requires, that values of "id" elements should occur in ascending sorted order. In this example, consecutive identical values are considered sorted.

Let's try go understand this XPath 2.0 expression as specified in the example. A "for" loop is included in einen "every" statement. The "for" loop returns one sequence of boolean worths (a 'true' means that, the previous value is less-or-equal to this current item's value). Of "every" construct specifies, that each of that item in the "for" loop's returned sequence must be 'true'. The specified XPath expression is a naive implementation, a the check of sorted order.

Assertion example 4:

Sentences including provides new string processing capabilities for complex type "mixed" content models. Following is one example of this. Think the following XSD document:

(note mixed= "true" on complexType, furthermore the <xs:assert> element)

The assertion specifies that, the word "prohibited" required not occur in any of text nodes which are child of the fixed node "X" .

Following exist two valid XML records for the aforementioned schema document:

When, followers is one invalid XML document when validated by the XSD support pending stylish this example:

Interrogation examples 5:

Assertions also provide on arbitrary strength processing when using the <xs:any> wild-card schema element (the <xs:any> wild-card in the schema, identify which it allows any element to occur at its spot in the XML single document). Considered of following XSD document:

The first assertion specifies that, child element of element "X" must did have name "temp" . The secondary statements specifies so, string value of an element which is child of "X" must can maximum length 9.

Following is on sound XML document for the XSD schema shown above:

Whereas following two XML documents would subsist invalid, when certified by the same XSD schema:

(element "temp" is no allowed by aforementioned <xs:assert> )

(the string "abcdefghij" exceeds an length required by <xs:assert> )

Assertion example 6:

In this example, we'll visit how specifying <xs:assert> works in an XSD complex your derivation. Consider the following XSD document:

Following is one validity XML report, when validated by the above XSD schema:

(the value of attribute "id" a an even integer, or the value of element "x" contains the talk "hello" )

Follow are two invalid XML documents, when verified by and XSD document defined in this example:

(the value of part "x" doesn't contain the word "hello" )

(the value for "id" attribute is not even)

Another useful XSD 1.1 schemas can be write which use <xs:assert> , if are use XPath 2.0 functions like "avg" , "max" , "min" , "sum" (Infact the whole to XPath 2.0 functions & operators may becoming second in <xs:assert> XPath expressions).

Including Xerces-J, by default XML comments real processing instructions (PIs) are not available in the XPath Data Example (XDM) trees such <xs:assert> expressions can zugang. With an API pick, setting a specify validation feature to boolean 'true', will make comments and Flatfoots available in XDM trees through assertion analysis. By enabling this feature, we can allow <xs:assert> expressions into check fork presence/absence and do string processing on comments and PIs.

4.2 Simple Type characteristic <xs:assertion>

The XML Schema 1.1 language, has introduced a new facet for simple types such is named <xs:assertion> . The <xs:assertion> doesn't provide used co-occurrence constraints, I'm describing it here because it is quite similar to <xs:assert> at the grammatical level ( <xs:assert> and <xs:assertion> both use XPath 2.0 expressions as a predicate language).

Following is an excerpt from the XML Schema 1.1 specification the course of simple genres:

XML Agency Summary: simpleType Element Information Item et alo.

The elements <xs:assertion> is itself defined when following in the XML Schema 1.1 specification:

XML Representation Summary: assertion Element Information Item

Let's see ampere fairly simple example from using <xs:assertion> facet for an XSD schema. Consider the following XSD document:

Following is one valid XML insert, when validated by the above XSD document:

(the value of the "id" element must be and even integer, as required by aforementioned schema)

Whereas following is one-time void XML document, when validated by an XSD document specified in those example:

(the "id" values 1, 3 and 5 are non valid according at the XSD schema)

5. Limited Type Association

The XML Schema 1.1 function also refers to on XSD construct as "Type Alternatives". Many times, we would also refer until this feature as CTA. And "Type Alternative" XSD feature exists also a form of co-occurrence constraint (as we shall see in this section), but I have chosen for describe itp in an section of its own. Contentions become the generic co-occurrence relationship feature, while CTAs provide a certain kind of co-occurrence inhibitions feature. How take you set alternate XML structures inbound xsd schema? For example the next structures would be optional: <a> <b/> <c> <d/> </c> </a> and <a&g...

We can specify 0 up to each number of <xs:alternative> XSD elements since child the <xs:element> constructive.

The following XSD course fragments, illustrate the syntax of <xs:alternative> construct:

XML Show Summary: element Element Information Item

Let's look at a simple case, illustrating the functionality of <xs:alternative> element. Considerable the following XSD document:

In to the XSD document above, one content of "address" element becoming have ampere type "USAddress" in an XML instance document provided aforementioned customize "format" has value "US" on who "address" element. And if the "address" element's customize "format" has evaluate "Canada" , then the content of "address" element will have ampere type "CanadaAddress" include an XML instance document. i.e depending on the value a an attribute in an XML illustration document, we can specify different XSD types to an constituent.

Followers is one valid XML download, according toward the XSD document presented above:

Let's also look at the followed alterations go above XSD validation:

1) If in an XML instance document, we set value other than "US" and "Canada" to which attribute "format" of XML items "address" .

In this case, the validation will still pass. Let's discuss the reasons of this. The <xs:element> declaration with <xs:alternative> elements in it, is implicitly available when following:

That shall, provided "format" characteristics does not have values "US" or "Canada" , afterwards "address" element willing will species "xs:anyType".

Also consider following syntax:

The XML instance element "E1" canned have types T1, T2 or T3. Types T1 and T2 must derive from type T3. This is a compulsion that lives required by the XML Sheets 1.1 specification.

2) We change one element declaration included XSD document for following:

Now if in aforementioned XML cite document, value of attribute "format" is all other better "US" or "Canada" , the type xs:error will be assigned at the element "address" . xs:error shall an XSD easily type, and any element otherwise characteristic that shall assigned the type xs:error is invalid. Therefore, in this case an XSD validation fails.

"test" property on <xs:alternative>: The value of "test" attribute on the <xs:alternative> element, is an XPath expression. Items would evaluate to likewise bootlean 'true' with 'false'. Aforementioned context item for an "test" evaluation is an element node upon whichever <xs:alternative> constructs are spoken. The XML Wiring 1.1 language says, that we can write these "test" expressions using a CTA specific XPath language (that your designation in the XSD 1.1 specification), or using the full XPath 2.0 language. Xerces-J due default uses the CTA specific XPath language, but it bottle benefit full XPath 2.0 language at setting a specific feature on the validation API during the XSD validation. Other XSD 1.1 validators can choose to implements this, to their customizable ways.

I hope this essay met the expectations of reading, to understand the working of co-occurrence constraints the type alternative features of the XSD 1.1 words. Correct usage of xs:alternative in XML 1.1

Time discussing both assertions also conditionality type assignments, I haven't discussed one XML namespace related special concerning assertion and CTA constructs. They are simpler to understand, if we perceive the fundamentals of XML namespaces. I would leave it to the readership to explore those features, if they want to. XML Schema 1.1 <alternative> use cases with <choice> and <attribute>

7. References

  • W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures : http://www.w3.org/TR/ xmlschema11-1/
  • W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes : http://www.w3.org/TR/ xmlschema11-2/
  • XML Road Language (XPath) 2.0 : http://www.w3.org/TR/xpath20/
  • XQuery 1.0 the XPath 2.0 Functions and Operators : http://www.w3.org/TR/xquery- operators/
  • Xerces-J XML tools library : http://xerces.apache.org/ xerces2-j/

Related links

  • Follow-up blog post on Mukul's blog

conditional type assignment xsd

Xml – How to make type depend on attribute value using Conditional Type Assignment

xml xsd xsd-1.1 xsd-validation

I have an XML file like this

I'd like to make an XSD, so that if the value of the attribute "type" is 1, the name and surname elements must be present, and when it's 2, name and id must be there. I tried to generate the XSD in XSD schema generator , but it made the surname and id element minOccurs=0. How could I make it work?

Best Solution

You can do this using XSD 1.1's Conditional Type Assignment :

Related Solutions

Java – generate java classes from .xsd files….

JAXB does EXACTLY what you want. It's built into the JRE/JDK starting at 1.6

Python – How to parse XML and count instances of a particular node attribute

I suggest ElementTree . There are other compatible implementations of the same API, such as lxml , and cElementTree in the Python standard library itself; but, in this context, what they chiefly add is even more speed -- the ease of programming part depends on the API, which ElementTree defines.

First build an Element instance root from the XML, e.g. with the XML function, or by parsing a file with something like:

Or any of the many other ways shown at ElementTree . Then do something like:

And similar, usually pretty simple, code patterns.

Related Question

  • Xml – Extract value of attribute node via XPath
  • Xml – How to make an element in XML schema optional
  • Restriction of elements based on another attribute using XSD 1.1

DEV Community

DEV Community

M. Alexandre J-S William ELISÉ

Posted on Nov 19, 2019

Answer: How to make type depend on attribute value using Conditional Type Assignment

You can do this using XSD 1.1's Conditional Type Assignment :

Top comments (0)

pic

Templates let you quickly answer FAQs or store snippets for re-use.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink .

Hide child comments as well

For further actions, you may consider blocking this person and/or reporting abuse

kairatorozobekov profile image

JavaScript Efficiency War: Astro.js vs Next.js

Kairat - Feb 21

kishansheth profile image

Next.js 14 Booking App with Live Data Scraping using Scraping Browser

Kishan Sheth - Feb 22

shuttle_dev profile image

Implementing JWT Authentication in Rust

Shuttle - Feb 21

igbojionu profile image

Understanding CSS Website Layouts

igbojionu - Feb 22

Once suspended, mralexandrelise will not be able to comment or publish posts until their suspension is removed.

Once unsuspended, mralexandrelise will be able to comment and publish posts again.

Once unpublished, all posts by mralexandrelise will become hidden and only accessible to themselves.

If mralexandrelise is not suspended, they can still re-publish their posts from their dashboard.

Once unpublished, this post will become invisible to the public and only accessible to M. Alexandre J-S William ELISÉ.

They can still re-publish the post if they are not suspended.

Thanks for keeping DEV Community safe. Here is what you can do to flag mralexandrelise:

mralexandrelise consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy.

Unflagging mralexandrelise will restore default visibility to their posts.

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

W3C logo

XML Schema (XSD) 1.1

What's new, c. m. sperberg-mcqueen, black mesa technologies, http://www.blackmesatech.com/2009/07/xsd11, summer xml 2009, 27 july 2009, overview and introduction, classes of change in xsd 1.1, datatypes changes.

  • Co-occurrence constraints
  • Other declaration changes
  • Versioning XSD itself

Deploying XSD 1.1

  • XSD 1.0 Recommendation: May 2001
  • XSD 1.0 Second Edition: October 2004
  • minor tweaks
  • some additional functionality
  • What happened ...
  • Editorial improvements
  • Conceptual clarifications, simplifications
  • Alignment with other specs
  • including support for easier versioning, extensibility, backward compatibility

Editorial changes

  • new terminology
  • reorganized XML mappings
  • if vs. if and only if
  • must ... be vs. must ... must
  • sentence-by-sentence revisions
  • ... and hundreds more.

Conceptual clarifications

  • restriction rules simplified
  • post-schema-validation info set (PSVI)
  • validation rules and terminology
  • conformance levels
  • schema composition terminology
  • ... and more

Nine specific changes to look for

  • New datatypes (and other Datatypes changes)

Changes to the ID datatype

Conditional type assignment.

  • Weakened wildcards
  • Open content

Changes to substitution groups

Xsd versioning, lax fallback.

  • (Arithmetic) equality vs. identity
  • Tighter value space / lexical space story
  • anyAtomicType
  • yearMonthDuration
  • dayTimeDuration
  • dateTimeStamp
  • precisionDecimal
  • Implementation-defined primitives

Numbers and significant digits

Precision decimal, the explicittimezone facet, the explicittimezone facet (2).

  • list of xsd:ID
  • unions of xsd:ID and other types
  • default and fixed xsd:ID values*
  • multiple xsd:ID attributes on same element (N.B. multiple ID elements were already legal.)

Supporting xml:id with XSD 1.1

Q: how do i ... .

  • “How do I say that if xml:lang="ja" , the element has type my:Japanese-prose , and otherwise my:Western-prose ?”
  • “How do I say that if attribute a is "v1" , then b must not be any of v2 , v3 , v4 ?”
  • “How do I require that the count attribute give the correct number of children?”

A: Co-occurrence constraints

  • conditional type assignment (CTA)
  • assertions (check clauses)
  • Element E has type T.
  • Element E has ...
  • If 〈test 1〉 then type T1
  • else if 〈test 2〉 then type T2
  • else if 〈test n 〉 then type T n
  • else type T

Supporting Atom message types with XSD 1.1

Internationalizing your prose, restrictions on cta tests.

  • attributes on the element itself
  • ancestors, siblings, children, descendants
  • attributes on the above

Inherited attributes

Supporting xml:lang with xsd 1.1, checking the count attribute, xpath evaluation.

  • True → OK
  • False → not valid
  • Xpath error → not valid
  • Evaluated on a subtree.
  • Full XPath is legal; for CTA, implementations may support subset.
  • Attributes, descendants are typed; element itself is not typed.

CTA vs. Assertions (vs. Schematron)

  • element - type binding
  • very restricted XDM (attributes only)
  • part of type
  • XDM has (typed) subtree
  • typically element-based
  • may point anywhere in the document
  • not type-aware*
  • streamable?

Revision to UPA

Competition.

  • Q 1 = Q 0 + < P 1 >
  • Q 2 = Q 0 + < P 2 >

New UPA rule

  • No two element particles in M compete.
  • No two wildcard particles in M compete.

Weak wildcards in XSD 1.1 (basic structure)

Weak wildcards 2 (planning extensibility).

  • We expect we may revise this schema.
  • We want 1.0 handlers to accept 2.0 messages.
  • accept valid 1.0 messages
  • reject all others

Weak wildcards 3 (worrying about 2.0)

  • We worry about 2.0. What if 2.0 wants to allow <personName xmlns="http://example.com/ns> <given>Dave</given> <middle>Bryce</middle> <surname>Orchard</surname> </personName> ?

Weak wildcards 4 (1.0 wildcards)

Weak wildcards 5 (1.1 wildcards), weak wildcards 6 (a 1.1 gotcha), weak wildcards 7 (a legal 1.1 formulation), open content: the problem.

  • a given element
  • followed optionally by a middle
  • followed by a surname
  • with anything at all allowed before, between, and after.

Open content: the feature

Open content: the feature (2), other wildcard changes.

  • negative wildcards (exclude certain namespaces, certain QNames)
  • not-my-sibling wildcards
  • not-in-schema wildcards ( BEWARE! )
  • Multiple substitution group heads
  • Abstract elements in substitution groups

Using substitution groups for extensibility

  • xsd:schema now has open content
  • block="#all" is gone
  • identifiers for versions of XSD (coexistence)
  • implementations can allow user-defined primitives
  • version-control ( vc:* ) attributes

Version-control attributes

  • vc:minVersion , vc:maxVersion : What version of XSD does the validator support?
  • vc:typeAvailable , vc:typeUnavailable : Are these types built-in?
  • vc:facetAvailable , vc:facetUnavailable : Does the processor understand these facets?

Using version-control in schema documents

  • either skip
  • or ‘fall back to lax assessment’ (with xsd:anyType )
  • fall back to lax assessment with xsd:anyType (always)

Lax fallback for xsi:type

  • a restriction of declared type
  • an extension of declared type
  • named subsets of PSVI
  • new names for conformance levels
  • error detection required
  • implementation-defined primitives, facets, built-ins
  • invocation terminology
  • choice of XML 1.0 or XML 1.1
  • implementation-defined, implementation-dependent

Implementation-defined, implementation-dependent

  • implementation-defined : may vary from vendor to vendor. Must be documented.
  • implementation-dependent : may vary from moment to moment. Need not be documented (and in fact, documentation discouraged).

Checklist of implementation-defined features

  • Use of XML 1.0 or XML 1.1 name rules.
  • Read schema documents (or hard-coded schema?)
  • Possible methods of invocation.
  • What parts of PSVI available to user? How?
  • Schema composition policy.
  • Additional primitives?
  • Implementation limits (max integer, etc.)

XML 1.0 or XML 1.1?

Conforming implementations of this specification may provide either the 1.1-based datatypes or the 1.0-based datatypes, or both. If both are supported, the choice of which datatypes to use in a particular assessment episode should be under user control.

Named PSVI subsets

  • root-validity (valid? validation attempted? error?)
  • instance-validity (as above, for each element and attribute)
  • type-aware (as above, plus particle, declaration, type definition, etc.)
  • lightweight type-aware (as above, using names of types, not full type info)
  • full instance (everything but the components)
  • full PSVI with components (everything including the components)

Conformance levels

Starting schema-validity assessment.

  • type-driven : start here , using type definition foo
  • element-driven : start here , using element declaation bar
  • attribute-driven : start here , using attribute declaration baz
  • lax-wildcard validation : start here , as if matching a lax wildcard (i.e. either find the declaration or fall back to lax processing). Missing declaration? Not a problem.
  • strict-wildcard validation : start here , as if matching a strict wildcard (i.e. either find the declaration or fall back to lax processing).* Missing declaration? It's the end of the world.*

Schema composition terminology

  • Where does the processor look?
  • Methods of indirection
  • What to use in indirect lookup
  • When to stop
  • Reacting to failure

Where to look

  • hard-coded schemas
  • automatically known components
  • hard-coded schema locations
  • named pairs (run-time options)
  • user-specified schema documents
  • interactive inquiry
  • namespace name
  • schemaLocation hints in the XML instance
  • schemaLocation hints in schema documents
  • local repository

Indirection

  • path indirection / search path
  • URI indirection
  • recursion (multi-step lookup)
  • non-recursion

What's the key?

  • other ... ?
  • stop after first success
  • consult all locations / resources

Why all these terms?

  • vendors — to say what their software does
  • users — to say what they want their software to do
  • other specs — to say what schema validators must do, to work with their spec

Technical-QA.com

Which is conditional required element in an XSD?

Table of Contents

  • 1 Which is conditional required element in an XSD?
  • 2 When to use conditional type assignment in XML?
  • 3 How are child elements declared in XSD schema?
  • 4 What is if condition in xsd file-codeproject?

I have a requirement for an xml schema which accepts either a request with the customer or with the customer id. If the customer Id is 0 then we need the customer data, if it’s > 0 then customer data is optional (They can submit ammendements). My XSD looks like this at the moment; I need something a bit like this…

When to use conditional type assignment in XML?

Conditional type assignment: These are a specific type of constraints, that solve the following problems while modeling XML data using XML schemas. Some properties of an element (mainly the absence/presence, or values of its attributes), may require certain types (simple or complex types) to the element.

Is it possible to have two elements in XSD?

For example, when test@attrib=”one”, I want one-element to be allowed and mandatory or when test@attrib=”two”, I want two-element to be allowed and mandatory. Is it possible in XSD? Not within the same type.

When do I need an XML schema for XSD?

I have a requirement for an xml schema which accepts either a request with the customer or with the customer id. If the customer Id is 0 then we need the customer data, if it’s > 0 then customer data is optional (They can submit ammendements). My XSD looks like this at the moment;

How are child elements declared in XSD schema?

The child elements in the XML document MUST appear in the order they are declared in the XSD schema. Only one of the child elements described in the XSD schema can appear in the XML document. The child elements described in the XSD schema can appear in the XML document in any order.

What is if condition in xsd file-codeproject?

Please Sign up or sign in to vote. 1. if Attibute1 value is “XYZ” then Attibute2 value should be “ABC”? if Attibute1 value is “WXYZ” then Attibute2 value should be “DEF”? but still it is not performing the validation , i am using MSXML4 for xml validation. Please Sign up or sign in to vote. At least try to format the code. (I did it for you now)

infosec-jobs.com logo

  • Post a Job Post a Job
  • Find Talent Find Talent
  • Log in Log in

XSD explained

XSD: Extensible Markup Language Schema Definition

Table of contents

Introduction, what is xsd, documentation, history and background, xsd examples, data exchange and integration, web services, data validation and sanitization, career aspects.

In the world of information security and cybersecurity, data validation and data integrity play a crucial role. One of the key technologies used for defining and validating the structure and content of XML documents is XSD, which stands for Extensible Markup Language Schema Definition. XSD provides a standardized way to describe the structure, data types, and constraints of XML documents, ensuring that they adhere to a predefined set of rules.

XSD is a specification developed by the World Wide Web Consortium (W3C) that defines the structure and content of XML documents. It is an XML-based language used to describe the elements, attributes, data types, and relationships within an XML document. XSD serves as a blueprint or contract for XML documents, allowing developers to define the expected structure and content of XML data.

How is XSD Used?

XSD is primarily used for two purposes: validation and documentation.

XSD provides a set of rules that XML documents must adhere to in order to be considered valid. These rules are defined using XSD elements and attributes, such as xs:element , xs:attribute , xs:complexType , and xs:simpleType . By specifying the structure and data types of elements and attributes, XSD enables the validation of XML documents against a predefined schema.

For example, consider an XML document that represents user information. The XSD schema can define the expected structure, such as the presence of a name element and an email attribute. It can also define the data types and constraints, such as requiring the email attribute to be a valid email address. By validating XML documents against the XSD schema, potential data integrity issues, such as missing or incorrect data, can be detected and prevented.

XSD schemas can also serve as documentation for XML documents. They provide a clear and structured representation of the expected structure and content of XML data. Developers can refer to XSD schemas to understand the requirements and constraints of XML documents, facilitating the development, integration, and maintenance of XML-based systems.

The development of XSD began in the late 1990s as a replacement for Document Type Definitions (DTDs), which were the traditional method for defining the structure of XML documents. XSD aimed to address the limitations of DTDs, such as the lack of support for data types, namespaces, and more advanced validation rules.

The first version of XSD, known as XSD 1.0, was published by the W3C in 2001 as a recommendation 1 . It introduced a powerful set of features, including support for complex data types, namespaces, and constraints. XSD 1.1, the second version of the specification, was published in 2012 2 . It introduced additional features, such as assertions and conditional type assignment, further enhancing the expressive power of XSD.

To illustrate the usage of XSD, let's consider a simple example of an XSD schema for an address book. The following XSD snippet defines a schema that expects an addressBook element, which contains multiple contact elements. Each contact element must have a name element, an optional email element, and an address element.

In this example, the XSD schema defines the structure of the address book XML document. It specifies that the addressBook element should contain one or more contact elements. Each contact element should have a name element of type xs:string , an optional email element of type xs:string , and an address element of type xs:string . By validating an XML document against this XSD schema, we can ensure that it conforms to the defined structure.

XSD finds applications in various domains and scenarios. Some of the common use cases include:

XSD is widely used for exchanging data between different systems and applications. It provides a standardized way to define the structure and content of XML documents, ensuring interoperability and data integrity. XSD schemas serve as a contract between data producers and consumers, enabling seamless integration and communication.

XSD plays a crucial role in defining the structure of XML messages exchanged between web services. By defining the expected structure and data types of XML messages, XSD ensures that web services can communicate effectively and handle data in a consistent manner. XSD schemas are often used in conjunction with web service description languages like WSDL (Web Services Description Language) to define the complete contract of a web service.

XSD is a powerful tool for validating and sanitizing XML data. By defining constraints, data types, and relationships within an XML document, XSD enables the detection and prevention of data integrity issues, such as missing or incorrect data. XSD validation is commonly used in data processing pipelines, data transformation, and data quality assurance processes.

Proficiency in XSD is highly valuable for professionals working in the fields of information security and cybersecurity. Understanding XSD allows security experts to analyze and validate XML data structures, ensuring the integrity and security of XML-based systems.

In terms of career opportunities, XSD expertise can open doors in various roles, including:

  • XML Security Analyst: Responsible for analyzing and securing XML-based systems, including the validation and sanitization of XML data using XSD schemas.
  • XML Integration Specialist: Involved in integrating XML-based systems and ensuring data integrity through the use of XSD schemas.
  • XML Developer: Responsible for developing XML-based applications and services, including the design and implementation of XSD schemas.

As XML continues to be a widely used format for data exchange and integration, the relevance of XSD in the industry remains high. Staying up-to-date with the latest versions of XSD and best practices for schema design and validation can enhance career prospects in the field of information security and cybersecurity.

XSD, or Extensible Markup Language Schema Definition, is a powerful tool for validating and defining the structure and content of XML documents. It provides a standardized way to ensure data integrity and interoperability in XML-based systems. By defining constraints, data types, and relationships, XSD schemas serve as a contract between data producers and consumers. XSD plays a vital role in various domains, including data exchange, web services, and data validation. Proficiency in XSD is valuable for professionals in the information security and cybersecurity fields, opening doors to various career opportunities.

XSD: Extensible Markup Language Schema Definition - A Blueprint for XML Data Validation and Integrity

References:

XML Schema Definition Language (XSD) 1.0   ↩

XML Schema Definition Language (XSD) 1.1   ↩

Humbly Confident Security Lead

@ YNAB | Remote

Information Technology Specialist II: Information Security Engineer

@ WBCP, Inc. | Pasadena, CA.

Director of the Air Force Cyber Technical Center of Excellence (CyTCoE)

@ Air Force Institute of Technology | Dayton, OH, USA

Senior Cyber Security Analyst

@ Valley Water | San Jose, CA

Information Systems Director/Officer

@ Bay Area Air Quality Management District | San Francisco, CA

Chief Information Security Officer (CISO)

@ California Institute of Technology | Pasadena, CA

Looking for InfoSec / Cybersecurity jobs related to XSD? Check out all the latest job openings on our XSD job list page.

XSD talents

Looking for InfoSec / Cybersecurity talent with experience in XSD? Check out all the latest talent profiles on our XSD talent search page.

Related articles

  • Using XML Schema (XSD) ▷
  • XML Schema 1.1 ▷

Assertions on simple types

  • About Saxon
  • Change history
  • Configuration
  • Handling XML documents
  • Using XQuery
  • Using XPath
  • Validation from the command line
  • Validation from Java
  • Validation from C#
  • Validation from C/C++, Python or PHP
  • Validation from Ant
  • Schema-aware queries and transformations
  • Exporting schema component models
  • Assertions on complex types
  • Conditional type assignment
  • All model groups
  • Open content
  • Miscellaneous XSD 1.1 features
  • Handling minOccurs and maxOccurs
  • Built-in schemas
  • Handling absent components
  • Saxon extensions to XML Schema 1.1
  • The Gizmo utility
  • Localization
  • Extensibility mechanisms
  • Saxon extensions
  • Experimental 4.0 extensions
  • Sample Saxon applications
  • Saxon SQL extension
  • Reference: XSLT elements
  • Reference: XPath syntax
  • Reference: Function library
  • Standards conformance
  • Using this documentation

XSD 1.1 allows assertions on simple types to be defined. The mechanism is to define an xs:assertion element as a child of the xs:restriction child of the xs:simpleType element (that is, it acts as an additional facet). The type must be an atomic type. The value of the test attribute of xs:assert is an XPath expression.

The expression is evaluated with the value being validated supplied as the value of the variable $value . This will be an instance of the base type: for example, if you are restricting from xs:string , it will be a string; if you are restricting from xs:date , it will be an xs:date ; if you are validating a list of integers, then $value will be a sequence of integers.

If the effective boolean value of the expression is true, the value is valid. If the effective boolean value is false, or if a dynamic error occurs while evaluating the expression, the value is invalid. Currently no diagnostics are produced to indicate why the value is deemed invalid, other than a statement that the xs:assertion facet is violated. You can supply a message in a saxon:message attribute: see saxon:message .

The XPath expression has no access to any part of the document being validated, other than the atomic value of the actual element or attribute node. So the validation cannot be context-sensitive.

The XPath expression may make calls on Java extension functions in the normal way: see Writing extension functions in Java . Allowing call-out to procedural programming languages means that you can perform arbitrary procedural validation of element and attribute values. Take care to disable use of extension functions if validating against a schema that is untrusted.

The following example validates that a date is in the past:

The following example validates that a string is a legal XPath expression. This relies on the fact that a failure evaluating the assertion is treated as "false":

Note how the in-scope namespaces for the XPath expression are taken from the in-scope namespaces of the containing xs:assert element.

Saxon Developer Guide (Non-JavaScript Version)

Make Me Engineer

How to make type depend on attribute value using Conditional Type Assignment

You can do this using XSD 1.1’s Conditional Type Assignment :

Related Contents:

  • Require XML element in XSD when another element has certain value?
  • xmlns, xmlns:xsi, xsi:schemaLocation, and targetNamespace?
  • How to link XML to XSD using schemaLocation or noNamespaceSchemaLocation?
  • What does elementFormDefault do in XSD?
  • XML Validation with XSD in Visual Studio IDE
  • Restricting XML Elements Based on Another Element via XSD
  • The difference between and in XSD?
  • XSLT – XSD files – Where to find the schema.xsd file – Please suggest
  • Is there any difference between ‘valid xml’ and ‘well formed xml’?
  • XML attribute vs XML element
  • How to reference a local XML Schema file correctly?
  • How to generate sample XML documents from their DTD or XSD?
  • What’s the difference between xsd:include and xsd:import?
  • XML Schema minOccurs / maxOccurs default values
  • What are XML namespaces for?
  • Must an XML namespace name URI be retrievable?
  • Any tools to generate an XSD schema from an XML instance document? [closed]
  • XSD – how to allow elements in any order any number of times?
  • How to restrict the value of an XML element using xsi:type in XSD?
  • XML Schema: Element with attributes containing only text?
  • processContents strict vs lax vs skip for xsd:any
  • XML Schema (XSD) validation tool? [closed]
  • What are the best practices for versioning XML schemas?
  • XML namespaces and attributes
  • XML Schema How to Restrict Attribute by Enumeration
  • What is the difference between XML and XSD?
  • Free DTD to XSD conversion utility? [closed]
  • How to convert xsd to human readable documentation? [closed]
  • What is the purpose of XSD files?
  • The ‘minOccurs’ attribute cannot be present
  • Generate Json schema from XML schema (XSD) [closed]
  • Does XML care about the order of elements?
  • How to validate XML against XSD 1.1 in Java?
  • What are invalid characters in XML
  • How to parse XML using vba
  • How to use jQuery for XML parsing with namespaces
  • How to validate an XML file using Java with an XSD having an include?
  • How to save newlines in XML attribute?
  • What’s the difference between text/xml vs application/xml for webservice response
  • How to change or reassign a variable in XSLT?
  • How to transform XML data into a data.frame?
  • How to force wrap on table entries
  • How to declare XPath namespaces in xmlstarlet?
  • Generating XML file using XSD file
  • Is XML case-sensitive?
  • How to ignore namespace when selecting XML nodes with XPath
  • Libraries and tutorials for XML in Delphi
  • Add CDATA to an xml file
  • What is the difference between // and .// in XPath?
  • How to run a specific phpunit xml testsuite?

Leave a Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

404 Not found

Search code, repositories, users, issues, pull requests...

Provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Support for validation XSD version 1.1 #1500

@alfoa

alfoa commented Apr 6, 2021 • edited

@alfoa

alfoa commented May 13, 2021

Sorry, something went wrong.

@wangcj05

Successfully merging a pull request may close this issue.

@alfoa

W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures

W3c candidate recommendation 30 april 2009.

This document is also available in these non-normative formats: XML , XHTML with changes since version 1.0 marked , XHTML with changes since previous Working Draft marked , Independent copy of the schema for schema documents , Independent copy of the DTD for schema documents , Independent tabulation of components and microcomponents , and  List of translations .

Copyright  © 2009  W3C ® ( MIT , ERCIM , Keio ), All Rights Reserved. W3C liability , trademark and document use rules apply.

This document specifies the XML Schema Definition Language, which offers facilities for describing the structure and constraining the contents of XML documents, including those which exploit the XML Namespace facility. The schema language, which is itself represented in an XML vocabulary and uses namespaces, substantially reconstructs and considerably extends the capabilities found in XML document type definitions (DTDs). This specification depends on XML Schema Definition Language 1.1 Part 2: Datatypes .

Status of this Document

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

This W3C Candidate Recommendation specifies W3C XML Schema Definition Language (XSD) 1.1. It is here made available for review by W3C members and the public. XSD 1.1 retains all the essential features of XSD 1.0, but adds several new features to support functionality requested by users, fixes many errors in XSD 1.0, and clarifies wording.

  • To reduce confusion and avert a widespread misunderstanding, the normative references to various W3C specifications now state explicitly that while the reference describes the particular edition of a specification current at the time this specification is published, conforming implementations of this specification are not required to ignore later editions of the other specification but instead may support later editions, thus allowing users of this specification to benefit from corrections to other specifications on which this one depends.
  • The discussion of schemaLocation information in How schema definitions are located on the Web (§4.3.2) has been revised to try to make clearer the motivation for recommending user control over whether schema locations specified in the document instance should or should not be dereferenced. The new text describes some circumstances in which such schema locations typically should be dereferenced and some in which they should not, and attempts to set useful expectations for users and for implementors. These changes are intended to resolve issue 6655 , raised by the W3C Web Accessibility Initiative's Protocols and Formats Working Group.
  • The conceptual overview now included in Constraint Components (§2.2.4) some discussion of the overlap in functionality among identity constraints, conditional type assignment, and assertions, and identifies some of the factors which may be relevant in choosing among them; this change resolves issue 5023 Relationship between identity constraints and assertions .
  • The discussion of schema import in Licensing References to Components Across Namespaces (§4.2.5.1) now states more clearly that references to components in external namespaces are an error if the namespace is not imported; this change addresses issue 5779 QName resolution and xs:import .
  • The discussion of checking content-type restriction included in an appendix in earlier drafts of this specification has now been removed, as have some references to published algorithms for the problem. Several of the papers referred to are no longer publicly accessible on the Web, and the changes made to the Unique Particle Attribution (§3.8.6.4) have in any case rendered those algorithms obsolete. These changes resolve issue 6685 Appendix I Checking content-type restriction References Not Available .
  • Discussions of global components now take <redefine> into account (addresses issue 5918 Top level declarations ).
  • The fact that · xs:anyType · is its own base type has been clarified (addresses issue 6204 anyType/ur-Type: inconsistent whether it has a base-type ).
  • The rules for the "available collections" and "default collection" properties of the [XPath 2.0] dynamic context have been simplified; these properties are now required to be the empty set instead of being · implementation-defined · . This improves interoperability and resolves issue 6540 Available documents in assertions .
  • The [XPath 2.0] static context used for the evaluation of assertions has been clarified; it now explicitly includes the functions in the [Functions and Operators] fn namespace and constructors for all built-in types. This resolves issue 6541 Assertions and in-scope functions .
  • The definition of · context-determined type table · now explicitly excludes skip wildcards from consideration and makes clear that · xs:anyType · never maps an element information item or an expanded name to any · context-determined type table · . This aligns the treatment of type tables more closely with that of declared types and resolves issue 6561 Type Substitutable in Restriction .
  • Several other editorial corrections and improvements have been made.

For those primarily interested in the changes since version 1.0, the appendix Changes since version 1.0 (non-normative) (§G) is the recommended starting point. It summarizes both changes made since XSD 1.0 and some changes which were expected (and predicted in earlier drafts of this specification) but have not been made after all. Accompanying versions of this document display in color all changes to normative text since version 1.0 and since the previous Working Draft.

The Candidate Recommendation review period for this document extends until 3 August 2009. Comments on this document should be made in W3C's public installation of Bugzilla, specifying "XML Schema" as the product. Instructions can be found at http://www.w3.org/XML/2006/01/public-bugzilla . If access to Bugzilla is not feasible, please send your comments to the W3C XML Schema comments mailing list, [email protected] ( archive ) Each Bugzilla entry and email message should contain only one comment.

Although feedback based on any aspect of this specification is welcome, there are certain aspects of the design presented herein for which the Working Group is particularly interested in feedback. These are designated "priority feedback" aspects of the design, and identified as such in editorial notes at appropriate points in this draft. Any feature mentioned in a priority feedback note is a "feature at risk": the feature may be retained as is or dropped, depending on the feedback received from readers, schema authors, schema users, and implementors.

Publication as a Candidate Recommendation 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.

  • A test suite is available which tests each required and optional feature of XSD 1.1.
  • Each feature of the specification has been implemented successfully by at least two independent implementations.
  • The Working Group has responded formally to all issues raised against this document during the Candidate Recommendation period.

This document has been produced by the W3C XML Schema Working Group as part of the W3C XML Activity . The goals of XSD 1.1 are discussed in the document Requirements for XML Schema 1.1 . The authors of this document are the members of the XML Schema Working Group. Different parts of this specification have different editors.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy . W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy .

The English version of this specification is the only normative version. Information about translations of this document is available at http://www.w3.org/2003/03/Translations/byTechnology?technology=xmlschema .

Table of Contents

1 introduction.

This document sets out the structural part of the XML Schema Definition Language.

Chapter 2 presents a Conceptual Framework (§2) for XSD, including an introduction to the nature of XSD schemas and an introduction to the XSD abstract data model, along with other terminology used throughout this document.

Chapter 3, Schema Component Details (§3) , specifies the precise semantics of each component of the abstract model, the representation of each component in XML, with reference to a DTD and an XSD schema for an XSD document type, along with a detailed mapping between the elements and attribute vocabulary of this representation and the components and properties of the abstract model.

Chapter 4 presents Schemas and Namespaces: Access and Composition (§4) , including the connection between documents and schemas, the import, inclusion and redefinition of declarations and definitions and the foundations of schema-validity assessment.

Chapter 5 discusses Schemas and Schema-validity Assessment (§5) , including the overall approach to schema-validity assessment of documents, and responsibilities of schema-aware processors.

The normative appendices include a Schema for Schema Documents (Structures) (normative) (§A) for the XML representation of schemas and Normative (§M.1) .

The non-normative appendices include the DTD for Schemas (non-normative) (§J) and a Glossary (non-normative) (§I) .

This document is primarily intended as a language definition reference. As such, although it contains a few examples, it is not primarily designed to serve as a motivating introduction to the design and its features, or as a tutorial for new users. Rather it presents a careful and fully explicit definition of that design, suitable for guiding implementations. For those in search of a step-by-step introduction to the design, the non-normative [XML Schema: Primer] is a much better starting point than this document.

1.1 Introduction to Version 1.1

The Working Group has three main goals for this version of W3C XML Schema:

  • Significant improvements in simplicity of design and clarity of exposition without loss of backward or forward compatibility;
  • Provision of support for versioning of XML languages defined using this specification, including the XML vocabulary specified here for use in schema documents.
  • Provision of support for co-occurrence constraints, that is constraints which make the presence of an attribute or element, or the values allowable for it, depend on the value or presence of other attributes or elements.

These goals are in tension with one another. The Working Group's strategic guidelines for changes between versions 1.0 and 1.1 can be summarized as follows:

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

The aim with regard to compatibility is that

  • All schema documents conformant to version 1.0 of this specification should also conform to version 1.1, and should have the same validation behavior across 1.0 and 1.1 implementations (except possibly in edge cases and in the details of the resulting PSVI);
  • The vast majority of schema documents conformant to version 1.1 of this specification should also conform to version 1.0, leaving aside any incompatibilities arising from support for versioning or co-occurrence constraints, and when they are conformant to version 1.0 (or are made conformant by the removal of versioning information), should have the same validation behavior across 1.0 and 1.1 implementations (again except possibly in edge cases and in the details of the resulting PSVI);

1.2 Purpose

The purpose of XML Schema Definition Language: Structures is to define the nature of XSD schemas and their component parts, provide an inventory of XML markup constructs with which to represent schemas, and define the application of schemas to XML documents.

The purpose of an XSD schema is to define and describe a class of XML documents by using schema components to constrain and document the meaning, usage and relationships of their constituent parts: datatypes, elements and their content and attributes and their values. Schemas can also provide for the specification of additional document information, such as normalization and defaulting of attribute and element values. Schemas have facilities for self-documentation. Thus, XML Schema Definition Language: Structures can be used to define, describe and catalogue XML vocabularies for classes of XML documents.

Any application that consumes well-formed XML can use the formalism defined here to express syntactic, structural and value constraints applicable to its document instances. The XSD formalism allows a useful level of constraint checking to be described and implemented for a wide spectrum of XML applications. However, the language defined by this specification does not attempt to provide all the facilities that might be needed by applications. Some applications will require constraint capabilities not expressible in this language, and so will need to perform their own additional validations.

1.3 Namespaces and Language Identifiers

1.3.1 xsd namespaces, 1.3.1.1 the schema namespace ( xs ).

The XML representation of schema components uses a vocabulary identified by the namespace name http://www.w3.org/2001/XMLSchema . For brevity, the text and examples in this specification use the prefix xs: to stand for this namespace; in practice, any prefix can be used.

Users of the namespaces defined here should be aware, as a matter of namespace policy, that more names in this namespace may be given definitions in future versions of this or other specifications.

1.3.1.2 The Schema Instance Namespace ( xsi )

This specification defines several attributes for direct use in any XML documents, as described in Schema-Related Markup in Documents Being Validated (§2.6) . These attributes are in the namespace whose name is http://www.w3.org/2001/XMLSchema-instance . For brevity, the text and examples in this specification use the prefix xsi: to stand for this namespace; in practice, any prefix can be used.

1.3.1.3 The Schema Versioning Namespace ( vc )

The pre-processing of schema documents described in Conditional inclusion (§4.2.1) uses attributes in the namespace http://www.w3.org/2007/XMLSchema-versioning . For brevity, the text and examples in this specification use the prefix vc: to stand for this namespace; in practice, any prefix can be used.

1.3.2 Namespaces with Special Status

  • http://www.w3.org/XML/1998/namespace
  • http://www.w3.org/2001/XMLSchema
  • http://www.w3.org/2001/XMLSchema-instance
  • http://www.w3.org/2007/XMLSchema-versioning

Components and source declarations must not specify http://www.w3.org/2000/xmlns/ as their target namespace. If they do, then the schema and/or schema document is in · error · .

1.3.3 Conventional Namespace Bindings

  • fn bound to http://www.w3.org/2005/xpath-functions (defined in [Functions and Operators]
  • html bound to http://www.w3.org/1999/xhtml
  • my (in examples) bound to the target namespace of the example schema document
  • rddl bound to http://www.rddl.org/
  • vc bound to http://www.w3.org/2007/XMLSchema-versioning (defined in this and related specifications)
  • xhtml bound to http://www.w3.org/1999/xhtml
  • xlink bound to http://www.w3.org/1999/xlink
  • xml bound to http://www.w3.org/XML/1998/namespace (defined in [XML 1.1] and [XML Namespaces 1.1] )
  • xs bound to http://www.w3.org/2001/XMLSchema (defined in this and related specifications)
  • xsi bound to http://www.w3.org/2001/XMLSchema-instance (defined in this and related specifications)
  • xsl bound to http://www.w3.org/1999/XSL/Transform

In practice, any prefix bound to the appropriate namespace name may be used (unless otherwise specified by the definition of the namespace in question, as for xml and xmlns ).

1.3.4 Schema Language Identifiers

Sometimes other specifications or Application Programming Interfaces (APIs) need to refer to the XML Schema Definition Language in general, sometimes they need to refer to a specific version of the language. To make such references easy and enable consistent identifiers to be used, we provide the following URIs to identify these concepts.

Please see XSD Language Identifiers (non-normative) (§L) for a complete list of XML Schema Definition Language identifiers which exist to date.

1.4 Dependencies on Other Specifications

The definition of XML Schema Definition Language: Structures depends on the following specifications: [XML Infoset] , [XML Namespaces 1.1] , [XPath 2.0] , and [XML Schema: Datatypes] .

See Required Information Set Items and Properties (normative) (§D) for a tabulation of the information items and properties specified in [XML Infoset] which this specification requires as a precondition to schema-aware processing.

[XML Schema: Datatypes] defines some datatypes which depend on definitions in [XML 1.1] and [XML Namespaces 1.1] ; those definitions, and therefore the datatypes based on them, vary between version 1.0 ( [XML 1.0] , [XML Namespaces 1.0] ) and version 1.1 ( [XML 1.1] , [XML Namespaces 1.1] ) of those specifications. In any given schema-validity- · assessment · episode, the choice of the 1.0 or the 1.1 definition of those datatypes is · implementation-defined · .

Conforming implementations of this specification may provide either the 1.1-based datatypes or the 1.0-based datatypes, or both. If both are supported, the choice of which datatypes to use in a particular assessment episode should be under user control.

1.5 Documentation Conventions and Terminology

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

  • sections explicitly marked non-normative
  • examples and their commentary
  • informal descriptions of the consequences of rules formally and normatively stated elsewhere (such informal descriptions are typically introduced by phrases like "Informally, ..." or "It is a consequence of ... that ...")

Special terms are defined at their point of introduction in the text. For example [Definition:]   a term is something used with a special meaning . The definition is labeled as such and the term it defines is displayed in boldface. The end of the definition is not specially marked in the displayed or printed text. Uses of defined terms are links to their definitions, set off with middle dots, for instance · term · .

Non-normative examples are set off in boxes and accompanied by a brief explanation:

The definition of each kind of schema component consists of a list of its properties and their contents, followed by descriptions of the semantics of the properties:

An example property

References to properties of schema components are links to the relevant definition as exemplified above, set off with curly braces, for instance {example property} .

For a given component C , an expression of the form " C . {example property} " denotes the (value of the) property {example property} for component C . The leading " C ." (or more) is sometimes omitted, if the identity of the component and any other omitted properties is understood from the context. This "dot operator" is left-associative, so " C . {p1} . {p2} " means the same as "( C . {p1} ) . {p2} " and denotes the value of property {p2} within the component or · property record · which itself is the value of C 's {p1} property. White space on either side of the dot operator has no significance and is used (rarely) solely for legibility.

For components C 1 and C 2 , an expression of the form " C 1  .  {example property 1} = C 2  .  {example property 2} " means that C 1 and C 2 have the same value for the property (or properties) in question. Similarly, " C 1 = C 2 " means that C 1 and C 2 are identical, and " C 1 . {example property} = C 2 " that C 2 is the value of C 1 . {example property} .

The correspondence between an element information item which is part of the XML representation of a schema and one or more schema components is presented in a tableau which illustrates the element information item(s) involved. This is followed by a tabulation of the correspondence between properties of the component and properties of the information item. Where context determines which of several different components corresponds to the source declaration, several tabulations, one per context, are given. The property correspondences are normative, as are the illustrations of the XML representation element information items.

In the XML representation, bold-face attribute names (e.g. count below) indicate a required attribute information item, and the rest are optional. Where an attribute information item has an enumerated type definition, the values are shown separated by vertical bars, as for size below; if there is a default value, it is shown following a colon. Where an attribute information item has a built-in simple type definition defined in [XML Schema: Datatypes] , a hyperlink to its definition therein is given.

The allowed content of the information item is shown as a grammar fragment, using the Kleene operators ? , * and + . Each element name therein is a hyperlink to its own illustration.

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

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

Unless otherwise specified, references to attribute values are references to the · actual value · of the attribute information item in question, not to its · normalized value · or to other forms or varieties of "value" associated with it. For a given element information item E , expressions of the form " E has att1 = V " are short-hand for "there is an attribute information item named att1 among the [attributes] of E and its · actual value · is V ." If the identity of E is clear from context, expressions of the form " att1 = V " are sometimes used. The form " att1 ≠ V " is also used to specify that the · actual value · of att1 is not V .

References to properties of information items as defined in [XML Infoset] are notated as links to the relevant section thereof, set off with square brackets, for example [children] .

Properties which this specification defines for information items are introduced as follows:

References to properties of information items defined in this specification are notated as links to their introduction as exemplified above, set off with square brackets, for example [new property] .

The "dot operator" described above for components and their properties is also used for information items and their properties. For a given information item I , an expression of the form " I  .  [new property] " denotes the (value of the) property [new property] for item I .

Lists of normative constraints are typically introduced with phrase like "all of the following are true" (or "... apply"), "one of the following is true", "at least one of the following is true", "one or more of the following is true", "the appropriate case among the following is true", etc. The phrase "one of the following is true" is used in cases where the authors believe the items listed to be mutually exclusive (so that the distinction between "exactly one" and "one or more" does not arise). If the items in such a list are not in fact mutually exclusive, the phrase "one of the following" should be interpreted as meaning "one or more of the following". The phrase "the appropriate case among the following" is used only when the cases are thought by the authors to be mutually exclusive; if the cases in such a list are not in fact mutually exclusive, the first applicable case should be taken. Once a case has been encountered with a true condition, subsequent cases must not be tested.

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

Within normative prose in this specification, the words may , should , must and must not are defined as follows:

These definitions describe in terms specific to this document the meanings assigned to these terms by [IETF RFC 2119] . The specific wording follows that of [XML 1.1] .

Where these terms appear without special highlighting, they are used in their ordinary senses and do not express conformance requirements. Where these terms appear highlighted within non-normative material (e.g. notes), they are recapitulating rules normatively stated elsewhere.

This specification provides a further description of error and of conformant processors' responsibilities with respect to errors in Schemas and Schema-validity Assessment (§5) .

2 Conceptual Framework

This chapter gives an overview of XML Schema Definition Language: Structures at the level of its abstract data model. Schema Component Details (§3) provides details on this model, including a normative representation in XML for the components of the model. Readers interested primarily in learning to write schema documents will find it most useful first to read [XML Schema: Primer] for a tutorial introduction, and only then to consult the sub-sections of Schema Component Details (§3) named XML Representation of ... for the details.

2.1 Overview of XSD

An XSD schema is a set of components such as type definitions and element declarations. These can be used to assess the validity of well-formed element and attribute information items (as defined in [XML Infoset] ), and furthermore may specify augmentations to those items and their descendants. This augmentation makes explicit information that was implicit in the original document, such as normalized and/or default values for attributes and elements and the types of element and attribute information items. The input information set can also be augmented with information about the validity of the item, or about other properties described in this specification. [Definition:]   We refer to the augmented infoset which results from conformant processing as defined in this specification as the post-schema-validation infoset , or PSVI . Conforming processors may provide access to some or all of the PSVI, as described in Subset of the Post-schema-validation Infoset (§C.1) . The mechanisms by which processors provide such access to the PSVI are neither defined nor constrained by this specification.

Throughout this specification, [Definition:]   the word valid and its derivatives are used to refer to clause 1 above, the determination of local schema-validity .

Throughout this specification, [Definition:]   the word assessment is used to refer to the overall process of local validation, schema-validity assessment and infoset augmentation .

2.2 XSD Abstract Data Model

This specification builds on [XML 1.1] and [XML Namespaces 1.1] . The concepts and definitions used herein regarding XML are framed at the abstract level of information items as defined in [XML Infoset] . By definition, this use of the infoset provides a priori guarantees of well-formedness (as defined in [XML 1.1] ) and namespace conformance (as defined in [XML Namespaces 1.1] ) for all candidates for · assessment · and for all · schema documents · .

Just as [XML 1.1] and [XML Namespaces 1.1] can be described in terms of information items, XSD schemas can be described in terms of an abstract data model. In defining schemas in terms of an abstract data model, this specification rigorously specifies the information which must be available to a conforming XSD processor. The abstract model for schemas is conceptual only, and does not mandate any particular implementation or representation of this information. To facilitate interoperation and sharing of schema information, a normative XML interchange format for schemas is provided.

[Definition:]   Schema component is the generic term for the building blocks that make up the abstract data model of the schema. [Definition:]   An XSD schema is a set of · schema components · . There are several kinds of schema component, falling into three groups. The primary schema components, which may (type definitions) or must (element and attribute declarations) have names, are as follows:

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

The secondary schema components, are as follows:

  • Attribute group definitions
  • Identity-constraint definitions
  • Type alternatives
  • Model group definitions
  • Notation declarations

Finally, the "helper" schema components provide small parts of other schema components; they are dependent on their context:

  • Annotations
  • Model groups
  • Attribute Uses

The name [Definition:]   Component covers all the different kinds of schema component defined in this specification.

During · validation · , [Definition:]   declaration components are associated by (qualified) name to information items being · validated · .

On the other hand, [Definition:]   definition components define internal schema components that can be used in other schema components .

[Definition:]   Declarations and definitions may and in some cases must have and be identified by name s, which are NCNames as defined by [XML Namespaces 1.1] .

[Definition:]   Several kinds of component have a target namespace , which is either · absent · or a namespace name, also as defined by [XML Namespaces 1.1] . The · target namespace · serves to identify the namespace within which the association between the component and its name exists.

An expanded name , as defined in [XML Namespaces 1.1] , is a pair consisting of a namespace name, which may be · absent · , and a local name. The expanded name of any component with both a · target namespace · property and a · component name · property is the pair consisting of the values of those two properties. The expanded name of a declaration is used to help determine which information items will be · governed · by the declaration.

· Validation · , defined in detail in Schema Component Details (§3) , is a relation between information items and schema components. For example, an attribute information item is · validated · with respect to an attribute declaration, a list of element information items with respect to a content model, and so on. The following sections briefly introduce the kinds of components in the schema abstract data model, other major features of the abstract model, and how they contribute to · validation · .

2.2.1 Type Definition Components

The abstract model provides two kinds of type definition component: simple and complex.

[Definition:]   This specification uses the phrase type definition in cases where no distinction need be made between simple and complex types .

Type definitions form a hierarchy with a single root. The subsections below first describe characteristics of that hierarchy, then provide an introduction to simple and complex type definitions themselves.

2.2.1.1 Type Definition Hierarchy

[Definition:]   Except for · xs:anyType · , every · type definition · is, by construction, either a · restriction · or an · extension · of some other type definition. The exception · xs:anyType · is a · restriction · of itself. With the exception of the loop on · xs:anyType · , the graph of these relationships forms a tree known as the Type Definition Hierarchy with · xs:anyType · as its root .

[Definition:]   The type definition used as the basis for an · extension · or · restriction · is known as the base type definition of that definition . [Definition:]   If a type definition D can reach a type definition B by following its base type definition chain, then D is said to be derived from B . In most cases, a type definition is derived from other type definitions. The only exception is · xs:anyType · , which is derived from itself.

[Definition:]   A type defined with the same constraints as its · base type definition · , or with more, is said to be a restriction . The added constraints might include narrowed ranges or reduced alternatives. Given two types A and B , if the definition of A is a · restriction · of the definition of B , then members of type A are always locally valid against type B as well.

[Definition:]   A complex type definition which allows element or attribute content in addition to that allowed by another specified type definition is said to be an extension .

[Definition:]   A special complex type definition, (referred to in earlier versions of this specification as 'the ur-type definition') whose name is anyType in the XSD namespace, is present in each · XSD schema · . The definition of anyType serves as default type definition for element declarations whose XML representation does not specify one .

[Definition:]   A special simple type definition, whose name is error in the XSD namespace, is also present in each · XSD schema · . The XSD error type has no valid instances. It can be used in any place where other types are normally used; in particular, it can be used in conditional type assignment to cause elements which satisfy certain conditions to be invalid.

For brevity, the text and examples in this specification often use the qualified names xs:anyType and xs:error for these type definitions. (In practice, any appropriately declared prefix can be used, as described in Schema-Related Markup in Documents Being Validated (§2.6) .)

2.2.1.2 Simple Type Definition

A simple type definition is a set of constraints on strings and information about the values they encode, applicable to the · normalized value · of an attribute information item or of an element information item with no element children. Informally, it applies to the values of attributes and the text-only content of elements.

Each simple type definition, whether built-in (that is, defined in [XML Schema: Datatypes] ) or user-defined, is a · restriction · of its · base type definition · . [Definition:]   A special · restriction · of · xs:anyType · , whose name is anySimpleType in the XSD namespace, is the root of the · Type Definition Hierarchy · for all simple type definitions. · xs:anySimpleType · has a lexical space containing all sequences of characters in the Universal Character Set (UCS) and a value space containing all atomic values and all finite-length lists of atomic values . As with · xs:anyType · , this specification sometimes uses the qualified name xs:anySimpleType to designate this type definition. The built-in list datatypes all have · xs:anySimpleType · as their · base type definition · .

[Definition:]   There is a further special datatype called anyAtomicType , a · restriction · of · xs:anySimpleType · , which is the · base type definition · of all the primitive datatypes. This type definition is often referred to simply as " xs:anyAtomicType ". It too is considered to have an unconstrained lexical space. Its value space consists of the union of the value spaces of all the primitive datatypes.

[Definition:]   Datatypes can be constructed from other datatypes by restricting the value space or lexical space of a {base type definition} using zero or more Constraining Facet s, by specifying the new datatype as a list of items of some {item type definition} , or by defining it as a union of some specified sequence of {member type definitions} .

The mapping from lexical space to value space is unspecified for items whose type definition is · xs:anySimpleType · or · xs:anyAtomicType · . Accordingly this specification does not constrain processors' behavior in areas where this mapping is implicated, for example checking such items against enumerations, constructing default attributes or elements whose declared type definition is · xs:anySimpleType · or · xs:anyAtomicType · , checking identity constraints involving such items.

[XML Schema: Datatypes] provides mechanisms for defining new simple type definitions by · restricting · some primitive or ordinary datatype. It also provides mechanisms for constructing new simple type definitions whose members are lists of items themselves constrained by some other simple type definition, or whose membership is the union of the memberships of some other simple type definitions. Such list and union simple type definitions are also · restrictions · of · xs:anySimpleType · .

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

2.2.1.3 Complex Type Definition

A complex type definition is a set of attribute declarations and a content type, applicable to the [attributes] and [children] of an element information item respectively. The content type may require the [children] to contain neither element nor character information items (that is, to be empty), or to be a string which belongs to a particular simple type, or to contain a sequence of element information items which conforms to a particular model group, with or without character information items as well.

  • a restriction of a complex · base type definition ·
  • an · extension · of a simple or complex · base type definition · .

For detailed information on complex type definitions, see Complex Type Definitions (§3.4) .

2.2.2 Declaration Components

There are three kinds of declaration component: element, attribute, and notation. Each is described in a section below. Also included is a discussion of element substitution groups, which is a feature provided in conjunction with element declarations.

2.2.2.1 Element Declaration

An element declaration is an association of a name with a type definition, either simple or complex, an (optional) default value and a (possibly empty) set of identity-constraint definitions. The association is either global or scoped to a containing complex type definition. A top-level element declaration with name 'A' is broadly comparable to a pair of DTD declarations as follows, where the associated type definition fills in the ellipses:

Element declarations contribute to · validation · as part of model group · validation · , when their defaults and type components are checked against an element information item with a matching name and namespace, and by triggering identity-constraint definition · validation · .

For detailed information on element declarations, see Element Declarations (§3.3) . For an overview of identity constraints, see Identity-constraint Definition (§2.2.4.1) .

2.2.2.2 Element Substitution Group

[Definition:]   Through the mechanism of element substitution groups , XSD provides a more powerful model supporting substitution of one named element for another . Any top-level element declaration can serve as the defining member, or head, for an element · substitution group · . Other top-level element declarations, regardless of target namespace, can be designated as members of the · substitution group · headed by this element. In a suitably enabled content model, a reference to the head · validates · not just the head itself, but elements corresponding to any other member of the · substitution group · as well.

All such members must have type definitions which are either the same as the head's type definition or derived from it. Therefore, although the names of elements can vary widely as new namespaces and members of the · substitution group · are defined, the content of member elements is constrained by the type definition of the · substitution group · head.

Note that element substitution groups are not represented as separate components. They are specified in the property values for element declarations (see Element Declarations (§3.3) ).

2.2.2.3 Attribute Declaration

An attribute declaration is an association between a name and a simple type definition, together with occurrence information and (optionally) a default value. The association is either global, or local to its containing complex type definition. Attribute declarations contribute to · validation · as part of complex type definition · validation · , when their occurrence, defaults and type components are checked against an attribute information item with a matching name and namespace.

For detailed information on attribute declarations, see Attribute Declarations (§3.2) .

2.2.2.4 Notation Declaration

A notation declaration is an association between a name and an identifier for a notation. For an attribute or element information item to be · valid · with respect to a NOTATION simple type definition, its value must have been declared with a notation declaration.

For detailed information on notation declarations, see Notation Declarations (§3.14) .

2.2.3 Model Group Components

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

2.2.3.1 Model Group

A model group is a constraint in the form of a grammar fragment that applies to lists of element information items. It consists of a list of particles, i.e. element declarations, wildcards and model groups. There are three varieties of model group:

  • Sequence (the element information items match the particles in sequential order);
  • Conjunction (the element information items match the particles, in any order);
  • Disjunction (the element information items match one or more of the particles).

Each model group denotes a set of sequences of element information items. Regarding that set of sequences as a language, the set of sequences recognized by a group G may be written L ( G ). [Definition:]   A model group G is said to accept or recognize the members of L ( G ).

For detailed information on model groups, see Model Groups (§3.8) .

2.2.3.2 Particle

A particle is a term in the grammar for element content, consisting of either an element declaration, a wildcard or a model group, together with occurrence constraints. Particles contribute to · validation · as part of complex type definition · validation · , when they allow anywhere from zero to many element information items or sequences thereof, depending on their contents and occurrence constraints.

The name [Definition:]   Term is used to refer to any of the three kinds of components which can appear in particles. All · Terms · are themselves · Annotated Components · . [Definition:]   A basic term is an Element Declaration or a Wildcard . [Definition:]   A basic particle is a Particle whose {term} is a · basic term · .

Each content model, indeed each particle and each term, denotes a set of sequences of element information items. Regarding that set of sequences as a language, the set of sequences recognized by a particle P may be written L ( P ). [Definition:]   A particle P is said to accept or recognize the members of L ( P ). Similarly, a term T accepts or recognizes the members of L ( T ).

If a sequence S is a member of L ( P ), then it is necessarily possible to trace a path through the · basic particles · within P , with each item within S corresponding to a matching particle within P . The sequence of particles within P corresponding to S is called the · path · of S in P .

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

2.2.3.3 Attribute Use

An attribute use plays a role similar to that of a particle, but for attribute declarations: an attribute declaration within a complex type definition is embedded within an attribute use, which specifies whether the declaration requires or merely allows its attribute, and whether it has a default or fixed value.

2.2.3.4 Wildcard

A wildcard is a special kind of particle which matches element and attribute information items dependent on their namespace names and optionally on their local names.

For detailed information on wildcards, see Wildcards (§3.10) .

2.2.4 Constraint Components

This section describes constructs which use [XPath 2.0] expressions to constrain the input document; using them, certain rules can be expressed conveniently which would be inconvenient or impossible to express otherwise. Identity-constraint definitions are associated with element declarations; assertions are associated with type definitions; conditional type assignment using type alternatives allows the type of an element instance to be chosen based on properties of the element instance (in particular, based on the values of its attributes).

2.2.4.1 Identity-constraint Definition

An identity-constraint definition is an association between a name and one of several varieties of identity-constraint related to uniqueness and reference. All the varieties use [XPath 2.0] expressions to pick out sets of information items relative to particular target element information items which are unique, or a key, or a · valid · reference, within a specified scope. An element information item is only · valid · with respect to an element declaration with identity-constraint definitions if those definitions are all satisfied for all the descendants of that element information item which they pick out.

For detailed information on identity-constraint definitions, see Identity-constraint Definitions (§3.11) .

2.2.4.2 Type Alternative

A Type Alternative component (type alternative for short) associates a type definition with a predicate. Type alternatives are used in conditional type assignment, in which the choice of · governing type definition · for elements governed by a particular element declaration depends on properties of the document instance. An element declaration may have a {type table} which contains a sequence of type alternatives; the predicates on the alternatives are tested, and when a predicate is satisfied, the type definition paired with it is chosen as the element instance's · governing type definition · .

For detailed information on Type Alternatives, see Type Alternatives (§3.12) .

2.2.4.3 Assertion

An assertion is a predicate associated with a type, which is checked for each instance of the type. If an element or attribute information item fails to satisfy an assertion associated with a given type, then that information item is not locally · valid · with respect to that type.

For detailed information on Assertions, see Assertions (§3.13) .

2.2.4.4 Overlapping Functionality of Constraint Components

Many rules that can be enforced by identity constraints and conditional type assignment can also be formulated in terms of assertions. That is, the various constructs have overlapping functionality. The three forms of constraint differ from each other in various ways which may affect the schema author's choice of formulation.

Most obviously, the · post-schema-validation infoset · will differ somewhat, depending on which form of constraint is chosen.

Less obviously, identity constraints are associated with element declarations, while assertions are associated with type definitions. If it is desired to enforce a particular property of uniqueness or referential integrity associated with a particular element declaration E , of type T , the schema author may often choose either an identity constraint associated with E , or an assertion associated with T . One obvious difference is that elements substitutable for E are required to have types derived from T , but are not required to enforce the identity constraints (or the nillability) of E . If the constraint applicable to E should be enforced by elements substitutable for E , it is often most convenient to formulate the constraint as an assertion on T ; conversely, if only some elements of type T are intended to be subject to the constraint, or if elements substitutable for E need not enforce the constraint, then it will be more convenient to formulate the rule as an identity constraint on E .

Similar considerations sometimes apply to the choice between assertions and conditional type assignment.

Because identity constraints and conditional type assignment are simpler and less variable than assertions, it may be easier for software to exploit or optimize them. Assertions have greater expressive power, which means they are often convenient. The "rule of least power" applies here; it is often preferable to use a less expressive notation in preference to a more expressive one, when either will suffice. See [Rule of Least Power] .

2.2.5 Group Definition Components

There are two kinds of convenience definitions provided to enable the re-use of pieces of complex type definitions: model group definitions and attribute group definitions.

2.2.5.1 Model Group Definition

A model group definition is an association between a name and a model group, enabling re-use of the same model group in several complex type definitions.

For detailed information on model group definitions, see Model Group Definitions (§3.7) .

2.2.5.2 Attribute Group Definition

An attribute group definition is an association between a name and a set of attribute declarations, enabling re-use of the same set in several complex type definitions.

For detailed information on attribute group definitions, see Attribute Group Definitions (§3.6) .

2.2.6 Annotation Components

An annotation is information for human and/or mechanical consumers. The interpretation of such information is not defined in this specification.

For detailed information on annotations, see Annotations (§3.15) .

2.3 Constraints and Validation Rules

The [XML 1.1] specification describes two kinds of constraints on XML documents: well-formedness and validity constraints. Informally, the well-formedness constraints are those imposed by the definition of XML itself (such as the rules for the use of the < and > characters and the rules for proper nesting of elements), while validity constraints are the further constraints on document structure provided by a particular DTD.

The preceding section focused on · validation · , that is the constraints on information items which schema components supply. In fact however this specification provides four different kinds of normative statements about schema components, their representations in XML and their contribution to the · validation · of information items:

The last of these, schema information set contributions, are not as new as they might at first seem. XML validation augments the XML information set in similar ways, for example by providing values for attributes not present in instances, and by implicitly exploiting type information for normalization or access. (As an example of the latter case, consider the effect of NMTOKENS on attribute white space, and the semantics of ID and IDREF .) By including schema information set contributions, this specification makes explicit some features that XML leaves implicit.

2.4 Conformance

Within the context of this specification, conformance can be claimed for schema documents, for schemas, and for processors.

This specification describes three levels of conformance for schema aware processors. The first is required of all processors. Support for the other two will depend on the application environments for which the processor is intended.

[Definition:]   Minimally conforming processors must completely and correctly implement the · Schema Component Constraints · , · Validation Rules · , and · Schema Information Set Contributions · contained in this specification .

[Definition:]   · Minimally conforming · processors which accept schemas represented in the form of XML documents as described in Layer 2: Schema Documents, Namespaces and Composition (§4.2) are additionally said to be schema-document aware . Such processors must , when processing schema documents, completely and correctly implement (or enforce) all · Schema Representation Constraints · in this specification, and must adhere exactly to the specifications in Schema Component Details (§3) for mapping the contents of such documents to · schema components · for use in · validation · and · assessment · .

[Definition:]   A · minimally conforming · processor which is not · schema-document aware · is said to be a non-schema-document-aware processor.

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

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

2.5 Names and Symbol Spaces

As discussed in XSD Abstract Data Model (§2.2) , most schema components ( may ) have · names · . If all such names were assigned from the same "pool", then it would be impossible to have, for example, a simple type definition and an element declaration both with the name "title" in a given · target namespace · .

Therefore [Definition:]   this specification introduces the term symbol space to denote a collection of names, each of which is unique with respect to the others . There is a single distinct symbol space within a given · target namespace · for each kind of definition and declaration component identified in XSD Abstract Data Model (§2.2) , except that within a target namespace, simple type definitions and complex type definitions share a symbol space. Within a given symbol space, names must be unique, but the same name may appear in more than one symbol space without conflict. For example, the same name can appear in both a type definition and an element declaration, without conflict or necessary relation between the two.

Locally scoped attribute and element declarations are special with regard to symbol spaces. Every complex type definition defines its own local attribute and element declaration symbol spaces, where these symbol spaces are distinct from each other and from any of the other symbol spaces. So, for example, two complex type definitions having the same target namespace can contain a local attribute declaration for the unqualified name "priority", or contain a local element declaration for the name "address", without conflict or necessary relation between the two.

2.6 Schema-Related Markup in Documents Being Validated

XML Schema Definition Language: Structures defines several attributes for direct use in any XML documents. These attributes are in the schema instance namespace ( http://www.w3.org/2001/XMLSchema-instance ) described in The Schema Instance Namespace ( xsi ) (§1.3.1.2) above. All schema processors must have appropriate attribute declarations for these attributes built in, see Attribute Declaration for the 'type' attribute (§3.2.7.1) , Attribute Declaration for the 'nil' attribute (§3.2.7.2) , Attribute Declaration for the 'schemaLocation' attribute (§3.2.7.3) and Attribute Declaration for the 'noNamespaceSchemaLocation' attribute (§3.2.7.4) .

2.6.1 xsi:type

The Simple Type Definition (§2.2.1.2) or Complex Type Definition (§2.2.1.3) used in · validation · of an element is usually determined by reference to the appropriate schema components. An element information item in an instance may , however, explicitly assert its type using the attribute xsi:type . The value of this attribute is a · QName · ; see QName resolution (Instance) (§3.17.6.3) for the means by which the · QName · is associated with a type definition.

2.6.2 xsi:nil

XML Schema Definition Language: Structures introduces a mechanism for signaling that an element must be accepted as · valid · when it has no content despite a content type which does not require or even necessarily allow empty content. An element can be · valid · without content if it has the attribute xsi:nil with the value true . An element so labeled must be empty, but can carry attributes if permitted by the corresponding complex type.

2.6.3 xsi:schemaLocation, xsi:noNamespaceSchemaLocation

The xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes can be used in a document to provide hints as to the physical location of schema documents which can be used for · assessment · . See How schema definitions are located on the Web (§4.3.2) for details on the use of these attributes.

2.7 Representation of Schemas on the World Wide Web

On the World Wide Web, schemas are conventionally represented as XML documents (preferably of MIME type application/xml or text/xml , but see clause 1.1 of Inclusion Constraints and Semantics (§4.2.2) ), conforming to the specifications in Layer 2: Schema Documents, Namespaces and Composition (§4.2) . For more information on the representation and use of schema documents on the World Wide Web see Standards for representation of schemas and retrieval of schema documents on the Web (§4.3.1) and How schema definitions are located on the Web (§4.3.2) .

3 Schema Component Details

3.1 introduction.

  • properties: their values and significance
  • XML representation and the mapping to properties
  • constraints on representation
  • validation rules
  • · post-schema-validation infoset · contributions
  • constraints on the components themselves

3.1.1 Components and Properties

Components are defined in terms of their properties, and each property in turn is defined by giving its range, that is the values it may have. This can be understood as defining a schema as a labeled directed graph, where the root is a schema, every other vertex is a schema component or a literal (string, boolean, decimal) and every labeled edge is a property. The graph is not acyclic: multiple copies of components with the same name in the same · symbol space · must not exist, so in some cases re-entrant chains of properties will exist.

Component properties are simply named values. Most properties have either other components or literals (that is, strings or booleans or enumerated keywords) for values, but in a few cases, where more complex values are involved, [Definition:]   a property value may itself be a collection of named values, which we call a property record .

[Definition:]   Throughout this specification, the term absent is used as a distinguished property value denoting absence . Again this should not be interpreted as constraining implementations, as for instance between using a null value for such properties or not representing them at all. [Definition:]   A property value which is not · absent · is present .

Any property not defined as optional is always present; optional properties which are not present are taken to have · absent · as their value. Any property identified as a having a set, subset or list value might have an empty value unless this is explicitly ruled out: this is not the same as · absent · . Any property value identified as a superset or subset of some set might be equal to that set, unless a proper superset or subset is explicitly called for. By 'string' in Part 1 of this specification is meant a sequence of ISO 10646 characters identified as legal XML characters in [XML 1.1] .

3.1.2 XML Representations of Components

The principal purpose of XML Schema Definition Language: Structures is to define a set of schema components that constrain the contents of instances and augment the information sets thereof. Although no external representation of schemas is required for this purpose, such representations will obviously be widely used. To provide for this in an appropriate and interoperable way, this specification provides a normative XML representation for schemas which makes provision for every kind of schema component. [Definition:]   A document in this form (i.e. a <schema> element information item) is a schema document . For the schema document as a whole, and its constituents, the sections below define correspondences between element information items (with declarations in Schema for Schema Documents (Structures) (normative) (§A) and DTD for Schemas (non-normative) (§J) ) and schema components. The key element information items in the XML representation of a schema are in the XSD namespace, that is their [namespace name] is http://www.w3.org/2001/XMLSchema . Although a common way of creating the XML Infosets which are or contain · schema documents · will be using an XML parser, this is not required: any mechanism which constructs conformant infosets as defined in [XML Infoset] is a possible starting point.

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

A recurrent pattern in the XML representation of schemas may also be mentioned here. In many cases, the same element name (e.g. element or attribute or attributeGroup ), serves both to define a particular schema component and to incorporate it by reference. In the first case the name attribute is required, in the second the ref attribute is required. These two usages are mutually exclusive, and sometimes also depend on context.

The descriptions of the XML representation of components, and the · Schema Representation Constraints · , apply to schema documents after , not before, the conditional-inclusion pre-processing described in Conditional inclusion (§4.2.1) .

3.1.3 The Mapping between XML Representations and Components

For each kind of schema component there is a corresponding normative XML representation. The sections below describe the correspondences between the properties of each kind of schema component on the one hand and the properties of information items in that XML representation on the other, together with constraints on that representation above and beyond those expressed in the Schema for Schema Documents (Structures) (normative) (§A) .

The language used is as if the correspondences were mappings from XML representation to schema component, but the mapping in the other direction, and therefore the correspondence in the abstract, can always be constructed therefrom.

In discussing the mapping from XML representations to schema components below, the value of a component property is often determined by the value of an attribute information item, one of the [attributes] of an element information item. Since schema documents are constrained by the Schema for Schema Documents (Structures) (normative) (§A) , there is always a simple type definition associated with any such attribute information item. [Definition:]   With reference to any string, interpreted as denoting an instance of a given datatype, the term actual value denotes the value to which the lexical mapping of that datatype maps the string. In the case of attributes in schema documents, the string used as the lexical representation is normally the · normalized value · of the attribute. The associated datatype is, unless otherwise specified, the one identified in the declaration of the attribute, in the schema for schema documents; in some cases (e.g. the enumeration facet, or fixed and default values for elements and attributes) the associated datatype will be a more specific one, as specified in the appropriate XML mapping rules. The · actual value · will often be a string, but can also be an integer, a boolean, a URI reference, etc. This term is also occasionally used with respect to element or attribute information items in a document being · validated · .

Many properties are identified below as having other schema components or sets of components as values. For the purposes of exposition, the definitions in this section assume that (unless the property is explicitly identified as optional) all such values are in fact present. When schema components are constructed from XML representations involving reference by name to other components, this assumption will in some cases be violated if one or more references cannot be · resolved · . This specification addresses the matter of missing components in a uniform manner, described in Missing Sub-components (§5.3) : no mention of handling missing components will be found in the individual component descriptions below.

Forward reference to named definitions and declarations is allowed, both within and between · schema documents · . By the time the component corresponding to an XML representation which contains a forward reference is actually needed for · validation · , it is possible that an appropriately-named component will have become available to discharge the reference: see Schemas and Namespaces: Access and Composition (§4) for details.

3.1.4 White Space Normalization during Validation

Throughout this specification, [Definition:]   the initial value of some attribute information item is the value of the [normalized value] property of that item. Similarly, the initial value of an element information item is the string composed of, in order, the [character code] of each character information item in the [children] of that element information item .

The above definition means that comments and processing instructions, even in the midst of text, are ignored for all · validation · purposes.

When more than one pre-lexical facet applies, the whiteSpace facet is applied first; the order in which · implementation-defined · facets are applied is · implementation-defined · .

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

There are three alternative validation rules which help supply the necessary background for the above: Attribute Locally Valid (§3.2.4.1) (clause 3 ), Element Locally Valid (Type) (§3.3.4.4) (clause 3.1.3 ) or Element Locally Valid (Complex Type) (§3.4.4.2) (clause 1.2 ).

These three levels of normalization correspond to the processing mandated in XML for element content, CDATA attribute content and tokenized attributed content, respectively. See Attribute Value Normalization in [XML 1.1] for the precedent for replace and collapse for attributes. Extending this processing to element content is necessary to ensure consistent · validation · semantics for simple types, regardless of whether they are applied to attributes or elements. Performing it twice in the case of attributes whose [normalized value] has already been subject to replacement or collapse on the basis of information in a DTD is necessary to ensure consistent treatment of attributes regardless of the extent to which DTD-based information has been made use of during infoset construction.

3.2 Attribute Declarations

Attribute declarations provide for:

  • Local · validation · of attribute information item values using a simple type definition;
  • Specifying default or fixed values for attribute information items.

3.2.1 The Attribute Declaration Schema Component

The attribute declaration schema component has the following properties:

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

The value of each attribute validated must conform to the supplied {type definition} .

A · non-absent · value of the {target namespace} property provides for · validation · of namespace-qualified attribute information items (which must be explicitly prefixed in the character-level form of XML documents). · Absent · values of {target namespace} · validate · unqualified (unprefixed) items.

For an attribute declaration A , if A . {scope} . {variety} = global , then A is available for use throughout the schema. If A . {scope} . {variety} = local , then A is available for use only within (the Complex Type Definition or Attribute Group Definition ) A . {scope} . {parent} .

The {value constraint} property reproduces the functions of XML default and #FIXED attribute values. A {variety} of default specifies that the attribute is to appear unconditionally in the · post-schema-validation infoset · , with {value} and {lexical form} used whenever the attribute is not actually present; fixed indicates that the attribute value if present must be equal to {value} , and if absent receives {value} and {lexical form} as for default . Note that it is values that are checked, not strings, and that the test is for equality, not identity.

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

[XML Infoset] distinguishes attributes with names such as xmlns or xmlns:xsl from ordinary attributes, identifying them as [namespace attributes] . Accordingly, it is unnecessary and in fact not possible for schemas to contain attribute declarations corresponding to such namespace declarations, see xmlns Not Allowed (§3.2.6.3) . No means is provided in this specification to supply a default value for a namespace declaration.

3.2.2 XML Representation of Attribute Declaration Schema Components

The XML representation for an attribute declaration schema component is an <attribute> element information item. It specifies a simple type definition for an attribute either by reference or explicitly, and may provide default information. The correspondences between the properties of the information item and properties of the component are given in this section.

Attribute declarations can appear at the top level of a schema document, or within complex type definitions, either as complete (local) declarations, or by reference to top-level declarations, or within attribute group definitions. For complete declarations, top-level or local, the type attribute is used when the declaration can use a built-in or pre-declared simple type definition. Otherwise an anonymous <simpleType> is provided inline. When no simple type definition is referenced or provided, the default is · xs:anySimpleType · , which imposes no constraints at all.

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

An <attribute> element maps to an attribute declaration, and allows the type definition of that declaration to be specified either by reference or by explicit inclusion.

Top-level <attribute> elements (i.e. those which appear within the schema document as children of <schema> elements) produce global attribute declarations; <attribute> s within <attributeGroup> or <complexType> produce either attribute uses which contain global attribute declarations (if there's a ref attribute) or local declarations (otherwise). For complete declarations, top-level or local, the type attribute is used when the declaration can use a built-in or user-defined global type definition. Otherwise an anonymous <simpleType> is provided inline.

Attribute information items · validated · by a top-level declaration must be qualified with the {target namespace} of that declaration. If the {target namespace} is · absent · , the item must be unqualified. Control over whether attribute information items · validated · by a local declaration must be similarly qualified or not is provided by the form [attribute] , whose default is provided by the attributeFormDefault [attribute] on the enclosing <schema> , via its determination of {target namespace} .

The names for top-level attribute declarations are in their own · symbol space · . The names of locally-scoped attribute declarations reside in symbol spaces local to the type definition which contains them.

  • If the <attribute> element information item has <schema> as its parent, then it maps to a global Attribute Declaration as described in Mapping Rules for Global Attribute Declarations (§3.2.2.1) .
  • If the <attribute> element information item has <complexType> or <attributeGroup> as an ancestor, and the ref [attribute] is absent, and the use [attribute] is not "prohibited" , then it maps both to an Attribute Declaration and to an Attribute Use component, as described in Mapping Rules for Local Attribute Declarations (§3.2.2.2) . On Attribute Use components, see Attribute Uses (§3.5) .
  • If the <attribute> element information item has <complexType> or <attributeGroup> as an ancestor, and the ref [attribute] is · present · , and the use [attribute] is not "prohibited" , then it maps to an Attribute Use component, as described in Mapping Rules for References to Top-level Attribute Declarations (§3.2.2.3) .
  • If the <attribute> element information item has use='prohibited' , then it does not map to, or correspond to, any schema component at all. Note: The use attribute is not allowed on top-level <attribute> elements, so this can only happen with <attribute> elements appearing within a <complexType> or <attributeGroup> element.

3.2.2.1 Mapping Rules for Global Attribute Declarations

If the <attribute> element information item has <schema> as its parent, the corresponding schema component is as follows:

3.2.2.2 Mapping Rules for Local Attribute Declarations

If the <attribute> element information item has <complexType> or <attributeGroup> as an ancestor and the ref [attribute] is absent, it maps both to an attribute declaration (see below) and to an attribute use with properties as follows (unless use='prohibited' , in which case the item corresponds to nothing at all):

The <attribute> element also maps to the {attribute declaration} of the attribute use just described, as follows:

3.2.2.3 Mapping Rules for References to Top-level Attribute Declarations

If the <attribute> element information item has <complexType> or <attributeGroup> as an ancestor and the ref [attribute] is present, it maps to an attribute use with properties as follows (unless use='prohibited' , in which case the item corresponds to nothing at all):

3.2.3 Constraints on XML Representations of Attribute Declarations

3.2.4 attribute declaration validation rules, 3.2.4.1 attribute locally valid.

Informally, an attribute in an XML instance is locally · valid · against an attribute declaration if and only if (a) the name of the attribute matches the name of the declaration, (b) after whitespace normalization its · normalized value · is locally valid against the type declared for the attribute, and (c) the attribute obeys any relevant value constraint. Additionally, for xsi:type , it is required that the type named by the attribute be present in the schema. A logical prerequisite for checking the local validity of an attribute against an attribute declaration is that the attribute declaration itself and the type definition it identifies both be present in the schema.

Local validity of attributes is tested as part of schema-validity · assessment · of attributes (and of the elements on which they occur), and the result of the test is exposed in the [validity] property of the · post-schema-validation infoset · .

A more formal statement is given in the following constraint.

3.2.4.2 Governing Attribute Declaration and Governing Type Definition

[Definition:]   The governing type definition of an attribute, in a given schema-validity · assessment · episode, is the {type definition} of the · governing attribute declaration · , unless the processor has stipulated another type definition at the start of · assessment · (see Assessing Schema-Validity (§5.2) ), in which case it is the stipulated type definition.

3.2.4.3 Schema-Validity Assessment (Attribute)

Schema-validity assessment of an attribute information item involves identifying its · governing attribute declaration · and checking its local validity against the declaration. If the · governing type definition · is not present in the schema, then assessment is necessarily incomplete.

[Definition:]   For attribute information items, there is no difference between assessment and strict assessment, so the attribute information item has been strictly assessed if and only if its schema-validity has been assessed.

3.2.5 Attribute Declaration Information Set Contributions

3.2.5.1 assessment outcome (attribute), 3.2.5.2 validation failure (attribute), 3.2.5.3 attribute declaration, 3.2.5.4 attribute validated by type.

See also Attribute Default Value (§3.4.5.1) , Match Information (§3.4.5.2) and Schema Information (§3.17.5.1) , which describe other information set contributions related to attribute information items.

3.2.6 Constraints on Attribute Declaration Schema Components

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

3.2.6.1 Attribute Declaration Properties Correct

3.2.6.2 simple default valid, 3.2.6.3 xmlns not allowed, 3.2.6.4 xsi: not allowed, 3.2.7 built-in attribute declarations.

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

3.2.7.1 xsi:type

The xsi:type attribute is used to signal use of a type other than the declared type of an element. See xsi:type (§2.6.1) .

3.2.7.2 xsi:nil

The xsi:nil attribute is used to signal that an element's content is "nil" (or "null"). See xsi:nil (§2.6.2) .

3.2.7.3 xsi:schemaLocation

The xsi:schemaLocation attribute is used to signal possible locations of relevant schema documents. See xsi:schemaLocation, xsi:noNamespaceSchemaLocation (§2.6.3) .

3.2.7.4 xsi:noNamespaceSchemaLocation

The xsi:noNamespaceSchemaLocation attribute is used to signal possible locations of relevant schema documents. See xsi:schemaLocation, xsi:noNamespaceSchemaLocation (§2.6.3) .

3.3 Element Declarations

Element declarations provide for:

  • Local · validation · of element information item values using a type definition;
  • Specifying default or fixed values for element information items;
  • Establishing uniquenesses and reference constraint relationships among the values of related elements and attributes;
  • Controlling the substitutability of elements through the mechanism of · element substitution groups · .

3.3.1 The Element Declaration Schema Component

The element declaration schema component has the following properties:

A subset of { substitution , extension , restriction }.

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

For an element declaration E , if E . {scope} . {variety} = global , then E is available for use throughout the schema. If E . {scope} . {variety} = local , then E is available for use only within (the Complex Type Definition or Model Group Definition ) E . {scope} . {parent} .

A · non-absent · value of the {target namespace} property provides for · validation · of namespace-qualified element information items. · Absent · values of {target namespace} · validate · unqualified items.

An element information item is normally required to satisfy the {type definition} . For such an item, schema information set contributions appropriate to the {type definition} are added to the corresponding element information item in the · post-schema-validation infoset · . The type definition against which an element information item is validated (its · governing type definition · ) can be different from the declared {type definition} . The {type table} property of an Element Declaration , which governs conditional type assignment, and the xsi:type attribute of an element information item (see xsi:type (§2.6.1) ) can cause the · governing type definition · and the declared {type definition} to be different.

If {nillable} is true , then an element with no text or element content can be · valid · despite a {type definition} which would otherwise require content, if it carries the attribute xsi:nil with the value true (see xsi:nil (§2.6.2) ). Formal details of element · validation · are described in Element Locally Valid (Element) (§3.3.4.3) .

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

{identity-constraint definitions} express constraints establishing uniquenesses and reference relationships among the values of related elements and attributes. See Identity-constraint Definitions (§3.11) .

The {substitution group affiliations} property of an element declaration indicates which · substitution groups · , if any, it can potentially be a member of. Potential membership is transitive but not symmetric; an element declaration is a potential member of any group named in its {substitution group affiliations} , and also of any group of which any entry in its {substitution group affiliations} is a potential member. Actual membership may be blocked by the effects of {substitution group exclusions} or {disallowed substitutions} , see below.

An empty {substitution group exclusions} allows a declaration to be named in the {substitution group affiliations} of other element declarations having the same declared {type definition} or some type · derived · therefrom. The explicit values of {substitution group exclusions} , extension or restriction , rule out element declarations having types whose derivation from {type definition} involves any extension steps, or restriction steps, respectively .

The supplied values for {disallowed substitutions} determine whether an element declaration appearing in a · content model · will be prevented from additionally · validating · elements (a) with an xsi:type (§2.6.1) that identifies an extension or restriction of the type of the declared element, and/or (b) from · validating · elements which are in the · substitution group · headed by the declared element. If {disallowed substitutions} is empty, then all · derived · types and · substitution group · members are allowed.

Element declarations for which {abstract} is true can appear in content models only when substitution is allowed; such declarations must not themselves ever be used to · validate · element content.

3.3.2 XML Representation of Element Declaration Schema Components

The XML representation for an element declaration schema component is an <element> element information item. It specifies a type definition for an element either by reference or explicitly, and may provide occurrence and default information. The correspondences between the properties of the information item and properties of the component(s) it corresponds to are given in this section.

<element   abstract = boolean  : false   block = ( #all | List of ( extension | restriction | substitution ))   default = string   final = ( #all | List of ( extension | restriction ))   fixed = string   form = ( qualified | unqualified )   id = ID   maxOccurs = ( nonNegativeInteger | unbounded )  : 1   minOccurs = nonNegativeInteger  : 1   name = NCName   nillable = boolean  : false   ref = QName   substitutionGroup = List of QName   targetNamespace = anyURI   type = QName    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, (( simpleType | complexType )?, alternative *, ( unique | key | keyref )*)) </element>

An <element> element information item in a schema document maps to an element declaration and allows the type definition of that declaration to be specified either by reference or by explicit inclusion.

Top-level <element> elements (i.e. those which appear within the schema document as children of <schema> elements) produce global element declarations; <element> s within <group> or <complexType> produce either particles which contain global element declarations (if there's a ref attribute) or local declarations (otherwise). For complete declarations, top-level or local, the type attribute is used when the declaration can use a built-in or user-defined global type definition. Otherwise an anonymous <simpleType> or <complexType> is provided inline.

Element information items · validated · by a top-level declaration must be qualified with the {target namespace} of that declaration. If the {target namespace} is · absent · , the item must be unqualified. Control over whether element information items · validated · by a local declaration must be similarly qualified or not is provided by the form [attribute] , whose default is provided by the elementFormDefault [attribute] on the enclosing <schema> , via its determination of {target namespace} .

The names for top-level element declarations are in a separate · symbol space · from the symbol spaces for the names of type definitions, so there can (but need not be) a simple or complex type definition with the same name as a top-level element. As with attribute names, the names of locally-scoped element declarations with no {target namespace} reside in symbol spaces local to the type definition which contains them.

Note that the above allows for two levels of defaulting for unspecified type definitions. An <element> with no referenced or included type definition will correspond to an element declaration which has the same type definition as the first substitution-group head named in the substitutionGroup [attribute] , if present, otherwise · xs:anyType · . This has the important consequence that the minimum valid element declaration, that is, one with only a name attribute and no contents, is also (nearly) the most general, validating any combination of text and element content and allowing any attributes, and providing for recursive validation where possible.

See XML Representation of Identity-constraint Definition Schema Components (§3.11.2) for <key> , <unique> and <keyref> .

  • If the <element> element information item has <schema> as its parent, it maps to an Element Declaration using the mappings described in Common Mapping Rules for Element Declarations (§3.3.2.1) and Mapping Rules for Top-Level Element Declarations (§3.3.2.2) .
  • If the <element> element information item has <complexType> or <group> as an ancestor, and the ref [attribute] is absent, and it does not have minOccurs=maxOccurs=0 , then it maps both to a Particle , as described in Mapping Rules for Local Element Declarations (§3.3.2.3) , and also to an Element Declaration , using the mappings described in Common Mapping Rules for Element Declarations (§3.3.2.1) and Mapping Rules for Local Element Declarations (§3.3.2.3) .
  • If the <element> element information item has <complexType> or <group> as an ancestor, and the ref [attribute] is present, and it does not have minOccurs=maxOccurs=0 , then it maps to a Particle as described in References to Top-Level Element Declarations (§3.3.2.4) .
  • If the <element> element information item has minOccurs=maxOccurs=0 , then it maps to no component at all. Note: The minOccurs and maxOccurs attributes are not allowed on top-level <element> elements, so in valid schema documents this will happen only when the <element> element information item has <complexType> or <group> as an ancestor.

3.3.2.1 Common Mapping Rules for Element Declarations

The following mapping rules apply in all cases where an <element> element maps to an Element Declaration component.

3.3.2.2 Mapping Rules for Top-Level Element Declarations

If the <element> element information item has <schema> as its parent, it maps to a global Element Declaration , using the mapping given in Common Mapping Rules for Element Declarations (§3.3.2.1) , supplemented by the following.

3.3.2.3 Mapping Rules for Local Element Declarations

If the <element> element information item has <complexType> or <group> as an ancestor, and the ref [attribute] is absent, and it does not have minOccurs=maxOccurs=0 , then it maps both to a Particle and to a local Element Declaration which is the {term} of that Particle . The Particle is as follows:

The <element> element also maps to an element declaration using the mapping rules given in Common Mapping Rules for Element Declarations (§3.3.2.1) , supplemented by those below:

3.3.2.4 References to Top-Level Element Declarations

If the <element> element information item has <complexType> or <group> as an ancestor, and the ref [attribute] is present, and it does not have minOccurs=maxOccurs=0 , then it maps to a Particle as follows.

3.3.2.5 Examples of Element Declarations

3.3.3 constraints on xml representations of element declarations, 3.3.4 element declaration validation rules.

When an element is · assessed · , it is first checked against its · governing element declaration · , if any; this in turn entails checking it against its · governing type definition · . The second step is recursive: the element's [attributes] and [children] are · assessed · in turn with respect to the declarations assigned to them by their parent's · governing type definition · .

3.3.4.1 Selected and Instance-specified Type Definitions

The · governing type definition · of an element is normally the declared {type definition} associated with the · governing element declaration · , but this may be · overridden · using conditional type assignment in the Element Declaration or using an · instance-specified type definition · , or both. When the element is declared with conditional type assignment, the · selected type definition · is used as the · governing type definition · unless · overridden · by an · instance-specified type definition · .

3.3.4.2 Type Override and Valid Substitutability

  • S and T are both complex type definitions and S is validly derived from T subject to the blocking keywords in the union of K and T . {prohibited substitutions} , as defined in Type Derivation OK (Complex) (§3.4.6.5)
  • S is a complex type definition, T is a simple type definition, and S is validly · derived · from T subject to the blocking keywords in K , as defined in Type Derivation OK (Complex) (§3.4.6.5)
  • S is a simple type definition and S is validly · derived · from T subject to the blocking keywords in K , as defined in Type Derivation OK (Simple) (§3.16.6.3) .

[Definition:]   If the set of keywords controlling whether a type S is · validly substitutable · for another type T is the empty set, then S is said to be validly substitutable for T without limitation or absolutely . The phrase validly substitutable , without mention of any set of blocking keywords, means "validly substitutable without limitation".

Sometimes one type S is · validly substitutable · for another type T only if S is derived from T by a chain of restrictions, or if T is a union type and S a member type of the union. The concept of · valid substitutability · is appealed to often enough in such contexts that it is convenient to define a term to cover this specific case. [Definition:]   A type definition S is validly substitutable as a restriction for another type T if and only if S is · validly substitutable · for T , subject to the blocking keywords { extension , list , union }.

3.3.4.3 Element Locally Valid (Element)

The concept of local validity of an element information item against an element declaration is an important part of the schema-validity · assessment · of elements. (The other important part is the recursive · assessment · of attributes and descendant elements.) Local validity partially determines the element information item's [validity] property, and fully determines the [local element validity] property, in the · post-schema-validation infoset · .

  • The declaration is present in the schema and the name of the element matches the name of the declaration.
  • The element is declared concrete (i.e. not abstract).
  • Any xsi:nil attribute on the element obeys the rules. The element is allowed to have an xsi:nil attribute only if the element is declared nillable, and xsi:nil = 'true' is allowed only if the element itself is empty. If the element declaration specifies a fixed value for the element, xsi:nil='true' will make the element invalid.
  • Any xsi:type attribute present names a type which is · validly substitutable · for the element's declared {type definition} .
  • The element's content satisfies the appropriate constraints: If the element is empty and the declaration specifies a default value, the default is checked against the appropriate type definitions. Otherwise, the content of the element is checked against the · governing type definition · ; additionally, if the element declaration specifies a fixed value, the content is checked against that value.
  • The element satisfies all the identity constraints specified on the element declaration.
  • Additionally, on the · validation root · , document-level ID and IDREF constraints are checked.

The following validation rule gives the normative formal definition of local validity of an element against an element declaration.

3.3.4.4 Element Locally Valid (Type)

The following validation rule specifies formally what it means for an element to be locally valid against a type definition. This concept is appealed to in the course of checking an element's local validity against its · governing type definition · . It is also part of schema-validity · assessment · of an element when the element is · laxly assessed · , by checking its local validity against xs:anyType .

Informally, local validity against a type requires first that the type definition be present in the schema and not declared abstract. For a simple type definition, the element must lack attributes (except for namespace declarations and the special attributes in the xsi namespace) and child elements, and must be type-valid against that simple type definition. For a complex type definition, the element must be locally valid against that complex type definition. Also, if the element has an xsi:type attribute, then it is not locally valid against any type other than the one named by that attribute.

3.3.4.5 Validation Root Valid (ID/IDREF)

The following validation rule specifies document-level ID/IDREF constraints checked on the · validation root · if it is an element; this rule is not checked on other elements. Informally, the requirement is that each ID identifies a single element within the · validation root · , and that each IDREF value matches one ID.

3.3.4.6 Schema-Validity Assessment (Element)

  • Assessment begins with the identification of a · governing element declaration · for the element and then checks that the element is locally valid against the declaration; if no · governing element declaration · is available, a · governing type definition · can be used instead.
  • The element's attributes are to be · assessed · recursively, unless they match a skip wildcard and are thus · skipped · .
  • The element's children are to be · assessed · recursively, unless they match a skip wildcard and are thus · skipped · . For each child element, the · governing element declaration · is the one identified in the course of checking the local validity of the parent, unless that declaration is not available. If the · governing element declaration · is not available, the element may still be · strictly assessed · if a · governing type definition · can be identified (e.g. via the xsi:type attribute), otherwise the element will be · laxly assessed · .

3.3.5 Element Declaration Information Set Contributions

3.3.5.1 assessment outcome (element), 3.3.5.2 validation failure (element), 3.3.5.3 element declaration, 3.3.5.4 element validated by type.

  • declared if the element information item has a · governing element declaration · which has no {type table} , and also an xsi:type attribute which fails to · resolve · to a type definition that · overrides · the declared {type definition}
  • selected if the element information item has a · governing element declaration · with a {type table} and also has an xsi:type attribute which fails to · resolve · to a type definition that · overrides · the · selected type definition ·
  • lax if the element was · laxly assessed · using · xs:anyType ·
  • none otherwise

3.3.5.5 Element Default Value

See also Match Information (§3.4.5.2) , Identity-constraint Table (§3.11.5) , Validated with Notation (§3.14.5) , and Schema Information (§3.17.5.1) , which describe other information set contributions related to element information items.

3.3.5.6 Inherited Attributes

3.3.6 constraints on element declaration schema components.

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

3.3.6.1 Element Declaration Properties Correct

3.3.6.2 element default valid (immediate).

This and the following sections define relations appealed to elsewhere in this specification.

3.3.6.3 Substitution Group OK (Transitive)

3.3.6.4 substitution group.

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

[Definition:]   Every element declaration (call this HEAD ) in the {element declarations} of a schema defines a substitution group , a subset of those {element declarations} . An element declaration is in the substitution group of HEAD if and only if it is · substitutable · for HEAD .

3.4 Complex Type Definitions

Complex Type Definitions provide for:

  • Constraining element information items by providing Attribute Declaration (§2.2.2.3) s governing the appearance and content of [attributes]
  • Constraining element information item [children] to be empty, or to conform to a specified element-only or mixed content model, or else constraining the character information item [children] to conform to a specified simple type definition.
  • Constraining elements and attributes to exist, not to exist, or to have specified values, with Assertion (§2.2.4.3) s.
  • Using the mechanisms of Type Definition Hierarchy (§2.2.1.1) to · derive · a complex type from another simple or complex type.
  • Specifying · post-schema-validation infoset contributions · for elements.
  • Limiting the ability to · derive · additional types from a given complex type.
  • Controlling the permission to substitute, in an instance, elements of a · derived · type for elements declared in a content model to be of a given complex type.

3.4.1 The Complex Type Definition Schema Component

A complex type definition schema component has the following properties:

A subset of { extension , restriction }.

Either an Element Declaration or a Complex Type Definition .

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

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

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

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

Complex types for which {abstract} is true have no valid instances and thus cannot be used in the normal way as the {type definition} for the · validation · of element information items (if for some reason an abstract type is identified as the · governing type definition · of an element information item, the item will invariably be invalid). It follows that such abstract types must not be referenced from an xsi:type (§2.6.1) attribute in an instance document. Abstract complex types can be used as {base type definition} s, or even as the declared {type definition} s of element declarations, provided in every case a concrete · derived · type definition is used for · validation · , either via xsi:type (§2.6.1) or the operation of a · substitution group · .

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

{attribute wildcard} s provide a more flexible specification for · validation · of attributes not explicitly included in {attribute uses} . See Element Locally Valid (Complex Type) (§3.4.4.2) , The Wildcard Schema Component (§3.10.1) and Wildcard allows Expanded Name (§3.10.4.2) for formal details of attribute wildcard · validation · .

  • A {content type} with {variety} empty · validates · elements with no character or element information item [children] .
  • A {content type} with {variety} simple · validates · elements with character-only [children] using its {simple type definition} .
  • A {content type} with {variety} element-only · validates · elements with [children] that conform to the · content model · supplied by its {particle} .
  • A {content type} with {variety} mixed · validates · elements whose element [children] (i.e. specifically ignoring other [children] such as character information items) conform to the · content model · supplied by its {particle} .
  • A {content type} with · non-absent · {open content} · validates · elements with some [children] conforming to the · content model · and others conforming to the {open content} .
  • as the · governing type definition · of an element instance E , when T is the · selected type definition · of E (often, the declared {type definition} of E 's · governing element declaration · ); this can occur when E specifies a type definition using the xsi:type attribute; see xsi:type (§2.6.1) ;
  • as the · selected type definition · of an element instance E , when T is the declared {type definition} of E 's · governing element declaration · ; this can occur when conditional type assignment is used; see Type Alternatives (§3.12) ;
  • as the · governing type definition · of element instances whose · governing element declaration · is included in a model group only · implicitly · , by virtue of being included in the · substitution group · of some element declaration present · directly · · indirectly · in the model group, whose declared {type definition} is T .
  • E1 is contained in a Complex Type Definition D
  • D is derived from another Complex Type Definition B
  • B contains an Element Declaration E2 that has the same expanded name as E1
  • E2 has T as its {type definition} .

Editorial Note: Priority Feedback Request

In version 1.0 of this specification, {prohibited substitutions} of a Complex Type Definition is only used when type substitution ( xsi:type ) or element substitution (substitution groups) appear in the instance document. It has been changed to take effect whenever complex type derivation is checked, including cases beyond type and element substitutions in instance documents. In particular, it affects clause 4 of Element Declaration Properties Correct (§3.3.6.1) , clause 2.1 of Conditional Type Substitutable (§3.4.4.5) , clause 1.6 of Derivation Valid (Extension) (§3.4.6.2) , clause 4 of Derivation Valid (Restriction, Complex) (§3.4.6.3) , and clause 4.5 of Content type restricts (Complex Content) (§3.4.6.4) . Because of the consideration of {prohibited substitutions} , existing schemas may be rendered invalid by the above rules. The XML Schema Working Group solicits input from implementors and users of this specification as to whether this change is desirable and acceptable.

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

3.4.2 XML Representation of Complex Type Definition Schema Components

The XML representation for a complex type definition schema component is a <complexType> element information item.

The XML representation for complex type definitions with a {content type} with {variety} simple is significantly different from that of those with other {content type} s, and this is reflected in the presentation below, which describes the mappings for the two cases in separate subsections. Common mapping rules are factored out and given in separate sections.

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

  • Mapping Rules for Complex Types with Simple Content (§3.4.2.2) ,
  • Common Mapping Rules for Complex Type Definitions (§3.4.2.1) ,
  • Mapping Rule for Attribute Uses Property (§3.4.2.4) , and
  • Mapping Rule for Attribute Wildcard Property (§3.4.2.5) .
  • Mapping Rules for Complex Types with Explicit Complex Content (§3.4.2.3.1) ,
  • Mapping Rules for Content Type Property of Complex Content (§3.4.2.3.3) ,
  • Mapping Rules for Complex Types with Implicit Complex Content (§3.4.2.3.2) ,

Where convenient, the mapping rules are described exclusively in terms of the schema document's information set. The mappings, however, depend not only upon the source declaration but also upon the schema context. Some mappings, that is, depend on the properties of other components in the schema. In particular, several of the mapping rules given in the following sections depend upon the {base type definition} having been identified before they apply.

3.4.2.1 Common Mapping Rules for Complex Type Definitions

Whichever alternative for the content of <complexType> is chosen, the following property mappings apply. Except where otherwise specified, attributes and child elements are to be sought among the [attributes] and [children] of the <complexType> element.

3.4.2.2 Mapping Rules for Complex Types with Simple Content

When the <complexType> source declaration has a <simpleContent> child, the following elements are relevant (as are <attribute> , <attributeGroup> , and <anyAttribute> ), and the property mappings are as below, supplemented by the mappings in Common Mapping Rules for Complex Type Definitions (§3.4.2.1) , Mapping Rule for Attribute Uses Property (§3.4.2.4) , and Mapping Rule for Attribute Wildcard Property (§3.4.2.5) . Note that either <restriction> or <extension> must appear in the content of <simpleContent> .

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

<restriction    base = QName   id = ID    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, ( simpleType ?, ( minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | maxScale | minScale | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion | {any with namespace: ##other} )*)?, (( attribute | attributeGroup )*, anyAttribute ?), assert *) </restriction>

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

When the <complexType> element has a <simpleContent> child, then the <complexType> element maps to a complex type with simple content, as follows.

3.4.2.3 Mapping Rules for Complex Types with Complex Content

When the <complexType> element does not have a <simpleContent> child element, then it maps to a complex type with complex content. The following elements are relevant (as are the <attribute> , <attributeGroup> , and <anyAttribute> elements, not repeated here), and the additional property mappings are as below, supplemented by the mappings in Common Mapping Rules for Complex Type Definitions (§3.4.2.1) , Mapping Rule for Attribute Uses Property (§3.4.2.4) , and Mapping Rule for Attribute Wildcard Property (§3.4.2.5) . Note that either <restriction> or <extension> must appear in the content of <complexContent> , but their content models are different in this case from the case above when they occur as children of <simpleContent> .

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

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

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

<openContent   id = ID   mode = ( none | interleave | suffix ) : interleave    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, any ?) </openContent>

Complex types with complex content can be the image of two different forms of <complexType> element: one with a <complexContent> child (discussed in Mapping Rules for Complex Types with Explicit Complex Content (§3.4.2.3.1) ), and one with neither <simpleContent> nor <complexContent> as a child (discussed in Mapping Rules for Complex Types with Implicit Complex Content (§3.4.2.3.2) ). The mapping of the {content type} is the same in both cases; it is described in Mapping Rules for Content Type Property of Complex Content (§3.4.2.3.3) .

3.4.2.3.1 Mapping Rules for Complex Types with Explicit Complex Content

When the <complexType> source declaration has a <complexContent> child, the following mappings apply, supplemented by those specified in Mapping Rules for Content Type Property of Complex Content (§3.4.2.3.3) , Common Mapping Rules for Complex Type Definitions (§3.4.2.1) , Mapping Rule for Attribute Uses Property (§3.4.2.4) , and Mapping Rule for Attribute Wildcard Property (§3.4.2.5) .

3.4.2.3.2 Mapping Rules for Complex Types with Implicit Complex Content

When the <complexType> source declaration has neither <simpleContent> nor <complexContent> as a child, it is taken as shorthand for complex content restricting · xs:anyType · . The mapping rules specific to this situation are as follows; the mapping rules for properties not described here are as given in Mapping Rules for Content Type Property of Complex Content (§3.4.2.3.3) , Common Mapping Rules for Complex Type Definitions (§3.4.2.1) , Mapping Rule for Attribute Uses Property (§3.4.2.4) , and Mapping Rule for Attribute Wildcard Property (§3.4.2.5) .

3.4.2.3.3 Mapping Rules for Content Type Property of Complex Content

For complex types with complex content, the {content type} property is calculated as follows. (For the {content type} on complex types with simple content, see Mapping Rules for Complex Types with Simple Content (§3.4.2.2) .)

3.4.2.4 Mapping Rule for Attribute Uses Property

Any <complexType> source declaration can have <attribute> and <attributeGroup> elements as children, or descendants. The <attribute> element is described in XML Representation of Attribute Declaration Schema Components (§3.2.2) and will not be repeated here.

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

The <attribute> and <attributeGroup> elements map to the {attribute uses} property of the Complex Type Definition component as described below. This mapping rule is the same for all complex type definitions.

If the <schema> ancestor has a defaultAttributes attribute, and the <complexType> element does not have defaultAttributesApply = false , then the {attribute uses} property is computed as if there were an <attributeGroup> [child] with empty content and a ref [attribute] whose · actual value · is the same as that of the defaultAttributes [attribute] appearing after any other <attributeGroup> [children] . Otherwise proceed as if there were no such <attributeGroup> [child] .

3.4.2.5 Mapping Rule for Attribute Wildcard Property

The {attribute wildcard} property of a Complex Type Definition depends on the <anyAttribute> element which may be present within the <complexType> element or within the attribute groups referred to within <complexType> . The <attributeGroup> element is described in the preceding section Mapping Rule for Attribute Uses Property (§3.4.2.4) and will not be repeated here.

If the <schema> ancestor has a defaultAttributes attribute, and the <complexType> element does not have defaultAttributesApply = false , then the {attribute wildcard} property is computed as if there were an <attributeGroup> [child] with empty content and a ref [attribute] whose · actual value · is the same as that of the defaultAttributes [attribute] appearing after any other <attributeGroup> [children] . Otherwise proceed as if there were no such <attributeGroup> [child] .

3.4.2.6 Examples of Complex Type Definitions

The following declaration defines a type for specifications of length by creating a complex type with simple content, with xs:nonNegativeInteger as the type of the content, and a unit attribute to give the unit of measurement.

An instance using this type might look like this:

A second approach to defining length uses two elements, one for size and one for the unit of measure. The definition of the type and the declaration of the element might look like this:

An instance using this method might look like this:

A third definition of type leaves the base type implicit; at the component level, the following declaration is equivalent to the preceding one.

3.4.3 Constraints on XML Representations of Complex Type Definitions

3.4.4 complex type definition validation rules, 3.4.4.1 locally declared type and context-determined type table.

This section defines the concepts of · locally declared type · and · context-determined type table · ; these concepts play a role in determining whether restrictions and extensions of complex type definitions are legitimate. The · locally declared type · is also used to help determine the · governing element declaration · and · governing type definition · of an element information item.

[Definition:]   Every Complex Type Definition determines a partial functional mapping from element or attribute information items (and their expanded names ) to type definitions. This mapping serves as a locally declared type for elements and attributes which are allowed by the Complex Type Definition .

The attribute case is simpler and will be taken first.

The definition for elements is slightly more complex.

3.4.4.2 Element Locally Valid (Complex Type)

3.4.4.3 element sequence locally valid (complex content).

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

3.4.4.4 Attribution

[Definition:]   During · validation · of an element information item against its (complex) · governing type definition · , associations between element and attribute information items among the [children] and [attributes] on the one hand, and attribute uses, attribute wildcards, particles and open contents on the other, are established. The element or attribute information item is attributed to the corresponding component.

When an attribute information item has the same expanded name as the {attribute declaration} of an Attribute Use , then the item is attributed to that attribute use. Otherwise, if the item matches an attribute wildcard, as described in Item Valid (Wildcard) (§3.10.4.1) , then the item is attributed to that wildcard. Otherwise the item is not attributed to any component.

  • S is a member of S1 × S2
  • S1 is a prefix of some element sequence that is · locally valid · with respect to CT , as defined in Element Sequence Locally Valid (Complex Content) (§3.4.4.3) .
  • for every element E in S2 , let S3 be the longest prefix of S1 where members of S3 are before E in S , then S3 + E is not a prefix of any element sequence that is · locally valid · with respect to CT .

[Definition:]   During · validation · , associations between element and attribute information items among the [children] and [attributes] on the one hand, and element and attribute declarations on the other, are also established. When an item is · attributed · to an · element particle · , then it is associated with the declaration which is the {term} of the particle. Similarly, when an attribute information item is · attributed to · an Attribute Use , then the item is associated with the {attribute declaration} of that Attribute Use . Such declarations are called the context-determined declarations . See clause 2.1 (in Element Locally Valid (Complex Type) (§3.4.4.2) ) for attribute declarations, clause 2 (in Element Sequence Locally Valid (Particle) (§3.9.4.2) ) for element declarations.

3.4.4.5 Conditional Type Substitutable

  • B be the {base type definition} of T
  • T T be the · context-determined type table · of E in T , if any
  • T B be the · context-determined type table · of E in B , if any
  • S T be the Type Definition · conditionally selected · for E by T T , if T T exists
  • S B be the Type Definition · conditionally selected · for E by T B , if T B exists

The constraint Conditional Type Substitutable (§3.4.4.5) above is intended to ensure that the use of Type Table s for conditional type assignment does not violate the usual principles of complex type restriction. More specifically, if T is a complex type definition derived from its base type B by restriction, then the rule seeks to ensure that a type definition conditionally assigned by T to some child element is always derived by restriction from that assigned by B to the same child. The current design enforces this using a "run-time" rule: instead of marking T as invalid if it could possibly assign types incompatible with those assigned by B , the run-time rule accepts the schema as valid if the usual constraints on the declared {type definition} s are satisified, without checking the details of the {type table} s. Element instances are then checked as part of validation, and any instances that would cause T (or any type in T 's {base type definition} chain) to assign the incompatible types are made invalid with respect to T . This rule may prove hard to understand or implement. The Working Group is uncertain whether the current design has made the right trade-off and whether we should use a simpler but more restrictive rule. We solicit input from implementors and users of this specification as to whether the current run-time rule should be retained.

3.4.5 Complex Type Definition Information Set Contributions

3.4.5.1 attribute default value.

  • Add the binding of P to N to the [in-scope namespaces] of all descendants of E , except where that binding is overridden by another binding for P .
  • Add to the [namespace attributes] of each child of E a namespace attribute which undeclares the binding for P (i.e. a namespace attribute for prefix P whose · normalized value · is the empty string), unless that child already has a namespace declaration for prefix P . Note that this approach is possible only if [XML Namespaces 1.1] is in use, rather than [XML Namespaces 1.0] .

3.4.5.2 Match Information

3.4.6 constraints on complex type definition schema components.

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

3.4.6.1 Complex Type Definition Properties Correct

3.4.6.2 derivation valid (extension).

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

3.4.6.3 Derivation Valid (Restriction, Complex)

The constraint just given, like other constraints on schemas, must be satisfied by every complex type T to which it applies.

The above constraint allows a complex type with an <all> model groups to restrict another complex type with either <all> , <sequence> , or <choice> model groups. Even when the base type has an <all> model group, the list of member elements and wildcard may be very different between the two types. The working group solicits feedback on how useful this is in practice, and on the difficulty in implementing this feature.

However, under certain conditions conforming processors need not (although they may ) detect some violations of this constraint. If (1) the type definition being checked has T . {content type} . {particle} . {term} . {compositor} = all and (2) an implementation is unable to determine by examination of the schema in isolation whether or not clause 2.4.2 is satisfied, then the implementation may provisionally accept the derivation. If any instance encountered in the · assessment · episode is valid against T but not against T . {base type definition} , then the derivation of T does not satisfy this constraint, the schema does not conform to this specification, and no · assessment · can be performed using that schema.

It is · implementation-defined · whether a processor (a) always detects violations of clause 2.4.2 by examination of the schema in isolation, (b) detects them only when some element information item in the input document is valid against T but not against T . {base type definition} , or (c) sometimes detects such violations by examination of the schema in isolation and sometimes not. In the latter case, the circumstances in which the processor does one or the other are · implementation-dependent · .

The above rule allows an implementation to use a potentially non-conforming schema to perform schema assessment and produce PSVI. This results in an exception of rules specified in Errors in Schema Construction and Structure (§5.1) . The Working Group solicits input from implementors and users of this specification as to whether this is an acceptable implementation behavior.

3.4.6.4 Content Type Restricts (Complex Content)

3.4.6.5 type derivation ok (complex).

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

  • When they are both top-level components with the same component type, namespace name, and local name;
  • When they are necessarily the same type definition (for example, when the two type definitions in question are the type definitions associated with two attribute or element declarations, which are discovered to be the same declaration);
  • When they are the same by construction (for example, when an element's type definition defaults to being the same type definition as that of its substitution-group head or when a complex type definition inherits an attribute declaration from its base type definition).

3.4.7 Built-in Complex Type Definition

There is a complex type definition for · xs:anyType · present in every schema by definition. It has the following properties:

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

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

3.5 Attribute Uses

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

3.5.1 The Attribute Use Schema Component

The attribute use schema component has the following properties:

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

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

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

3.5.2 XML Representation of Attribute Use Schema Components

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

3.5.3 Constraints on XML Representations of Attribute Uses

None as such.

3.5.4 Attribute Use Validation Rules

[Definition:]   The effective value constraint of an attribute use U is U . {value constraint} , if present, otherwise U . {attribute declaration} . {value constraint} , if present, otherwise the effective value constraint is · absent · .

3.5.5 Attribute Use Information Set Contributions

3.5.6 constraints on attribute use schema components.

All attribute uses (see Attribute Uses (§3.5) ) must satisfy the following constraints.

3.6 Attribute Group Definitions

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

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

The example above illustrates the pattern mentioned in XML Representations of Components (§3.1.2) : The same element, in this case attributeGroup , serves both to define and to incorporate by reference. In the first attributeGroup element in the example, the name attribute is required and the ref attribute is forbidden; in the second the ref attribute is required, the name attribute is forbidden.

3.6.1 The Attribute Group Definition Schema Component

The attribute group definition schema component has the following properties:

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

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

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

3.6.2 XML Representation of Attribute Group Definition Schema Components

3.6.2.1 xml mapping rule for named attribute groups.

The XML representation for an attribute group definition schema component is an <attributeGroup> element information item. It provides for naming a group of attribute declarations and an attribute wildcard for use by reference in the XML representation of complex type definitions and other attribute group definitions. The correspondences between the properties of the information item and properties of the component it corresponds to are given in this section.

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

When an <attributeGroup> appears as a child of <schema> or <redefine> , it corresponds to an attribute group definition as below. When it appears as a child of <complexType> or <attributeGroup> , it does not correspond to any component as such.

The rules given above for {attribute uses} and {attribute wildcard} specify that if an <attributeGroup> element A contains a reference to another attribute group B (i.e. A 's [children] include an <attributeGroup> with a ref attribute pointing at B ), then A maps to an Attribute Group Definition component whose {attribute uses} reflect not only the <attribute> [children] of A but also those of B and of any <attributeGroup> elements referred to in B . The same is true for attribute groups referred to from complex types.

Circular reference is not disallowed. That is, it is not an error if B , or some <attributeGroup> element referred to by B (directly, or indirectly at some remove) contains a reference to A . An <attributeGroup> element involved in such a reference cycle maps to a component whose {attribute uses} and {attribute wildcard} properties reflect all the <attribute> and <any> elements contained in, or referred to (directly or indirectly) by elements in the cycle.

3.6.2.2 Common Rules for Attribute Wildcards

3.6.3 constraints on xml representations of attribute group definitions, 3.6.4 attribute group definition validation rules, 3.6.5 attribute group definition information set contributions, 3.6.6 constraints on attribute group definition schema components.

All attribute group definitions (see Attribute Group Definitions (§3.6) ) must satisfy the following constraint.

3.7 Model Group Definitions

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

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

3.7.1 The Model Group Definition Schema Component

The model group definition schema component has the following properties:

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

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

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

3.7.2 XML Representation of Model Group Definition Schema Components

The XML representation for a model group definition schema component is a <group> element information item. It provides for naming a model group for use by reference in the XML representation of complex type definitions and model groups. The correspondences between the properties of the information item and properties of the component it corresponds to are given in this section.

<group   id = ID   maxOccurs = ( nonNegativeInteger | unbounded )  : 1   minOccurs = nonNegativeInteger  : 1   name = NCName   ref = QName    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, ( all | choice | sequence )?) </group>

If there is a name [attribute] (in which case the item will have <schema> or <redefine> as parent), then the item maps to a model group definition component with properties as follows:

Otherwise, if the item has a ref [attribute] and does not have minOccurs=maxOccurs=0 , then the <group> element maps to a particle component with properties as follows:

Otherwise, the <group> has minOccurs=maxOccurs=0 , in which case it maps to no component at all.

3.7.3 Constraints on XML Representations of Model Group Definitions

3.7.4 model group definition validation rules, 3.7.5 model group definition information set contributions, 3.7.6 constraints on model group definition schema components.

All model group definitions (see Model Group Definitions (§3.7) ) must satisfy the following constraint.

3.8 Model Groups

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

3.8.1 The Model Group Schema Component

The model group schema component has the following properties:

  • ( sequence ) correspond, in order, to the specified {particles} ;
  • ( choice ) correspond to exactly one of the specified {particles} ;
  • ( all ) correspond to the specified {particles} . The elements can occur in any order.

When two or more particles contained · directly · , · indirectly · , or · implicitly · in the {particles} of a model group have identically named element declarations as their {term} , the type definitions of those declarations must be the same.

3.8.2 XML Representation of Model Group Schema Components

The XML representation for a model group schema component is either an <all> , a <choice> or a <sequence> element information item. The correspondences between the properties of those information items and properties of the component they correspond to are given in this section.

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

<choice   id = ID   maxOccurs = ( nonNegativeInteger | unbounded )  : 1   minOccurs = nonNegativeInteger  : 1    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, ( element | group | choice | sequence | any )*) </choice>

<sequence   id = ID   maxOccurs = ( nonNegativeInteger | unbounded )  : 1   minOccurs = nonNegativeInteger  : 1    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, ( element | group | choice | sequence | any )*) </sequence>

Each of the above items corresponds to a particle containing a model group, with properties as follows (unless minOccurs=maxOccurs=0 , in which case the item corresponds to no component at all):

The particle just described has a Model Group as the value of its {term} property, as follows.

3.8.3 Constraints on XML Representations of Model Groups

3.8.4 model group validation rules.

In order to define the validation rules for model groups clearly, it will be useful to define some basic terminology; this is done in the next two sections, before the validation rules themselves are formulated.

3.8.4.1 Language Recognition by Groups

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

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

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

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

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

3.8.4.1.1 Sequences

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

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

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

  • j ≤ n , and
  • S = S 1 + S 2 + ... + S j (i.e. S 1 , S 2 , ..., S j is a · partition · of S ), and
  • S i is in L ( P i ) for 0 < i < j , and
  • Q i is a · path · of S i in P i for 0 < i ≤ j .

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

3.8.4.1.2 Choices

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

When the {compositor} of M is choice , and the {particles} of M is the sequence P 1 , P 2 , ..., P n , then L ( M ) is L ( P 1 ) ∪ L ( P 2 ) ∪ ... ∪ L ( P n ), and the set of · paths · of S in P is the set Q = Q 1 ∪ Q 2 ∪ ... ∪ Q n , where Q i is the set of · paths · of S in P i , for 0 < i ≤ n . Less formally, when M is a choice of P 1 , P 2 , ... P n , then L ( M ) contains any sequence accepted by any of the particles P 1 , P 2 , ... P n , and any · path · of S in any of the particles P 1 , P 2 , ... P n is a · path · of S in P .

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

3.8.4.1.3 All-groups

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

When the {compositor} of M is all , and the {particles} of M is the sequence P 1 , P 2 , ..., P n , then L ( M ) is the set of sequences S = S 1 × S 2 × ... × Sn (taking "×" as the interleave operator), where for 0 < i ≤ n , S i is in L ( P i ). The set of sequences { S 1 , S 2 , ..., Sn } is a · grouping · of S . The set of · paths · of S in P is the set of all · paths · Q = Q 1 × Q 2 × ... × Q n , where Q i is a · path · of S i in P i , for 0 < i ≤ n .

Less formally, when M is an all -group of P 1 , P 2 , ... P n , then L ( M ) is the set of sequences formed by taking one sequence which is accepted by P 1 , then one accepted by P 2 , and so on, up through P n , and then interleaving them together. Equivalently, L ( M ) is the set of sequences S such that the set { S 1 , S 2 , ..., Sn } is a · grouping · of S , and for 0 < i ≤ n , S i is in L ( P i ).

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

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

3.8.4.1.4 Multiple Paths in Groups

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

which can match the sequence ( <a/><b/> ) in more than one way. It may also be the case with unambiguous model groups, if they do not correspond to a deterministic expression (as it is termed in [XML 1.1] ) or a "1-unambiguous" expression, as it is defined by [Brüggemann-Klein / Wood 1998] . For example,

3.8.4.2 Principles of Validation against Groups

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

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

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

For example, in the content model

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

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

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

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

3.8.4.3 Element Sequence Valid

3.8.5 model group information set contributions, 3.8.6 constraints on model group schema components.

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

3.8.6.1 Model Group Correct

3.8.6.2 all group limited, 3.8.6.3 element declarations consistent, 3.8.6.4 unique particle attribution.

[Definition:]   An element particle is a Particle whose {term} is an Element Declaration . [Definition:]   A wildcard particle is a Particle whose {term} is a Wildcard . Wildcard particles may be referred to as "strict", "lax", or "skip" particles, depending on the {process contents} property of their {term} .

3.8.6.5 Effective Total Range ( all and sequence )

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

3.8.6.6 Effective Total Range ( choice )

3.9 particles.

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

When an element is validated against a complex type, its sequence of child elements is checked against the content model of the complex type and the children are · attributed to · to Particles of the content model. The attribution of items to Particles determines the calculation of the items' · context-determined declarations · and thus partially determines the · governing element declarations · for the children: when an element information item is · attributed to · an · element particle · , that Particle 's Element Declaration , or an Element Declaration · substitutable · for it, becomes the item's · context-determined declaration · and thus normally its · governing element declaration · ; when the item is · attributed to · a · wildcard particle · , the · governing element declaration · depends on the {process contents} property of the wildcard and on QName resolution (Instance) (§3.17.6.3) .

3.9.1 The Particle Schema Component

The particle schema component has the following properties:

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

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

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

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

3.9.2 XML Representation of Particle Components

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

3.9.3 Constraints on XML Representations of Particles

3.9.4 particle validation rules, 3.9.4.1 principles of validation against particles.

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

3.9.4.1.1 Language Recognition for Repetitions

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

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

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

  • If T is a model group, then the set of · paths · of S in P is the set of all · paths · Q such that Q = Q 1 + Q 2 + ... + Q n , where Q i is a · path · of S i in T for 0 < i ≤ n . (For the definition of · paths · in model groups, see Language Recognition by Groups (§3.8.4.1) .)
  • If T is a · basic term · , then the (sole) · path · of S in P is a sequence of n occurrences of P .

3.9.4.1.2 Validation of Basic Terms

In the preceding section ( Language Recognition for Repetitions (§3.9.4.1.1) ), the language L ( P ) · accepted · by a Particle P is defined in terms of the language · accepted · by P 's {term} . This section defines L ( T ) for · basic terms · ; for the definition of L ( T ) when T is a group, see Language Recognition by Groups (§3.8.4.1) .

[Definition:]   For any Element Declaration D , the language L ( D ) · accepted · by D is the set of all sequences of length 1 whose sole member is an element information item which · matches · D .

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

[Definition:]   For any Wildcard W , the language L ( W ) · accepted · by W is the set of all sequences of length 1 whose sole member is an element information item which · matches · W .

[Definition:]   An element information item E matches a Wildcard W (or a · wildcard particle · whose {term} is W ) if and only if E is locally · valid · with respect to W , as defined in the validation rule Item Valid (Wildcard) (§3.10.4.1) .

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

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

3.9.4.2 Element Sequence Locally Valid (Particle)

3.9.4.3 element sequence accepted (particle), 3.9.5 particle information set contributions, 3.9.6 constraints on particle schema components, 3.9.6.1 particle correct.

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

3.9.6.2 Particle Valid (Extension)

3.9.6.3 particle emptiable, 3.10 wildcards.

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

3.10.1 The Wildcard Schema Component

The wildcard schema component has the following properties:

A set each of whose members is either an xs:anyURI value or the distinguished value · absent · . Required.

A set each of whose members is either an xs:QName value or the keyword defined or the keyword sibling . Required.

  • ( {variety} any ) have any namespace or are not namespace-qualified;
  • ( {variety} not and {namespaces} a set whose members are either namespace names or · absent · ) have any namespace other than the specified namespaces and/or, if · absent · is included in the set, are namespace-qualified;
  • ( {variety} enumeration and {namespaces} a set whose members are either namespace names or · absent · ) have any of the specified namespaces and/or, if · absent · is included in the set, are unqualified.
  • ( {disallowed names} contains QName members) have any expanded name other than the specified names.
  • ( {disallowed names} contains the keyword defined ) have any expanded name other than those matching the names of global element or attribute declarations.
  • ( {disallowed names} contains the keyword sibling ) have any expanded name other than those matching the names of element or attribute declarations in the containing complex type definition.

The keywords defined and sibling allow a kind of wildcard which matches only elements not declared in the current schema or contained within the current complex type, respectively. They are new in this version of this specification. The Working Group is uncertain whether their value outweighs their liabilities; we solicit input from implementors and users of this specification as to whether they should be retained or not.

3.10.2 XML Representation of Wildcard Schema Components

The XML representation for a wildcard schema component is an <any> or <anyAttribute> element information item.

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

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

An <any> information item corresponds both to a wildcard component and to a particle containing that wildcard (unless minOccurs=maxOccurs=0 , in which case the item corresponds to no component at all). The mapping rules are given in the following two subsections.

3.10.2.1 Mapping from <any> to a Particle

The mapping from an <any> information item to a particle is as follows.

3.10.2.2 Mapping from <any> and <anyAttribute> to a Wildcard Component

The mapping from an <any> information item to a wildcard component is as follows. This mapping is also used for mapping <anyAttribute> information items to wildcards, although in some cases the result of the mapping is further modified, as specified in the rules for <attributeGroup> and <complexType> .

  • If the item is a QName value (i.e. an expanded name ), then that QName value is a member of the set.
  • If the item is the token " ##defined ", then the keyword defined is a member of the set.
  • If the item is the token " ##definedSibling ", then the keyword sibling is a member of the set.

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

3.10.3 Constraints on XML Representations of Wildcards

3.10.4 wildcard validation rules, 3.10.4.1 item valid (wildcard).

When an element or attribute information item is · attributed · to a wildcard and the preceding constraint ( Item Valid (Wildcard) (§3.10.4.1) ) is satisfied, then the item has no · context-determined declaration · . Its · governing · declaration, if any, is found by matching its expanded name as described in QName resolution (Instance) (§3.17.6.3) . Note that QName resolution is performed only if the item is · attributed · to a strict or lax wildcard; if the wildcard has a {process contents} property of skip , then the item has no · governing · declaration.

[Definition:]   An element or attribute information item is skipped if it is · attributed · to a skip wildcard or if one of its ancestor elements is.

3.10.4.2 Wildcard allows Expanded Name

3.10.4.3 wildcard allows namespace name, 3.10.5 wildcard information set contributions, 3.10.6 constraints on wildcard schema components, 3.10.6.1 wildcard properties correct.

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

3.10.6.2 Wildcard Subset

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

3.10.6.3 Attribute Wildcard Union

3.10.6.4 attribute wildcard intersection, 3.11 identity-constraint definitions.

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

3.11.1 The Identity-constraint Definition Schema Component

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

If a value is present, its {identity-constraint category} must be key or unique .

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

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

These constraints are specified along side the specification of types for the attributes and elements involved, i.e. something declared as of type integer can also serve as a key. Each constraint declaration has a name, which exists in a single symbol space for constraints. The equality and inequality conditions appealed to in checking these constraints apply to the values of the fields selected, not their lexical representation, so that for example 3.0 and 3 would be conflicting keys if they were both decimal, but non-conflicting if they were both strings, or one was a string and one a decimal. When equality and identity differ for the simple types involved, all three forms of identity-constraint test for equality, not identity, of values.

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

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

{selector} specifies a restricted XPath ( [XPath 2.0] ) expression relative to instances of the element being declared. This must identify a sequence of element nodes that are contained within the declared element to which the constraint applies.

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

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

3.11.2 XML Representation of Identity-constraint Definition Schema Components

The XML representation for an identity-constraint definition schema component is either a <key> , a <keyref> or a <unique> element information item. The correspondences between the properties of those information items and properties of the component they correspond to are as follows:

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

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

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

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

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

If the ref [attribute] is absent, the corresponding schema component is as follows:

Otherwise (the ref [attribute] is present), the corresponding schema component is the identity-constraint definition · resolved · to by the · actual value · of the ref [attribute] .

3.11.3 Constraints on XML Representations of Identity-constraint Definitions

3.11.4 identity-constraint definition validation rules.

For purposes of checking identity-constraints, single atomic values are not distinguished from lists with single items. An atomic value V and a list L with a single item are treated as equal, for purposes of this specification, if V is equal to the atomic value which is the single item of L .

3.11.5 Identity-constraint Definition Information Set Contributions

3.11.6 constraints on identity-constraint definition schema components, 3.11.6.1 identity-constraint definition properties correct.

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

3.11.6.2 Selector Value OK

[Definition:]   The subset of XPath defined in Selector Value OK (§3.11.6.2) is called the selector subset of XPath.

3.11.6.3 Fields Value OK

[Definition:]   The subset of XPath defined in Fields Value OK (§3.11.6.3) is called the field subset of XPath.

3.12 Type Alternatives

Type Alternative components provide associations between boolean conditions (as XPath expressions) and Type Definition s. They are used in conditional type assignment.

3.12.1 The Type Alternative Schema Component

The type alternative schema component has the following properties:

Type alternatives can be used by an Element Declaration to specify a condition ( {test} ) under which a particular type ( {type definition} ) is used as the · governing type definition · for element information items governed by that Element Declaration . Each Element Declaration may have multiple Type Alternative s in its {type table} .

3.12.2 XML Representation of Type Alternative Schema Components

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

<alternative   id = ID   test = an XPath expression   type = QName   xpathDefaultNamespace = ( anyURI | ( ##defaultNamespace | ##targetNamespace | ##local ))    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, ( simpleType | complexType )?) </alternative>

Each <alternative> element maps to a Type Alternative component as follows.

3.12.3 Constraints on XML Representations of Type Alternatives

3.12.4 type alternative validation rules, 3.12.5 type alternative information set contributions, 3.12.6 constraints on type alternative schema components.

All type alternatives (see Type Alternatives (§3.12) ) must satisfy the following constraints.

3.13 Assertions

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

3.13.1 The Assertion Schema Component

The assertion schema component has the following properties:

To check an assertion, an instance of the XPath 2.0 data model ( [XDM] ) is constructed, in which the element information item being · assessed · is the root element, and elements and attributes are assigned types and values according to XPath 2.0 data model construction rules, with some exceptions. See Assertion Satisfied (§3.13.4.1) for details about how the data model is constructed. When evaluated against this data model instance, {test} evaluates to either true or false (if any other value is returned, it's converted to either true or false as if by a call to the XPath fn:boolean function).

3.13.2 XML Representation of Assertion Schema Components

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

<assert   id = ID    test = an XPath expression   xpathDefaultNamespace = ( anyURI | ( ##defaultNamespace | ##targetNamespace | ##local ))    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?) </assert>

The <assert> element maps to an Assertion component as follows.

Assertions, like identity constraints and conditional type assignment, use [XPath 2.0] expressions. The expression itself is recorded, together with relevant parts of the context, in an XPath Expression property record. The mapping is as described below; in each case, the XPath expression itself is given in a designated attribute of the appropriate " host element ".

3.13.3 Constraints on XML Representations of Assertions

3.13.4 assertion validation rules, 3.13.4.1 assertion satisfied, 3.13.4.2 xpath evaluation, 3.13.5 assertion information set contributions, 3.13.6 constraints on assertion schema components.

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

3.13.6.1 Assertion Properties Correct

3.13.6.2 xpath valid, 3.14 notation declarations.

Notation declarations reconstruct XML NOTATION declarations.

3.14.1 The Notation Declaration Schema Component

The notation declaration schema component has the following properties:

As defined in [XML 1.1] .

Notation declarations do not participate in · validation · as such. They are referenced in the course of · validating · strings as members of the NOTATION simple type. An element or attribute information item with its · governing · type definition or its · actual member type definition · derived from the NOTATION simple type is · valid · only if its value was among the enumerations of such simple type. As a consequence such a value is required to be the {name} of a notation declaration.

3.14.2 XML Representation of Notation Declaration Schema Components

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

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

The <notation> element maps to a Notation Declaration component as follows.

3.14.3 Constraints on XML Representations of Notation Declarations

3.14.4 notation declaration validation rules, 3.14.5 notation declaration information set contributions, 3.14.6 constraints on notation declaration schema components.

All notation declarations (see Notation Declarations (§3.14) ) must satisfy the following constraint.

3.15 Annotations

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

3.15.1 The Annotation Schema Component

The annotation schema component has the following properties:

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

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

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

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

3.15.2 XML Representation of Annotation Schema Components

Annotation of schemas and schema components, with material for human or computer consumption, is provided for by allowing application information and human information at the beginning of most major schema elements, and anywhere at the top level of schemas. The XML representation for an annotation schema component is an <annotation> element information item. The correspondences between the properties of that information item and properties of the component it corresponds to are as follows:

<annotation   id = ID    {any attributes with non-schema namespace . . .} >   Content: ( appinfo | documentation )* </annotation>

<appinfo   source = anyURI    {any attributes with non-schema namespace . . .} >   Content: ( {any} )* </appinfo>

<documentation   source = anyURI   xml:lang = language    {any attributes with non-schema namespace . . .} >   Content: ( {any} )* </documentation>

The <annotation> element and its descendants map to an Annotation component as follows.

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

Virtually every kind of schema component defined in this specification has an {annotations} property. When the component is described in a schema document, the mapping from the XML representation of the component to the Annotation components in the appropriate {annotations} property follows the rules described in the next paragraph.

3.15.3 Constraints on XML Representations of Annotations

3.15.4 annotation validation rules, 3.15.5 annotation information set contributions.

None as such: the addition of annotations to the · post-schema-validation infoset · is covered by the · post-schema-validation infoset · contributions of the enclosing components.

3.15.6 Constraints on Annotation Schema Components

All annotations (see Annotations (§3.15) ) must satisfy the following constraint.

3.16 Simple Type Definitions

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

3.16.1 The Simple Type Definition Schema Component

The simple type definition schema component has the following properties:

A subset of { extension , restriction , list , union }.

Either an Attribute Declaration , an Element Declaration , a Complex Type Definition or a Simple Type Definition .

With one exception, the {base type definition} of any Simple Type Definition is a Simple Type Definition . The exception is · xs:anySimpleType · , which has · xs:anyType · , a Complex Type Definition , as its {base type definition} .

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

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

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

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

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

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

The {facets} property contains a set of constraining facets which are used to specify constraints on the datatype described by the simple type definition. For atomic definitions, these are restricted to those appropriate for the corresponding {primitive type definition} . Therefore, the value space and lexical space (i.e. what is · validated · by any atomic simple type) is determined by the pair ( {primitive type definition} , {facets} ).

Constraining facets are defined in [XML Schema: Datatypes] . All conforming implementations of this specification must support all of the facets defined in [XML Schema: Datatypes] . It is · implementation-defined · whether additional facets are supported; if they are, the implementation must satisfy the rules for · implementation-defined · facets described in [XML Schema: Datatypes] .

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

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

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

3.16.2 XML Representation of Simple Type Definition Schema Components

<simpleType   final = ( #all | List of ( list | union | restriction | extension ))   id = ID   name = NCName    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, ( restriction | list | union )) </simpleType>

<restriction   base = QName   id = ID    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, ( simpleType ?, ( minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | maxScale | minScale | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion | explicitTimezone | {any with namespace: ##other} )*)) </restriction>

<list   id = ID   itemType = QName    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, simpleType ?) </list>

<union   id = ID   memberTypes = List of QName    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, simpleType *) </union>

The <simpleType> element and its descendants normally, when there are no errors, map to a Simple Type Definition component. The case in which an unknown facet is used in the definition of a simple type definition is handled specially: the <simpleType> in question is not in error, but it does not map to any component at all.

  • If the <simpleType> element has a <restriction> element among its children, and the base type definition has {variety} = atomic , then the mapping rules in Common mapping rules for Simple Type Definitions (§3.16.2.1) and Mapping Rules for Atomic Simple Type Definitions (§3.16.2.2) apply.
  • If the <simpleType> element has a <list> element among its children, or if it has a <restriction> child and the base type definition has {variety} = list , then the mapping rules in Common mapping rules for Simple Type Definitions (§3.16.2.1) and Mapping Rules for Lists (§3.16.2.3) apply.
  • If the <simpleType> element has a <union> element among its children, or if it has a <restriction> child and the base type definition has {variety} = union , then the mapping rules in Common mapping rules for Simple Type Definitions (§3.16.2.1) and Mapping Rules for Unions (§3.16.2.4) apply.

3.16.2.1 Common mapping rules for Simple Type Definitions

The following rules apply to all simple type definitions.

3.16.2.2 Mapping Rules for Atomic Simple Type Definitions

The following rule applies if the {variety} is atomic

[Definition:]   The ancestors of a · type definition · are its {base type definition} and the · ancestors · of its {base type definition} . (The ancestors of a Simple Type Definition T in the type hierarchy are themselves · type definitions · ; they are distinct from the XML elements which may be ancestors, in the XML document hierarchy, of the <simpleType> element which declares T .)

3.16.2.3 Mapping Rules for Lists

If the {variety} is list , the following additional property mapping applies:

3.16.2.4 Mapping Rules for Unions

If the {variety} is union , the following additional property mapping applies:

3.16.3 Constraints on XML Representations of Simple Type Definitions

3.16.4 simple type definition validation rules, 3.16.5 simple type definition information set contributions, 3.16.6 constraints on simple type definition schema components, 3.16.6.1 simple type definition properties correct.

All simple type definitions must satisfy both the following constraints.

3.16.6.2 Derivation Valid (Restriction, Simple)

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

3.16.6.3 Type Derivation OK (Simple)

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

3.16.6.4 Simple Type Restriction (Facets)

3.16.7 built-in simple type definitions, 3.16.7.1 xs:anysimpletype.

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

The definition of · xs:anySimpleType · is the root of the simple type definition hierarchy, and as such mediates between the other simple type definitions, which all eventually trace back to it via their {base type definition} properties, and · xs:anyType · , which is its {base type definition} .

3.16.7.2 xs:anyAtomicType

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

3.16.7.3 xs:error

A Simple Type Definition for · xs:error · is present in every schema by definition. It has the following properties:

3.16.7.4 Built-in primitive datatypes

Simple type definitions corresponding to all the built-in primitive datatypes, namely string , boolean , float , double , decimal , precisionDecimal , dateTime , duration , time , date , gMonth , gMonthDay , gDay , gYear , gYearMonth , hexBinary , base64Binary , anyURI , QName and NOTATION (see the Primitive Datatypes section of [XML Schema: Datatypes] ) are present by definition in every schema as follows:

[as appropriate]

All conforming implementations of this specification must support all the primitive datatypes defined in [XML Schema: Datatypes] . It is · implementation-defined · whether additional primitive datatypes are supported, and whether, if so, they are automatically incorporated in every schema or not. If · implementation-defined · primitives are supported, the implementation must satisfy the rules for · implementation-defined · primitive datatypes described in [XML Schema: Datatypes] .

[Definition:]   A type about which a processor possesses prior knowledge, and which the processor can support without any declaration of the type being supplied by the user, is said to be automatically known to the processor.

3.16.7.5 Other built-in datatypes

Similarly, simple type definitions corresponding to all the other built-in datatypes (see the Other Built-in Datatypes section of [XML Schema: Datatypes] ) are present by definition in every schema, with properties as specified in [XML Schema: Datatypes] and as represented in XML in Illustrative XML representations for the built-in ordinary type definitions .

All conforming implementations of this specification must support all the built-in datatypes defined in [XML Schema: Datatypes] . It is · implementation-defined · whether additional derived types are · automatically known · to the implementation without declaration and whether, if so, they are automatically incorporated in every schema or not.

3.17 Schemas as a Whole

A schema consists of a set of schema components.

3.17.1 The Schema Itself

At the abstract level, the schema itself is just a container for its components.

3.17.2 XML Representations of Schemas

A schema is represented in XML by one or more · schema documents · , that is, one or more <schema> element information items. A · schema document · contains representations for a collection of schema components, e.g. type definitions and element declarations, which have a common {target namespace} . A · schema document · which has one or more <import> element information items corresponds to a schema with components with more than one {target namespace} , see Import Constraints and Semantics (§4.2.5.2) .

<schema   attributeFormDefault = ( qualified | unqualified ) : unqualified   blockDefault = ( #all | List of ( extension | restriction | substitution ))  : ''   defaultAttributes = QName   xpathDefaultNamespace = ( anyURI | ( ##defaultNamespace | ##targetNamespace | ##local ))  : ##local   elementFormDefault = ( qualified | unqualified ) : unqualified   finalDefault = ( #all | List of ( extension | restriction | list | union ))  : ''   id = ID   targetNamespace = anyURI   version = token   xml:lang = language    {any attributes with non-schema namespace . . .} >   Content: (( include | import | redefine | override | annotation )*, ( defaultOpenContent , annotation *)?, (( simpleType | complexType | group | attributeGroup | element | attribute | notation ), annotation *)*) </schema>

<defaultOpenContent   appliesToEmpty = boolean  : false   id = ID   mode = ( interleave | suffix ) : interleave    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?, any ) </defaultOpenContent>

The <schema> element information item maps to a Schema component as follows.

Note that none of the attribute information items displayed above correspond directly to properties of schemas. The blockDefault , finalDefault , attributeFormDefault , elementFormDefault and targetNamespace attributes are appealed to in the sub-sections above, as they provide global information applicable to many representation/component correspondences. The other attributes ( id and version ) are for user convenience, and this specification defines no semantics for them.

The definition of the schema abstract data model in XSD Abstract Data Model (§2.2) makes clear that most components have a {target namespace} . Most components corresponding to representations within a given <schema> element information item will have a {target namespace} which corresponds to the targetNamespace attribute.

Since the empty string is not a legal namespace name, supplying an empty string for targetNamespace is incoherent, and is not the same as not specifying it at all. The appropriate form of schema document corresponding to a · schema · whose components have no {target namespace} is one which has no targetNamespace attribute specified at all.

Although the example schema at the beginning of this section might be a complete XML document, <schema> need not be the document element, but can appear within other documents. Indeed there is no requirement that a schema correspond to a (text) document at all: it could correspond to an element information item constructed 'by hand', for instance via a DOM-conformant API.

Aside from <include> and <import> , which do not correspond directly to any schema component at all, each of the element information items which may appear in the content of <schema> corresponds to a schema component, and all except <annotation> are named. The sections below present each such item in turn, setting out the components to which it corresponds.

3.17.2.1 References to Schema Components

Reference to schema components from a schema document is managed in a uniform way, whether the component corresponds to an element information item from the same schema document or is imported ( References to schema components across namespaces ( <import> ) (§4.2.5) ) from an external schema (which may , but need not, correspond to an actual schema document). The form of all such references is a · QName · .

[Definition:]   A QName is a name with an optional namespace qualification, as defined in [XML Namespaces 1.1] . When used in connection with the XML representation of schema components or references to them, this refers to the simple type QName as defined in [XML Schema: Datatypes] . For brevity, the term · QName · is also used to refer to · actual values · in the value space of the QName simple type, which are expanded names with a [Definition:]   local name and a [Definition:]   namespace name .

[Definition:]   An NCName is a name with no colon, as defined in [XML Namespaces 1.1] . When used in connection with the XML representation of schema components in this specification, this refers to the simple type NCName as defined in [XML Schema: Datatypes] .

[Definition:]   A · QName · in a schema document resolves to a component in a schema if and only if in the context of that schema the QName and the component together satisfy the rule QName resolution (Schema Document) (§3.17.6.2) . A · QName · in an input document, or a pair consisting of a local name and a namespace name, resolves to a component in a schema if and only if in the context of that schema the QName (or the name + namespace pair) and the component together satisfy the rule QName resolution (Instance) (§3.17.6.3) .

In each of the XML representation expositions in the following sections, an attribute is shown as having type QName if and only if it is interpreted as referencing a schema component.

3.17.2.2 References to Schema Components from Elsewhere

The names of schema components such as type definitions and element declarations are not of type ID : they are not unique within a schema, just within a symbol space. This means that simple fragment identifiers will not always work to reference schema components from outside the context of schema documents.

There is currently no provision in the definition of the interpretation of fragment identifiers for the text/xml MIME type, which is the MIME type for schemas, for referencing schema components as such. However, [XPointer] provides a mechanism which maps well onto the notion of symbol spaces as it is reflected in the XML representation of schema components. A fragment identifier of the form #xpointer(xs:schema/xs:element[@name="person"]) will uniquely identify the representation of a top-level element declaration with name person , and similar fragment identifiers can obviously be constructed for the other global symbol spaces.

Short-form fragment identifiers may also be used in some cases, that is when a DTD or XSD schema is available for the schema in question, and the provision of an id attribute for the representations of all primary and secondary schema components, which is of type ID , has been exploited.

It is a matter for applications to specify whether they interpret document-level references of either of the above varieties as being to the relevant element information item (i.e. without special recognition of the relation of schema documents to schema components) or as being to the corresponding schema component.

3.17.3 Constraints on XML Representations of Schemas

3.17.4 validation rules for schemas as a whole, 3.17.5 schema information set contributions, 3.17.5.1 schema information, 3.17.5.2 id/idref table, 3.17.6 constraints on schemas as a whole, 3.17.6.1 schema properties correct.

All schemas (see Schemas as a Whole (§3.17) ) must satisfy the following constraint.

3.17.6.2 QName resolution (Schema Document)

3.17.6.3 qname resolution (instance).

As the discussion above at Schema Component Details (§3) makes clear, at the level of schema components and · validation · , reference to components by name is normally not involved. In a few cases, however, qualified names appearing in information items being · validated · must be resolved to schema components by such lookup. The following constraint is appealed to in these cases.

4 Schemas and Namespaces: Access and Composition

This chapter defines the mechanisms by which this specification establishes the necessary precondition for · assessment · , namely access to one or more schemas. This chapter also sets out in detail the relationship between schemas and namespaces, as well as mechanisms for modularization of schemas, including provision for incorporating definitions and declarations from one schema in another, possibly with modifications.

Conformance (§2.4) describes three levels of conformance for schema processors, and Schemas and Schema-validity Assessment (§5) provides a formal definition of · assessment · . This section sets out in detail the 3-layer architecture implied by the three conformance levels. The layers are:

  • The · assessment · core, relating schema components and instance information items;
  • Schema representation: the connections between XML representations and schema components, including the relationships between namespaces and schema components;
  • XSD web-interoperability guidelines: instance->schema and schema->schema connections for the WWW.

Layer 1 specifies the manner in which a schema composed of schema components can be applied to in the · assessment · of an instance element information item. Layer 2 specifies the use of <schema> elements in XML documents as the standard XML representation for schema information in a broad range of computer systems and execution environments. To support interoperation over the World Wide Web in particular, layer 3 provides a set of conventions for schema reference on the Web. Additional details on each of the three layers is provided in the sections below.

4.1 Layer 1: Summary of the Schema-validity Assessment Core

The fundamental purpose of the · assessment · core is to define · assessment · for a single element information item and its descendants with respect to a complex type definition. All processors are required to implement this core predicate in a manner which conforms exactly to this specification.

· Assessment · is defined with reference to an · XSD schema · (note not a · schema document · ).

As specified above, each schema component is associated directly or indirectly with a target namespace, or explicitly with no namespace. In the case of multi-namespace documents, components for more than one target namespace will co-exist in a schema.

Processors have the option to assemble (and perhaps to optimize or pre-compile) the entire schema prior to the start of an · assessment · episode, or to gather the schema lazily as individual components are required. In all cases it is required that:

  • The processor succeed in locating the · schema components · transitively required to complete an · assessment · (note that components derived from · schema documents · can be integrated with components obtained through other means);
  • no definition or declaration changes once it has been established;
  • if the processor chooses to acquire declarations and definitions dynamically, that there be no side effects of such dynamic acquisition that would cause the results of · assessment · to differ from that which would have been obtained from the same schema components acquired in bulk.

The obligation of a schema-aware processor as far as the · assessment · core is concerned is to implement one or more of the options for · assessment · given below in Assessing Schema-Validity (§5.2) . Neither the choice of element information item for that · assessment · , nor which of the means of initiating · assessment · are used, is within the scope of this specification.

Although · assessment · is defined recursively, it is also intended to be implementable in streaming processors. Such processors may choose to incrementally assemble the schema during processing in response, for example, to encountering new namespaces. The implication of the invariants expressed above is that such incremental assembly must result in an · assessment · outcome that is the same as would be given if · assessment · was undertaken again with the final, fully assembled schema.

4.2 Layer 2: Schema Documents, Namespaces and Composition

The sub-sections of Schema Component Details (§3) define an XML representation for type definitions and element declarations and so on, specifying their target namespace and collecting them into schema documents. The two following sections relate to assembling a complete schema for · assessment · from multiple sources. They should not be understood as a form of text substitution, but rather as providing mechanisms for distributed definition of schema components, with appropriate schema-specific semantics.

4.2.1 Conditional inclusion

Whenever a conforming XSD processor reads a · schema document · in order to include the components defined in it in a schema, it first performs on the schema document the pre-processing described in this section.

Every element in the · schema document · is examined to see whether any of the attributes vc:minVersion , vc:maxVersion , vc:typeAvailable , vc:typeUnavailable , vc:facetAvailable , or vc:facetUnavailable appear among its [attributes] .

Where they appear, the attributes vc:minVersion and vc:maxVersion are treated as if declared with type xs:decimal , and their · actual values · are compared to a decimal value representing the version of XSD supported by the processor (here represented as a variable V ). For processors conforming to this version of this specification, the value of V is 1.1.

If V is less than the value of vc:minVersion , or if V is greater than or equal to the value of vc:maxVersion , then the element on which the attribute appears is to be ignored, along with all its attributes and descendants. The effect is that portions of the schema document marked with vc:minVersion and/or vc:maxVersion are retained if vc:minVersion ≤ V < vc:maxVersion .

Where they appear, the attributes vc:typeAvailable and vc:typeUnavailable are treated as if declared with type list of xs:QName , and the items in their · actual values · are checked to see whether they name types · automatically known · to the processor. The attributes vc:facetAvailable and vc:facetUnavailable are similarly typed, and checked to see if they name facets supported by the processor.

  • vc:typeAvailable = T , where any item in the · actual value · T is not the expanded name of some type definition · automatically known · to the processor
  • vc:typeUnavailable = T , where every item in the · actual value · T is the expanded name of some type definition · automatically known · to and supported by the processor
  • vc:facetAvailable = F , where any item in the · actual value · F is not the expanded name of some facet known to and supported by the processor
  • vc:facetUnavailable = F , where every item in the · actual value · F is the expanded name of some facet known to and supported by the processor

The pre-processing of a schema document S1 results in a second schema document S2 , identical to S1 except that all elements and attributes in S1 which are to be ignored are absent from S2 . If the <schema> element information item in S1 is to be ignored, then S2 is identical to S1 except that any attributes other than targetNamespace , vc:minVersion or vc:maxVersion are removed from its [attributes] , and its [children] is the empty sequence. It is S2 , not S1 , which is required to conform to this specification.

Except where conditional-inclusion pre-processing is explicitly mentioned, references to · schema documents · elsewhere in this specification invariably refer to the result of the pre-processing step described here, not to its input, which need not, and in the general case will not, always conform to the rules for schema documents laid out in this specification.

Suppose that a processor supports an · implementation-defined · primitive named xpath_expression in namespace " http://example.org/extension_types ", and is presented with the following schema document:

The effect of conditional inclusion is to include the first declaration for e and omit the second, so that the effective schema document, after pre-processing for conditional inclusion, is:

A processor which does not support type "tns:xpath_expression", by contrast, will use the other declaration for e : type in the namespace in question

4.2.2 Assembling a schema for a single target namespace from multiple schema definition documents ( <include> )

Schema components for a single target namespace can be assembled from several · schema documents · , that is several <schema> element information items:

<include   id = ID    schemaLocation = anyURI    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?) </include>

A <schema> information item may contain any number of <include> elements. Their schemaLocation attributes, consisting of a URI reference, identify other · schema documents · , that is <schema> information items.

If two <include> elements specify the same schema location (after resolving relative URI references) then they refer to the same schema document. If they specify different schema locations, then they refer to different schema documents, unless the implementation is able to determine that the two URIs are references to the same resource.

The · XSD schema · corresponding to <schema> contains not only the components corresponding to its definition and declaration [children] , but also all the components of all the · XSD schemas · corresponding to any <include> d schema documents. Such included schema documents must either (a) have the same targetNamespace as the <include> ing schema document, or (b) no targetNamespace at all, in which case the <include> d schema document is converted to the <include> ing schema document's targetNamespace

If there is a sequence of schema documents S1 , S2 , ... Sn , and a sequence of <include> elements E1 , E2 , ... En , such that each S i contains the corresponding E i , and each E i (where i < n ) points to schema document S i + 1 , and En points to S1 (i.e. if there is a cycle in the relation defined by the <include> element), then the same schema corresponds to all of the schema documents S1 , ... Sn in the cycle, and it includes the same components as the schema corresponding to S1 in the similar case where Sn has no <include> element pointing at S1 .

4.2.3 Including modified component definitions ( <redefine> )

The Working Group requests feedback from readers, schema authors, implementors, and other users of this specification as to the desirability of retaining, removing, deprecating, or not deprecating the use of <redefine> . Since the <override> facility provides similar functionality but does not require a restriction or extension relation between the new and the old definitions of redefined components, the Working Group is particularly interested in learning whether users of this specification find that requirement useful or not.

In order to provide some support for evolution and versioning, it is possible to incorporate components corresponding to a schema document with modifications . The modifications have a pervasive impact, that is, only the redefined components are used, even when referenced from other incorporated components, whether redefined themselves or not.

<redefine   id = ID    schemaLocation = anyURI    {any attributes with non-schema namespace . . .} >   Content: ( annotation | ( simpleType | complexType | group | attributeGroup ))* </redefine>

A <schema> information item may contain any number of <redefine> elements. Their schemaLocation attributes, consisting of a URI reference, identify other · schema documents · , that is <schema> information items.

The · XSD schema · corresponding to <schema> contains not only the components corresponding to its definition and declaration [children] , but also all the components of all the · XSD schemas · corresponding to any <redefine> d schema documents. Such schema documents must either (a) have the same targetNamespace as the <redefine> ing schema document, or (b) no targetNamespace at all, in which case the <redefine> d schema document is converted to the <redefine> ing schema document's targetNamespace .

  • Type definitions must use themselves as their base type definition;
  • Attribute group definitions and model group definitions must be supersets or subsets of their original definitions, either by including exactly one reference to themselves or by containing only (possibly restricted) components which appear in a corresponding way in their <redefine> d selves.

This mechanism is intended to provide a declarative and modular approach to schema modification, with functionality no different except in scope from what would be achieved by wholesale text copying and redefinition by editing. In particular redefining a type is not guaranteed to be side-effect free: it can have unexpected impacts on other type definitions which are based on the redefined one, even to the extent that some such definitions become ill-formed.

4.2.4 Overriding component definitions ( <override> )

The <redefine> construct defined in Including modified component definitions ( <redefine> ) (§4.2.3) is useful in schema evolution and versioning, when it is desirable to have some guaranteed restriction or extension relation between the old component and the redefined component. But there are occasions when the schema author simply wants to replace old components with new ones without any constraint. Also, existing XSD processors have implemented conflicting and non-interoperable interpretations of <redefine> , and the <redefine> construct is · deprecated · . The <override> construct defined in this section allows such unconstrained replacement.

<override   id = ID    schemaLocation = anyURI    {any attributes with non-schema namespace . . .} >   Content: ( annotation | ( simpleType | complexType | group | attributeGroup | element | attribute | notation ))* </override>

A <schema> information item may contain any number of <override> elements. Their schemaLocation attributes, consisting of a URI reference, identify ("point to") other · schema documents · , that is <schema> information items.

The · XSD schema · corresponding to <schema> contains not only the components corresponding to its definition and declaration [children] , but also all the components mapped to by the (possibly modified) source declarations in any overridden schema documents (after the modifications described below). Overridden schema documents must either (a) have the same targetNamespace as the overriding schema document, or (b) no targetNamespace at all, in which case the overridden schema document is converted to the overriding schema document's targetNamespace .

The children of the <override> element may override any source declarations for · named · components which appear among the [children] of the <schema> , <redefine> , or <override> elements in the · target set · of the <override> element information item..

The definitions within the <override> element itself are not required to be similar in any way to the source declarations being overridden. Not all the source declarations of the overridden schema document need be overridden.

As this mechanism is very similar to <redefine> , many similar kinds of caution need to be taken in using <override> . Please refer to Including modified component definitions ( <redefine> ) (§4.2.3) for details.

4.2.5 References to schema components across namespaces ( <import> )

As described in XSD Abstract Data Model (§2.2) , every top-level schema component is associated with a target namespace (or, explicitly, with none). Furthermore, each schema document carries on its <schema> element at most one targetNamespace attribute associating that document with a target namespace. This section sets out the syntax and mechanisms by which references may be made from within a · schema document · to components not within that document's target namespace. Also included within the same syntax is an optional facility for suggesting the URI of a · schema document · containing definitions and declarations for components from the foreign target namespace.

<import   id = ID   namespace = anyURI   schemaLocation = anyURI    {any attributes with non-schema namespace . . .} >   Content: ( annotation ?) </import>

The <import> element information item identifies namespaces used in external references, i.e. those whose · QName · identifies them as coming from a different namespace (or none) than the enclosing schema document's targetNamespace .

4.2.5.1 Licensing References to Components Across Namespaces

At least two conditions must be satisfied for a reference to be made to a foreign component: (1) there must be a means of addressing such foreign components, and (2) there must be a signal to schema-aware processors that a schema document contains such references. The namespace mechanisms defined by [XML Namespaces 1.1] satisfy the first requirement by allowing foreign components to be addressed. (How those components are located is governed by the processor's strategies for locating schema components in a given namespace, in which the schemaLocation attribute on the <import> element can play a role; see also Terminology of schema construction (§C.2) .) The <import> element information item serves to satisfy the second requirement, by identifying namespaces used in external component references, i.e. those whose · QName · identifies them as coming from a namespace different from that of the enclosing schema document's targetNamespace . By contrast, a namespace used for other purposes in a schema document need not be imported.

The · actual value · of the namespace [attribute] indicates that the containing schema document may contain qualified references to schema components in that namespace (via one or more prefixes declared with namespace declarations in the normal way). If that attribute is absent, then the import allows unqualified reference to components with no target namespace.

It is a consequence of rules defined elsewhere that if references to components in a given namespace N appear in a schema document S , then S must contain an <import> element importing N . Otherwise, the references will fail to resolve; see clause 4 of QName resolution (Schema Document) (§3.17.6.2) . References in a schema document to foreign namespaces not imported by that schema document (or otherwise accounted for by QName resolution (Schema Document) (§3.17.6.2) ) are not "forward references" in the sense of The Mapping between XML Representations and Components (§3.1.3) and are not handled as if they referred to "missing components" in the sense of Missing Sub-components (§5.3) .

Note that components to be imported need not be in the form of a · schema document · and need not in particular be declared in the particular schema document identified by a schemaLocation attribute; the processor is free to access or construct components using means of its own choosing, whether or not a schemaLocation hint is provided.

4.2.5.2 Providing Hints for Schema Document Locations

The · actual value · of the schemaLocation attribute, if present on an <import> element, gives a hint as to where a serialization of a · schema document · with declarations and definitions for the imported namespace (or none) can possibly be found. When no schemaLocation [attribute] is present, the schema author is leaving the identification of that schema to the instance, application or user, via the mechanisms described below in Layer 3: Schema Document Access and Web-interoperability (§4.3) . When a schemaLocation attribute is present, it must contain a single URI reference which the schema author warrants will resolve to a serialization of a · schema document · containing component(s) in the <import> ed namespace.

Conformance profiles may further restrict the use of the schemaLocation attribute. For example, one profile might mandate that the hint be honored by the schema software, perhaps calling for a processor-dependent error should the URI fail to resolve, or mandating that the hint agree with some expected URI value; another profile might mandate that the hint not be honored, etc.

4.3 Layer 3: Schema Document Access and Web-interoperability

Layers 1 and 2 provide a framework for · assessment · and XML definition of schemas in a broad variety of environments. Over time, it is possible that a range of standards and conventions will evolve to support interoperability of XSD implementations on the World Wide Web. Layer 3 defines the minimum level of function required of all conformant processors operating on the Web: it is intended that, over time, future standards (e.g. XML Packages) for interoperability on the Web and in other environments can be introduced without the need to republish this specification.

4.3.1 Standards for representation of schemas and retrieval of schema documents on the Web

For interoperability, serialized · schema documents · , like all other Web resources, should be identified by URI and retrieved using the standard mechanisms of the Web (e.g. http, https, etc.) Such documents on the Web must be part of XML documents (see clause 1.1 ), and are represented in the standard XML schema definition form described by layer 2 (that is as <schema> element information items).

4.3.2 How schema definitions are located on the Web

As described in Layer 1: Summary of the Schema-validity Assessment Core (§4.1) , processors are responsible for providing the schema components (definitions and declarations) needed for · assessment · . This section introduces a set of conventions to facilitate interoperability for instance and schema documents retrieved and processed from the Web.

  • unless directed otherwise by the user, · assessment · is undertaken on the document element information item of the specified document;
  • unless directed otherwise by the user, the processor is required to construct a schema corresponding to a schema document whose targetNamespace is identical to the namespace name, if any, of the element information item on which · assessment · is undertaken.

The composition of the complete schema for use in · assessment · is discussed in Layer 2: Schema Documents, Namespaces and Composition (§4.2) above. The means used to locate appropriate schema document(s) are processor and application dependent, subject to the following requirements:

  • Schemas are represented on the Web in the form specified above in Standards for representation of schemas and retrieval of schema documents on the Web (§4.3.1) ;
  • The author of a document uses namespace declarations to indicate the intended interpretation of names appearing therein; it is possible but not guaranteed that a schema is retrievable via the namespace name. Accordingly whether a processor's default behavior is or is not to attempt such dereferencing, it must always provide for user-directed overriding of that default. Note: Experience suggests that it is not in all cases safe or desirable from a performance point of view to dereference namespace names as a matter of course. User community and/or consumer/provider agreements may establish circumstances in which such dereference is a sensible default strategy: this specification allows but does not require particular communities to establish and implement such conventions. Users are always free to supply namespace names as schema location information when dereferencing is desired: see below.
  • On the other hand, in case a document author (human or not) created a document with a particular schema in view, and warrants that some or all of the document conforms to that schema, the schemaLocation and noNamespaceSchemaLocation [attributes] (in the XSD instance namespace, that is, http://www.w3.org/2001/XMLSchema-instance ) (hereafter xsi:schemaLocation and xsi:noNamespaceSchemaLocation ) are provided. The first records the author's warrant with pairs of URI references (one for the namespace name, and one for a hint as to the location of a schema document defining names for that namespace name). The second similarly provides a URI reference as a hint as to the location of a schema document with no targetNamespace [attribute] . Processors may attempt to dereference each schema document location URI in the · actual value · of such xsi:schemaLocation and xsi:noNamespaceSchemaLocation [attributes] . Schema processors should provide an option to control whether they do so. It is not an error for such an attempt to fail, but failure may cause less than complete · assessment · outcomes. Note: Whether schema location information in the document instance should or should not be dereferenced may vary with the purpose in view. When systems rely on an input document being schema-valid with respect to a particular agreed-upon schema, it is important that they be able to have complete control over the choice of schema used in assessment and in particular that they be able to instruct the processor not to follow any schemaLocation hints in the input. Otherwise, the input document could circumvent the agreement and the consumer's validation of the input, by referring to an alternative schema for the same namespaces, which declares the input document schema-valid but which does not adhere to the prior agreement between the data source and the data consumer. In other cases the purpose of assessment may be not to enforce a prior agreement between data source and consumer, but to annotate the input with type definitions and other useful information from the · post-schema-validation infoset · . In such cases it will often be better to follow the schemaLocation hints. Users who need to exert control over the choice of schema can normally be expected to be aware of the requirement; conversely, users unaware of the issue will typically be those who are not relying on the use of a particular schema to enforce a specific agreement with the data source. Casual users will often benefit from a default behavior of following schemaLocation hints. Useful guidance on how to present this and other questions to end users may be found in the W3C's User Agent Accessibility Guidelines [UAAG 1.0] , [UAAG 2.0] .
  • When schema location values (i.e. schemaLocation attributes on <include> , <redefine> , <override> , and <import> in schema documents, or xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes in instance documents) are dereferenced and the values are relative references, then the [base URI] of the [owner element] must be used to resolve the relative references.
  • According to the rules of Layer 1: Summary of the Schema-validity Assessment Core (§4.1) , the corresponding schema may be lazily assembled, but is otherwise stable throughout · assessment · . Although schema location attributes can occur on any element, and can be processed incrementally as discovered, their effect is essentially global to the · assessment · . Definitions and declarations remain in effect beyond the scope of the element on which the binding is declared.

Improved or alternative conventions for Web interoperability can be standardized in the future without reopening this specification. For example, the W3C is currently considering initiatives to standardize the packaging of resources relating to particular documents and/or namespaces: this would be an addition to the mechanisms described here for layer 3. This architecture also facilitates innovation at layer 2: for example, it would be possible in the future to define an additional standard for the representation of schema components which allowed e.g. type definitions to be specified piece by piece, rather than all at once.

5 Schemas and Schema-validity Assessment

The architecture of schema-aware processing allows for a rich characterization of XML documents: schema validity is not a binary predicate.

This specification distinguishes between errors in schema construction and structure, on the one hand, and schema validation outcomes, on the other.

5.1 Errors in Schema Construction and Structure

Before · assessment · can be attempted, a schema is required. Special-purpose applications are free to determine a schema for use in · assessment · by whatever means are appropriate, but general purpose processors should implement and document a strategy for assembling a schema, exploiting at least some if not all of the non-hard-coded methods outlined in Terminology of schema construction (§C.2) , starting with the namespaces declared in the document whose · assessment · is being undertaken, and the · actual value · s of the xsi:schemaLocation and xsi:noNamespaceSchemaLocation [attributes] thereof, if any, along with any other information about schema identity or schema document location provided by users in application-specific ways, if any.

It is an error if a schema and all the components which are the value of any of its properties, recursively, fail to satisfy all the relevant Constraints on Schemas set out in the last section of each of the subsections of Schema Component Details (§3) .

  • It is an error if any such schema document would not be fully valid with respect to a schema corresponding to the Schema for Schema Documents (Structures) (normative) (§A) , that is, following schema-validation with such a schema, the <schema> element information items would have a [validation attempted] property with value full or partial and a [validity] property with value valid .
  • It is an error if any such schema document is or contains any element information items which violate any of the relevant Schema Representation Constraints set out in Schema Representation Constraints (§B.3) .

The cases described above are the only types of error which this specification defines. With respect to the processes of the checking of schema structure and the construction of schemas corresponding to schema documents, this specification imposes no restrictions on processors in the presence of errors, beyond the requirement that if there are errors in a schema, or in one or more schema documents used in constructing a schema, then a conforming processor must report the fact. However, any further operations performed in the presence of errors are outside the scope of this specification and are not · schema-validity assessment · as that term is defined here.

5.2 Assessing Schema-Validity

With a schema which satisfies the conditions expressed in Errors in Schema Construction and Structure (§5.1) above, the schema-validity of an element or attribute information item (the · validation root · ) can be assessed. Five primary approaches to this are described and given names here; conforming processors may but are not required to provide interfaces so that they can be invoked in ways consistent with any or all of these approaches.

[Definition:]   The element or attribute information item at which · assessment · begins is called the validation root .

The outcome of schema-validity assessment will be manifest in the [validation attempted] and [validity] properties on the · validation root · , and if the · validation root · is an element information item then also on its [attributes] and [children] , recursively, as defined by Assessment Outcome (Element) (§3.3.5.1) and Assessment Outcome (Attribute) (§3.2.5.1) . There is no requirement that input which is not schema-valid be rejected by an application. It is up to applications to decide what constitutes a successful outcome of validation.

Note that every element and attribute information item participating in the · assessment · will also have a [validation context] property which refers back to the · validation root · .

  • · assessment · was not attempted because of a · validation · failure, but declarations and/or definitions are available for at least some of the [children] or [attributes] ;
  • · assessment · was not attempted because a named definition or declaration was missing, but after further effort the processor has retrieved it.
  • · assessment · was not attempted because it was · skipped · , but the processor has at least some declarations and/or definitions available for at least some of the [children] or [attributes] .

5.3 Missing Sub-components

At the beginning of Schema Component Details (§3) , attention is drawn to the fact that most kinds of schema components have properties which are described therein as having other components, or sets of other components, as values, but that when components are constructed on the basis of their correspondence with element information items in schema documents, such properties usually correspond to QNames , and the · resolution · of such QNames can fail, resulting in one or more values of or containing · absent · where a component is mandated.

If at any time during · assessment · , an element or attribute information item is being · validated · with respect to a component of any kind any of whose properties has or contains such an · absent · value, the · validation · is modified, as following:

  • In the case of attribute information items, the effect is as if clause 1 of Attribute Locally Valid (§3.2.4.1) had failed;
  • In the case of element information items, the effect is as if clause 1 of Element Locally Valid (Element) (§3.3.4.3) had failed;
  • In the case of element information items, processors must fall back to · lax assessment · .

Because of the value specification for [validation attempted] in Assessment Outcome (Element) (§3.3.5.1) , if this situation ever arises, the document as a whole cannot show a [validation attempted] of full .

References in a Simple Type Definition to unknown datatypes, or to unknown constraining facets, make the simple type definition unusable in ways similar to having · absent · property values. Often, such references will result in component properties with · absent · values, but not necessarily. In either case they, and likewise any types derived or constructed from them, are handled in the same way as described above for components with · absent · property values.

5.4 Responsibilities of Schema-aware Processors

Schema-aware processors are responsible for processing XML documents, schemas and schema documents, as appropriate given the level of conformance (as defined in Conformance (§2.4) ) they support, consistently with the conditions set out above.

A Schema for Schema Documents (Structures) (normative)

The XML representation of the schema for schema documents is presented here as a normative part of the specification, and as an illustrative example of how the XML Schema Definition Language can define itself using its own constructs. The names of XSD types, elements, attributes and groups defined here are evocative of their purpose, but are occasionally verbose.

There is some annotation in comments, but a fuller annotation will require the use of embedded documentation facilities or a hyperlinked external annotation for which tools are not yet readily available.

Like any other XML document, schema documents may carry XML and document type declarations. An XML declaration and a document type declaration are provided here for convenience. Since this schema document describes the XSD language, the targetNamespace attribute on the schema element refers to the XSD namespace itself.

Schema documents conforming to this specification may be in XML 1.0 or XML 1.1. Conforming implementations may accept input in XML 1.0 or XML 1.1 or both. See Dependencies on Other Specifications (§1.4) .

B Outcome Tabulations (normative)

To facilitate consistent reporting of schema errors and · validation · failures, this section tabulates and provides unique names for all the constraints listed in this document. Wherever such constraints have numbered parts, reports should use the name given below plus the part number, separated by a period ('.'). Thus for example cos-ct-extends.1.2 should be used to report a violation of the clause 1.2 of Derivation Valid (Extension) (§3.4.6.2) .

B.1 Validation Rules

B.2 contributions to the post-schema-validation infoset, b.3 schema representation constraints, b.4 schema component constraints, c terminology for implementation-defined features (normative).

This section defines some terms for use in describing choices made by implementations in areas where the effect of XSD features is explicitly · implementation-defined · .

Future versions of this specification are expected to use the terminology defined here to specify conformance profiles. Conformance profiles may also be defined by other specifications without requiring any revision to this specification.

C.1 Subset of the Post-schema-validation Infoset

This specification defines a number of ways in which the information set taken as input is augmented in the course of schema-validity assessment. Conforming processors may provide access to some or all of this information; in the interests of simplifying discussion and documentation, this section defines names for several subsets of the PSVI, with the intention of simplifying short-hand descriptions of processors. These terms may be used to describe what parts of the PSVI a particular schema processor provides access to, or to specify requirements for processors, or for other purposes. A processor provides access to a particular subset of the PSVI if and only if it makes accessible some representation of the information in question, for information items to which it is applicable. (The properties labeled "if applicable" or "where applicable" below are simply the most obvious cases of properties which do not apply to every information item; the same qualification implicitly applies to all properties listed below.)

If other subsets of the PSVI prove important in practice it is expected that definitions of those subsets may be provided by other specifications or in later revisions of this one.

The definition in this section of a term denoting a particular subset of the PSVI does not constitute a requirement that conforming processors provide access to that subset.

  • [validation attempted]
  • [schema error code] , if applicable
  • [notation system]
  • [notation public]
  • [schema error code]
  • [element attribution]
  • [element declaration]
  • [type definition]
  • [member type definition] (where applicable)
  • [schema normalized value] (where applicable)
  • [schema actual value] (where applicable)
  • [attribute attribution]
  • [attribute declaration]
  • [match information]
  • [type definition name]
  • [type definition namespace]
  • [type definition type]
  • [type definition anonymous]
  • [member type definition name] (where applicable)
  • [member type definition namespace] (where applicable)
  • [member type definition anonymous] (where applicable)
  • [descendent validity]
  • [local element validity]
  • [local type validity]
  • [subsequence-valid]
  • [type fallback]
  • [type alternative]
  • [schema default] (where applicable)
  • [schema information] some · implementation-defined · representation (including at least the names of resources from which components were drawn)
  • [schema normalized value]
  • [schema specified] (where applicable)

C.2 Terminology of schema construction

Conforming processors may implement any combination of the following strategies for locating schema components, in any order. They may also implement other strategies.

The terminology offered here is intended to be useful in discussions of processor behavior, whether documenting existing behavior or describing required behavior.

General-purpose processors should support multiple methods for locating schema documents, and provide user control over which methods are used and how to fall back in case of failure.

C.2.1 Identifying locations where components are sought

C.2.2 identifying methods of indirection, c.2.3 identifying the key for use in indirection, c.2.4 identifying when to stop searching, c.2.5 identifying how to react to failure, c.3 other implementation-defined features.

This section defines terms intended to be useful in describing other implementation-defined choices.

D Required Information Set Items and Properties (normative)

This specification requires as a precondition for · assessment · an information set as defined in [XML Infoset] which contains at least the following information items and properties:

In addition, infosets should support the [unparsed entities] property of the Document Information Item. Failure to do so will mean all items of type ENTITY or ENTITIES will fail to · validate · . If the [unparsed entities] property is supported, the following is also required:

This specification does not require any destructive alterations to the input information set: all the information set contributions specified herein are additive.

This appendix is intended to satisfy the requirements for Conformance to the [XML Infoset] specification.

E Checklists of implementation-defined and implementation-dependent features (normative)

E.1 checklist of implementation-defined features.

[Definition:]   An implementation-defined feature or behavior may vary among processors conforming to this specification; the precise behavior is not specified by this specification but must be specified by the implementor for each particular conforming implementation. (In the latter respect, · implementation-defined · features differ from · implementation-dependent · features.)

This appendix provides a summary of XSD features whose effect is explicitly · implementation-defined · . Any software which claims to conform to this specification must describe how these choices have been exercised, in documentation which accompanies any conformance claim.

In describing the choices made for a given processor, it is hoped that the terminology defined in Terminology for implementation-defined features (normative) (§C) will be found useful.

  • For the datatypes defined by [XML Schema: Datatypes] which depend on [XML 1.1] or [XML Namespaces 1.1] , it is · implementation-defined · whether a schema processor takes the relevant definitions from [XML 1.1] and [XML Namespaces 1.1] , or from [XML 1.0] and [XML Namespaces 1.0] . Implementations may support either the · XML-1.0-based · datatypes, or the · XML-1.1-based · datatypes, or both. The same applies to the definition of whitespace.
  • It is · implementation-defined · whether a schema processor can read schema documents in the form of XML documents. (See Conformance (§2.4) for distinction between " · minimally conforming · " processors and " · schema-document aware · " processors.)
  • Whether a · schema-document aware · processor is able to retrieve schema documents from the Web is · implementation-defined · . (See Conformance (§2.4) , which defines " · Web-aware · " processors as · schema-document aware · processors which can retrieve schema documents from the Web.)
  • The way in which a processor is invoked, and the way in which values are specified for the schema to be used, the information item to be validated, and the declaration or definition with which to begin validation, is · implementation-defined · . (See Assessing Schema-Validity (§5.2) .)
  • The manner in which a processor provides access to the information items and properties in the PSVI to any downstream or user applications, or to the invoker, is · implementation-defined · .
  • The information items and properties in the PSVI to which the processor provides access, if any, is · implementation-defined · . (See Subset of the Post-schema-validation Infoset (§C.1) for some subsets of the PSVI for which this specification provides names and definitions.)
  • When the · post-schema-validation infoset · includes [type definition name] and similar properties, it is · implementation-defined · whether unique names are provided for anonymous type definitions.
  • The method used for assembling a set of schema components for use in validation is · implementation-defined · . (See How schema definitions are located on the Web (§4.3.2) for the normative prose and Terminology of schema construction (§C.2) for some terminology which can be used in describing implementation choices.)
  • It is · implementation-defined · whether a schema processor provides a value for the [type definition name] and [member type definition name] properties of attribute and element information-items. If it does so, the choice of name is · implementation-dependent · .
  • Everything · implementation-defined · in [XML Schema: Datatypes] is also · implementation-defined · in this specification. Note: This includes, but is not limited to, the choice of · XML-1.0-based · or · XML-1.1-based · datatypes, or both; support for · implementation-defined · primitive datatypes; and support for · implementation-defined · constraining facets. See the appendix on implementation-defined and implementation-dependent features in [XML Schema: Datatypes] .
  • It is · implementation-defined · whether a processor detects violations of clause 2.4.2 of Derivation Valid (Restriction, Complex) (§3.4.6.3) (a) always by examination of the schema in isolation, (b) only when some element information item in the input document is valid against its · governing type definition · T but not against T . {base type definition} , or (c) sometimes the one and sometimes the other. In case (c), the circumstances in which the processor does one or the other are · implementation-dependent · .

E.2 Checklist of implementation-dependent features

[Definition:]   An implementation-dependent feature or behavior may vary among processors conforming to this specification; the precise behavior is not specified by this or any other W3C specification and is not required to be specified by the implementor for any particular implementation. (In the latter respect, · implementation-dependent · features differ from · implementation-defined · features.)

This appendix provides a summary of XSD features whose effect is explicitly · implementation-dependent · . Choices made by processors in these areas are not required to be documented.

  • When a default value of type QName or NOTATION is applied to an element or attribute information item, it is · implementation-dependent · whether · namespace fixup · occurs to ensure that the {lexical form} maps to the {value} .
  • When a default value is supplied for a defaulted attribute and more than one prefix is bound to the namespace of the attribute in the [in-scope namespaces] , it is · implementation-dependent · which prefix is used for the attribute.
  • When a default value is supplied for a defaulted attribute and · namespace fixup · is performed, it is · implementation-dependent · what prefix is used in the new namespace information item.
  • When a default value is supplied for a defaulted attribute and · namespace fixup · is performed, it is · implementation-dependent · whether the consistency of the information set is preserved by (a) adding the new binding to the descendants of the element on which the defaulted attribute occurred, or by (b) undeclaring the new binding on the children of that element. When [XML Namespaces 1.0] rather than [XML Namespaces 1.1] is in use, namespace bindings cannot be undeclared, so the behavior is · implementation-dependent · only for those implementations which do support [XML Namespaces 1.1] .
  • If more than one Identity-Constraint Definition fails to be satisfied, it is · implementation-dependent · which of them are included in the [failed identity constraints] property of PSVI.
  • If more than one Assertion fails to be satisfied, it is · implementation-dependent · which of them are included in the [failed assertions] property of PSVI.
  • The order of Annotation components within various components' {annotations} property is · implementation-dependent · .
  • If a name is supplied for anonymous components (for example, [type definition name] and [member type definition name] properties in the · post-schema-validation infoset · ), the choice of name is · implementation-dependent · .
  • If a processor detects some violations of clause 2.4.2 of Derivation Valid (Restriction, Complex) (§3.4.6.3) by examination of the schema in isolation, and others only when some element information item in the input document is valid against its · governing type definition · T but not against T . {base type definition} , then the circumstances in which the processor does one or the other are · implementation-dependent · .

F Stylesheets for Composing Schema Documents (Normative)

The transformations specified in the following sections in the form of [XSLT 2.0] stylesheets are used when assembling schemas from multiple schema documents. Implementations do not have to perform [XSLT 2.0] transformation, or use the stylesheets given here, as long as the same result is produced.

F.1 Transformation for Chameleon Inclusion

  • Add a targetNamespace [attribute] to D2 , whose value is the same as that of the targetNamespace [attribute] of D1 .
  • Update all QName references in D2 that do not have a namespace name so that their namespace names become the · actual value · of the targetNamespace [attribute] .

F.2 Transformation for xs:override

When a <schema> information item D1 contains <override> elements, the transformation specified in the following [XSLT 2.0] stylesheet is performed once for each such <override> element. It requires as parameters (a) the <override> element in D1 (call it O1 ) as the overrideElement parameter and (b) the <schema> element of the schema document D2 identified by the schemaLocation attribute of O1 as the overriddenSchema parameter. The transformation produces another <schema> D2′ , which is equivalent to D2 except that some elements in D2 are replaced or modified, as follows.

The base URI of D2′ is the same as that of D2 .

G Changes since version 1.0 (non-normative)

G.1 changes made since version 1.0.

  • Support for XML 1.1 has been added. It is now implementation defined whether datatypes dependent on definitions in XML ( [XML 1.1] , [XML 1.0] ) and Namespaces in XML ( [XML Namespaces 1.1] , [XML Namespaces 1.0] ) use the definitions as found in version 1.1 or version 1.0 of those specifications.
  • A conditional inclusion mechanism is defined, roughly analogous to the XSLT 2.0 use-when attribute or to the C preprocessor #ifdef construct. By means of the vc:minVersion and vc:maxVersion attributes, a simple forward-processing mechanism is supplied, so that conforming XSD 1.1 processors can successfully ignore constructs introduced in future versions (if any) of XSD, and so that schema authors can define schemas which use newer constructs when available but can fall back on older constructs when the newer constructs are not available.
  • Identifiers for different versions of XSD are now defined in section Schema Language Identifiers (§1.3.4) .
  • The Unique Particle Attribution (§3.8.6.4) constraint has been relaxed. While competition between two · element particles · is still forbidden, as is competition between two · wildcard particles · , competition between an · element particle · and a · wildcard particle · is no longer forbidden. In the course of making this substantive change, some editorial changes have also been made, in order to make the exposition clearer. (Readers familiar with version 1.0 of this specification will find that the constraint works in almost exactly the same way as it did in 1.0, except that content models in which an input item matches either a · wildcard particle · or an · element particle · are now allowed.)
  • Content models may now use the <openContent> element to specify content models with "open content". Such content models allow elements not explicitly mentioned in the content model to appear in the document instance; it is as if wildcards were automatically inserted at appropriate points within the content model. By specifying what kind of wildcard is implicitly inserted, the schema author can adjust the degree of openness and determine what elements are accepted by the open content; the schema author can also specify that the content model should be open everywhere, or only at the end. A schema-document wide default may be set, which causes all content models to be open unless otherwise specified.
  • Wildcards may now be defined which allow names in any namespace but those in a set of proscribed namespaces. (In version 1.0 of this specification, only a single namespace, the target namespace of a schema document, could be proscribed.) Also, wildcards can now be written which match any element in a set of namespaces but which exclude a particular set of qualified names from matching the wildcard. Finally, the keyword ##definedSibling can be used to exclude all elements explicitly mentioned in a content model (and all elements substitutable for those elements).
  • Wildcards can now be defined which match any element (in the specified namespaces) which does not match an element declaration in the schema (so-called "not-in-schema" wildcards).
  • Wildcards are now allowed in all groups.
  • The value of maxOccurs may now be greater than 1 on particles in an all group. The elements which match a particular particle need not be adjacent in the input.
  • all groups can now be extended by adding more members to them.
  • Complex types whose content models are all -groups can now be extended; the result is an all -group (usually a larger one).
  • Support for check clauses to implement some co-occurrence constraints has been added. Each complex type can carry a list of assertions, which are checked when the complex type is used to validate an element information item.
  • The report element described in earlier drafts has been removed. This involves no loss of functionality: the same effect can be obtained by wrapping the test expression on an <assert> element in a negation.
  • The XPath subset defined for assertions has been eliminated. (A somewhat smaller subset is now defined for conditional type assignment.)
  • The static and dynamic contexts for XPath evaluation are explicitly specified.
  • When assertions on a complex type are evaluated, only the subtree rooted in an element of that type is mapped into the data model instance. References to ancestor elements or other nodes outside the subtree are not illegal but will not be effective.
  • For conditional type assignment, neither the ancestors nor the children of the element in question are included; the conditions for type assignment are thus effectively restricted to the attributes of the element.
  • For assertions on simple types, only the value is provided; the dynamic context includes no context item.
  • When assertions are evaluated, all of the elements and attributes descended from the element being validated are typed in the normal way; this has the effect that comparisons among attribute values (for example) are performed in a way consistent with the declarations of the attributes. The element node itself, however, is not typed (since it has not yet been completely validated).
  • For conditional type assignment, the nodes of the data model instance are untyped.
  • The rules for checking validity of complex-type restrictions have been simplified by reformulating the constraint in terms of local validity: the set of elements or attributes accepted by a restriction as locally valid must be a subset of those accepted by its base type. The rules for attributes have also been changed. The complex rules involving matching up particles in the base type and particles in the restriction, with their complex case by case analysis, have been replaced by a statement of the constraint which is shorter and more correct.
  • It is now possible to specify a target namespace for local elements and attributes which differs from the target namespace of the schema document itself, when restricting a complex type which has local elements or attributes and which itself is in another namespace. This should simplify the reuse of types from other namespaces.
  • The rules for complex type restriction now allow identity constraints on local elements. To make this possible, identity constraints may now be given names and referred to from elsewhere. Corresponding changes have been made in the description of the Schema component and in the rules for · QName resolution · .
  • This draft clarifies the rule requiring that any complex type derived by extension could, in principle, be derived in three steps from · xs:anyType · (first a restriction step, then an extension step, then a restriction step). A misleading note about the purpose of this rule has been deleted.
  • The constraint Element Declarations Consistent (§3.8.6.3) has been revised to require more consistency in type assignment when elements with the same expanded name may match both a local element declaration and a wildcard in the same content model. XSD 1.0 allows such content models even if there is a discrepancy between the type assigned to elements by the local element declarations and by the top-level element declaration which will govern elements which match the wildcard. For compatibility reasons, such content models are still allowed, but any element instance which matches the wildcard is required to have a governing type definition compatible with the type assigned by the local element declarations matched by the element's expanded name.
  • The elements <complexType> and <complexContent> are now forbidden to have different values for the mixed attribute.
  • Skip wildcards are now excluded from the Element Declarations Consistent (§3.8.6.3) constraint, and that constraint now also takes open content into account; these changes resolve issue 5940 Element Declarations Consistent .
  • Certain constraints involving ID have been extended to include lists of ID and unions including ID . See e.g. Constraints on Attribute Declaration Schema Components (§3.2.6) .
  • An element may now have multiple attributes of type xs:ID . Elements have always been able to have multiple children of type xs:ID , but XSD 1.0 forbad multiple attributes of this type for compatibility with XML DTDs. (Schemas intended to be translatable into DTD form should still avoid the practice.) This change should make it easier for XML vocabularies to support both existing ID attributes and xml:ID .
  • The validation rules for values of type xs:IDREF , xs:ENTITY , or xs:ENTITIES are now enforced on default values.
  • Elements and attributes of type xs:ID may now have default or fixed values. XSD 1.0 had forbidden this, for compatibility with XML DTDs.
  • A new type definition called anyAtomicType has been introduced into the type hierarchy between anySimpleType and all the atomic built-in type definitions. See Built-in Simple Type Definitions (§3.16.7) .
  • An error in version 1.0 of this specification relating to the construction of union types from other union types has been corrected. Unions may now appear as members of other unions, and all restrictions of unions are correctly enforced, even when xsi:type is used on an element to name a member of the union.
  • The requirement that a facet value be a "valid restriction" of another, in the context of simple type restriction, has been clarified.
  • No union type may be a member of its own transitive membership, nor may any type derived from the union. (XSD 1.0 forbad union datatypes to be members of other unions and thus had no need to forbid this explicitly.)
  • Since not all datatypes have a defined canonical representation for all of their values, appeals to the canonical forms of values have been eliminated.
  • Changes have been made to ensure that the descriptions of the Simple Type Definition component and of · xs:anySimpleType · agree in all details with those of [XML Schema: Datatypes] .
  • Equality and identity of lists have been clarified.
  • Introduction of a Type Table property on element declarations, to hold a sequence of Type Alternative s (condition - selected-type pairs) and a default type definition
  • Constraints on that table: all types named in the table (including the default) must be · validly substitutable · for the declared {type definition} .
  • Changes to the XML syntax and XML mapping rules to allow expression of conditional type bindings: the <alternative> element is added, the content model of <element> is changed.
  • Validation rules for conditional types: a validation-time check on restrictions of complex types ensures that the conditionally assigned types of their children are appropriately related to the types assigned by their base type; see Element Locally Valid (Complex Type) (§3.4.4.2) and Conditional Type Substitutable (§3.4.4.5) ; the definition of · governing type definition · is also adjusted
  • Rules for evaluating the conditional typing tests (more specifically, rules for constructing a temporary infoset and then building the XDM instance and evaluating the XPath expressions as defined elsewhere; priority of tests is given by document order / component order)
  • PSVI changes to reflect details of the conditional typing: a {type alternative} property is added, and the discussion of [type fallback] now refers to the · selected type definition · rather than to either the declared {type definition} or to the · governing type definition · of the element information item
  • Introduction of some terminology for discussing conditional types (define · selected type definition · , · conditionally selects · , · validly substitutable as a restriction · , · context-determined type table · )
  • Rules for checking type restriction in the presence of conditional types
  • Introduction of a special · xs:error · type for use in identifying conditionally assigned types which violate restriction rules
  • Miscellaneous supporting editorial changes
  • Element declarations may now specify multiple substitution-group heads.
  • Abstract elements may now appear in substitution groups.
  • Attribute declarations can now be marked {inheritable} (see Inherited Attributes (§3.3.5.6) ) and the values of inherited attributes are accessible in the XDM data model instance constructed for checking assertions (see Assertions (§3.13) ) and for conditional type assignment (see Type Alternatives (§3.12) ). Among other consequences, this allows conditional type assignment and assertions to be sensitive to the inherited value of the xml:lang attribute and thus to the language of the element's contents. This change was introduced to resolve issue 5003 Applicability of <alternative> element to xml:lang , raised by the W3C Internationalization Core Working Group .
  • The rules for default attribute values now refer to the · effective value constraint · , rather than to the [Value Constraint] ; this resolves a bug in the handling of default values for global attribute declarations.
  • The text now makes clear that it is pointless (although not illegal) for schema documents to supply default or fixed values for xsi:type and other attributes in the namespace http://www.w3.org/2001/XMLSchema-instance , since they will not be applied.
  • Default attribute groups are now supported. The <schema> element can carry a defaultAttributes attribute, which identifies a named Attribute Group Definition ; each complex type defined in the schema document then automatically includes that attribute group, unless this is overridden by the defaultAttributesApply attribute on the <complexType> element. Default attribute groups make it easier to specify attributes which should be accepted by every complex type in a schema (e.g. xml:id and xml:lang ).
  • All wildcard unions are now expressible, and wildcard union is used to combine multiple attribute wildcards, rather than wildcard intersection; this change resolves issue 6163 3.10.6.3 Attribute Wildcard Union .
  • Every component now has an {annotations} property whose value is a sequence of annotation elements and out-of-band attributes. See e.g. The Complex Type Definition Schema Component (§3.4.1) . Annotations are no longer allowed to vary in the part of a content model shared by a complex type and its extensions. (This was never possible in components specified using schema documents, but was possible in "born-binary" components.)
  • A {context} property has been defined for the definitions of complex and of simple types; this property simplifies testing for the identity of anonymous type definitions. See e.g. The Complex Type Definition Schema Component (§3.4.1) . The {context} property replaces the {scope} property found in some earlier drafts of this document.
  • The Schema component has an additional {identity-constraint definitions} property containing all the identity constraints in the corresponding schema. See The Schema Itself (§3.17.1) and XML Representations of Schemas (§3.17.2) .
  • The underlying basis for the definition of all the different kinds of components has changed to make use of a regular and formal tabulation of their properties. This has been achieved by introducing property records wherever version 1.0 had complex property values. For example instead of describing the {scope} property as having "either global or a complex type definition" for its value, a Scope property record is called for, which in turn has its own simple properties and values. See e.g. The Element Declaration Schema Component (§3.3.1) .
  • When an xsi:type attribute appears on an element, and has a QName as its value, but the QName does not resolve to a known type definition, processors are now required to "fall back" to lax validation, using the declared {type definition} of the · governing element declaration · as the · governing type definition · .
  • Element information items which match no particle in a content model are now to be validated using their · locally declared type · . Earlier drafts did not specify what happened in such cases.
  • · Lax assessment · is now required when an element information item to be validated has neither a · governing element declaration · nor a · governing type definition · ; also, lax assessment now requires that the [children] and [attributes] of the element be assessed as well. In XSD 1.0 and in earlier drafts, lax assessment was optional and did not require the recursive assessment of [children] and [attributes] .
  • The text now specifies that if an element has an xsi:type attribute, the · actual value · of that attribute must · resolve · to a type definition, and that type definition must be the · governing type definition · of the element. (This affects only elements without a · governing element declaration · ; other cases were already handled.)
  • The terminology of assessment has been changed to avoid the suggestion that an element information item can be · strictly assessed · without being · assessed · .
  • The presentation of the · post-schema-validation infoset · has been simplified by removing the suggestion that the · post-schema-validation infoset · varies from processor to processor. Instead, the exposition now makes clearer that the body of information available in principle after schema-validity assessment is consistent across all processors; processors may make different subsets of the · post-schema-validation infoset · accessible to downstream applications, but when they do so the variation reflects the implementors' decisions about what information to expose, not variation in the information in the · post-schema-validation infoset · .
  • Terms have been defined to describe different subsets of the · post-schema-validation infoset · which may be exposed by processors.
  • Provision is made for exposing the · actual values · of elements and attributes in the · post-schema-validation infoset · , in the {schema actual value} property.
  • The [element declaration] property and various other properties in the · post-schema-validation infoset · are now described as being present in the · post-schema-validation infoset · whenever a · governing · declaration and/or · governing · type definition is known for the item, instead of only when the item is valid.
  • When the · governing · type definition of an attribute or element information item is a list type whose item type is a union, the · post-schema-validation infoset · now includes the · actual member type definition · for each item in the list.
  • When default values are supplied for attributes with qualified names, · namespace fixup · is performed to ensure that the [in-scope namespaces] property of the attribute's host element has an appropriate binding for the namespace name. It is · implementation-defined · whether · namespace fixup · is also performed on descendants of that element so as to retain consistency of the infoset. · Namespace fixup · may also be helpful if the defaulted value is of type QName or NOTATION ; it is · implementation-dependent · whether fixup is performed for such values.
  • Annotations given in the XML form of identity-constraint declarations with ref attributes are now retained in the · post-schema-validation infoset · form of the containing element declaration. This change resolves issue 6144 annotation on IDC with a 'ref' attribute is lost .
  • The different levels of conformance have been given shorter and more convenient names.
  • A checklist has been included listing ways in which conforming processors may vary from each other, and terminology has been provided for some of the more important properties of conforming processors, in an attempt to make it easier for implementors to describe concisely which options their processors exercise, and easier for users to describe what kinds of processor they require.
  • The definition of must and · error · have been revised to specify that conforming processors must detect and report error in the schema or schema documents. The quality and detail of the error messages are not constrained.
  • Implementations are now allowed to support primitive datatypes and facets beyond those defined in [XML Schema: Datatypes] .
  • The validity requirements for schema documents are stated more fully and correctly.
  • The <redefine> construct is · deprecated · .
  • An <override> construct has been defined; in some ways it resembles <redefine> , but imposes no constraints on the new definitions provided for components whose definitions are being overridden.
  • The discussion of <include> and <override> has been revised to eliminate an ambiguity in earlier versions of this spec regarding the meaning of cyclic dependencies formed by use of <include> and <override> : such cyclic dependencies are now clearly allowed and have a well defined meaning.
  • When an xsi:schemaLocation attribute provides information about a schema document location for a particular namespace, it is no longer an error for it to be encountered after the first occurrence of an element or attribute information item in that namespace. Note, however, that if processing such an xsi:schemaLocation attribute causes new components to be added to the schema, then the new components cannot change the assessment outcome of any information items already seen before the element bearing the xsi:schemaLocation attribute.
  • No <import> is needed in a schema document in order to refer to components in namespaces http://www.w3.org/2001/XMLSchema or http://www.w3.org/2001/XMLSchema-instance . In XSD 1.0, the examples showed no such imports, but there was no rule making it legal to omit the <import> .
  • The handling of "chameleon" inclusion and redefinition in schema documents has been simplified. The new target namespace affects any component or property which would have the target namespace if the schema document specified one. This change makes it easier to write assertions in schema documents without a namespace which are intended to be included by schema documents with varying target namespaces.
  • Section Identifying how to react to failure (§C.2.5) has now been added, defining the terms error and continue for use in specifying what a processor does or should do when it seeks components for a given namespace in a given location but fails to find them there.
  • Schema processors are now explicitly recommended to provide a user option to control whether the processor attempts to dereference schema locations indicated in schemaLocation attributes in the instance document being validated; this resolves issue 5476 xsi:schemaLocation should be a hint, should be MAY not SHOULD .
  • The discussion of schema-validity assessment and the invocation of conforming processors has been revised; additional invocation patterns have been identified, and names have been given to the different methods of invoking a processor.
  • When an element cannot be strictly validated because no element declaration or type definition is available for it, fallback to lax validation (validating the element against the built-in type · xs:anyType · ) is now required; in earlier drafts of this document, fallback to lax validation was optional.
  • The XML Representation Constraints no longer refer to the component level; this makes it possible to test a schema document in isolation to determine whether it conforms or fails to conform to these rules.
  • The constraints on the XML representation of schemas have been reformulated to allow them to be checked on schema documents in isolation, rather than requiring knowledge of the rest of the schema into which they will be embedded. The consequence is that some errors are caught not in the XML representation constraints but by having the XML mapping rules generate faulty components so that the error can be detected at the component level. These changes resolve issue 6235 Restriction from xs:anySimpleType .
  • The <schema> element is now declared with open content in the schema for schema documents. This change addressess issue 5930 defaultOpenContent in the S4SD .
  • The setting blockDefault="#all" has been removed from the schema for schema documents; this change resolves issue 6120 Reconsider blockDefault=#all .
  • Namespace fixup is now explicitly required in some places where it is needed but was not mentioned before; these changes resolve issue 6445 Namespace fixup and default namespace and issue 6465 Namespace fixup and inherited attributes .
  • Each named constraint is now given in a separate section, to simplify reference to them.
  • The XML mapping rules have been reorganized to make them more perspicuous.
  • The keywords defined by [IETF RFC 2119] to designate different levels of requirement have been marked up to distinguish more consistently between cases where their normative meaning is intended (e.g. " must ") and cases where the words are used in its everyday sense without conformance implications (e.g. "must"). See Documentation Conventions and Terminology (§1.5) .
  • A note has been added, warning that the replace and collapse values for whitespace handling are not a reliable means of neutralizing the effects of word-wrapping and pretty-printing of natural-language data and should not be used for that purpose.
  • Several minor corrections and clarifications have been made. The usage of some technical terminology has been clarified, normalized, and aligned where appropriate with the usage in [XML Schema: Datatypes] . Conditionals using "if" have been rephrased to use "if and only if" where appropriate.
  • The title of the specification has been changed, and the language defined here is referred to as XSD, not using the name "XML Schema". This may help reduce confusion between the language defined here and the broader class of XML schema languages in general.
  • Conformance-related language has been reviewed to avoid confusion between the conformance-related usage of the verbs may , must , and should , and other usages.
  • Various new terms have been defined, and some existing terms have been redefined, to reduce confusion and improve legibility. In some cases, existing terms which were felt insufficiently informative have been replaced by new terms which may be more useful.
  • Following the example of XQuery 1.0 and XSLT 2.0, the terms " · implementation-defined · " and " · implementation-dependent · " have been defined and the two concepts distinguished. The appendix contains lists both of · implementation-defined · and of · implementation-dependent · features.
  • The term "context-determined-declaration" has been replaced with the term · locally declared type · ; this resolves issue 4690 Editorial: 'context-determined declarations' needs more work .
  • The namespace prefixes used to refer to well known namespaces have been changed and are now more consistent; this resolves issue 4316 Make sure namespace prefixes are used appropriately throughout structures .
  • Numerous small changes were made in the interests of clarity, completeness, consistency, and precision, and to correct typographical errors. These changes resolve a number of issues, including: 5140 small editorial changes section 3.3 ; 5148 inconsistent target ns description ; 5639 when is value V a valid restriction of value Y? ; 5800 Possibly revise list of required infoset properties ; 5916 Obsolete editorial note ; 5917 Typo in 3.1.1 ; 5934 Typo concerning <simpleContent mixed="true"> ; 6011 [schema11] base URI comments ; 6156 Typo in 3.4.2 ; 6162 <anyAttribute> allows ##definedSibling ; 6165 Constraints on XML representation of anyAttribute ; 6166 Schema Component Model for Wildcards ; 6167 Attribute Wildcard Intersection ; 6170 Wildcards and defaultAttributes ; 6175 Wildcard overlap ; 6227 Type Derivation OK (simple) ; and 6233 Wrong pointer for [nil] PSVI property .

G.2 Issues not resolved

It may be useful to mention some points where possible changes to the specification have been discussed, but on which no changes have, in the end, been made. In some cases, this resulted from the XML Schema Working Group's determination that no change was desirable; in other cases, there was no consensus on the desirability of change, or no consensus on what change should be made.

  • As noted above, some restrictions on all groups have been relaxed; all groups, however, must still be top-level groups; they are not allowed to appear within sequences or choice groups.
  • The namespace-related properties of the basic infoset are · fixed up · when attributes with qualified names are assigned default values. Other kinds of infoset fixup, however, are still not performed. Attributes of type ID , IDREF , IDREFS , and NOTATION do not have the same effect on the base infoset as they do if declared in a DTD. (An infoset-to-infoset transformation can be used to migrate the appropriate information into the base infoset.)
  • Some existing implementations (and specifications) assume that elements of type xs:ID uniquely identify themselves, instead of uniquely identifying their parent. This version of this specification reaffirms the existing rule, which is that elements and attributes of type xs:ID uniquely identify the parent element of the ID attribute or element.
  • The identity of components is still underspecified (although a number of points have been clarified, e.g. by the specification of the {scope} property), with the result that some schemas can be interpreted either as conformant or as non-conformant, depending on the interpretation of the specification's appeals to component identity.
  • The constraint Element Declarations Consistent (§3.8.6.3) has been recast, but not at the higher level of abstraction originally required and expected.
  • The account of schema composition given here has not eliminated all the uncertainties present in XSD 1.0; edge cases remain which different conformant implementations will treat differently.
  • A systematic tabulation of error conditions and definition of a new system of error codes was originally foreseen for XSD 1.1, but has not been completed for inclusion here. No further work in this area is currently anticipated.

H Schema Components Diagram (non-normative)

The following UML class diagram shows the interrelations of element declarations, simple and complex type definitions, and related component classes. In the interests of simplicity, a few liberties have been taken with the notation. For example, direct links are shown from Element Declaration to Simple Type Definition and Complex Type Definition, rather than a single link to a generic Type Definition class specialized by simple and complex types. Similarly, a particle in a content model has exactly one term, which is either an element declaration, a wildcard, or a model group, but this diagram does not show any class created as a generalization of these three.

Diagram of schema components

The following UML class diagram shows the relation of various component classes to the Schema component.

Diagram of schema components

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

J DTD for Schemas (non-normative)

The DTD for schema documents is given below. Note there is no implication here that schema must be the root element of a document.

Although this DTD is non-normative, any XML document which is not valid per this DTD, given redefinitions in its internal subset of the 'p' and 's' parameter entities below appropriate to its namespace declaration of the XSD namespace, is almost certainly not a valid schema document, with the exception of documents with multiple namespace prefixes for the XSD namespace itself. Accordingly authoring · schema documents · using this DTD and DTD-based authoring tools, and specifying it as the DOCTYPE of documents intended to be · schema documents · and validating them with a validating XML parser, are sensible development strategies which users are encouraged to adopt until XSD-based authoring tools and validators are more widely available.

K Analysis of the Unique Particle Attribution Constraint (non-normative)

A specification of the import of Unique Particle Attribution (§3.8.6.4) which does not appeal to a processing model is difficult. What follows is intended as guidance, without claiming to be complete.

  • They are both element declaration particles whose declarations have the same expanded name .
  • They are both element declaration particles and one of them has the same expanded name as an element declaration in the other's · substitution group · .
  • They are both global element declaration particles and their · substitution groups · contain the same element declaration.
  • It has {variety} = any .
  • It has {variety} = not .
  • It has {variety} = enumeration and {namespaces} ≠ the empty set.
  • are both in the {particles} of a choice or all group
  • may · validate · adjacent information items and the first has {min occurs} less than {max occurs} .

Two particles may · validate · adjacent information items if they are separated by at most epsilon transitions in the most obvious transcription of a content model into a finite-state automaton.

A precise formulation of this constraint can also be offered in terms of operations on finite-state automaton: transcribe the content model into an automaton in the usual way using epsilon transitions for optionality and unbounded maxOccurs, unfolding other numeric occurrence ranges and treating the heads of · substitution groups · as if they were choices over all elements in the group, but using not element QNames as transition labels, but rather pairs of element QNames and positions in the model. Determinize this automaton, treating wildcard transitions as if they were distinct from all other edge labels for the purposes of the determinization. Now replace all QName+position transition labels with the element QNames alone. If the result has any states with two or more identical-QName-labeled transitions from it, or two wildcard transitions whose intentional intersection is non-empty, the model does not satisfy the Unique Attribution constraint.

L XSD Language Identifiers (non-normative)

M references, m.1 normative, m.2 non-normative, n acknowledgements (non-normative).

The following contributed material to version 1.0 of this specification:

David Fallside, IBM Scott Lawrence, Agranat Systems Andrew Layman, Microsoft Eve L. Maler, Sun Microsystems Asir S. Vedamuthu, webMethods, Inc

The Working Group thanks the members of other W3C Working Groups and industry experts in other forums who have contributed directly or indirectly to the creation of this document and its predecessor.

The work of C. M. Sperberg-McQueen as a co-editor of this specification was supported by the World Wide Web Consortium through January 2009, and beginning in February 2009 by Black Mesa Technologies LLC.

At the time this Working Draft is published, the members in good standing of the XML Schema Working Group are:

  • Paul V. Biron, Invited expert
  • David Ezell, National Association of Convenience Stores (NACS) ( chair )
  • Shudi (Sandy) Gao 高殊镝, IBM
  • Mary Holstege, Mark Logic
  • Michael Kay, Invited expert
  • Paolo Marinelli, University of Bologna
  • Noah Mendelsohn, IBM
  • Dave Peterson, Invited expert
  • C. M. Sperberg-McQueen, invited expert
  • Henry S. Thompson, University of Edinburgh and W3C ( staff contact )
  • Scott Tsao, The Boeing Company
  • Fabio Vitali, University of Bologna
  • Stefano Zacchiroli, University of Bologna

The XML Schema Working Group has benefited in its work from the participation and contributions of a number of people who are no longer members of the Working Group in good standing at the time of publication of this Working Draft. Their names are given below. In particular we note with sadness the accidental death of Mario Jeckle shortly before publication of the first Working Draft of XML Schema 1.1. Affiliations given are (among) those current at the time of the individuals' work with the WG.

  • Paula Angerstein, Vignette Corporation
  • Leonid Arbouzov, Sun Microsystems
  • Jim Barnette, Defense Information Systems Agency (DISA)
  • David Beech, Oracle Corp.
  • Gabe Beged-Dov, Rogue Wave Software
  • Laila Benhlima, Ecole Mohammadia d'Ingenieurs Rabat (EMI)
  • Doris Bernardini, Defense Information Systems Agency (DISA)
  • Don Box, DevelopMentor
  • Allen Brown, Microsoft
  • Lee Buck, TIBCO Extensibility
  • Greg Bumgardner, Rogue Wave Software
  • Dean Burson, Lotus Development Corporation
  • Charles E. Campbell, Invited expert
  • Oriol Carbo, University of Edinburgh
  • Wayne Carr, Intel
  • Peter Chen, Bootstrap Alliance and LSU
  • Tyng-Ruey Chuang, Academia Sinica
  • Tony Cincotta, NIST
  • David Cleary, Progress Software
  • Mike Cokus, MITRE
  • Dan Connolly, W3C ( staff contact )
  • Ugo Corda, Xerox
  • Roger L. Costello, MITRE
  • Joey Coyle, Health Level Seven
  • Haavard Danielson, Progress Software
  • Josef Dietl, Mozquito Technologies
  • Kenneth Dolson, Defense Information Systems Agency (DISA)
  • Andrew Eisenberg, Progress Software
  • Rob Ellman, Calico Commerce
  • Tim Ewald, Developmentor
  • Alexander Falk, Altova GmbH
  • David Fallside, IBM
  • George Feinberg, Object Design
  • Dan Fox, Defense Logistics Information Service (DLIS)
  • Charles Frankston, Microsoft
  • Matthew Fuchs, Commerce One
  • Andrew Goodchild, Distributed Systems Technology Centre (DSTC Pty Ltd)
  • Xan Gregg, TIBCO Extensibility
  • Paul Grosso, Arbortext, Inc
  • Martin Gudgin, DevelopMentor
  • Ernesto Guerrieri, Inso
  • Dave Hollander, Hewlett-Packard Company ( co-chair )
  • Nelson Hung, Corel
  • Jane Hunter, Distributed Systems Technology Centre (DSTC Pty Ltd)
  • Michael Hyman, Microsoft
  • Renato Iannella, Distributed Systems Technology Centre (DSTC Pty Ltd)
  • Mario Jeckle, DaimlerChrysler
  • Rick Jelliffe, Academia Sinica
  • Marcel Jemio, Data Interchange Standards Association
  • Simon Johnston, Rational Software
  • Kohsuke Kawaguchi, Sun Microsystems
  • Dianne Kennedy, Graphic Communications Association
  • Janet Koenig, Sun Microsystems
  • Setrag Khoshafian, Technology Deployment International (TDI)
  • Melanie Kudela, Uniform Code Council
  • Ara Kullukian, Technology Deployment International (TDI)
  • Andrew Layman, Microsoft
  • Dmitry Lenkov, Hewlett-Packard Company
  • Bob Lojek, Mozquito Technologies
  • John McCarthy, Lawrence Berkeley National Laboratory
  • Matthew MacKenzie, XML Global
  • Eve Maler, Sun Microsystems
  • Ashok Malhotra, IBM, Microsoft, Oracle
  • Murray Maloney, Muzmo Communication, acting for Commerce One
  • Lisa Martin, IBM
  • Jim Melton, Oracle Corp
  • Adrian Michel, Commerce One
  • Alex Milowski, Invited expert
  • Don Mullen, TIBCO Extensibility
  • Ravi Murthy, Oracle
  • Murata Makoto, Xerox
  • Chris Olds, Wall Data
  • Frank Olken, Lawrence Berkeley National Laboratory
  • David Orchard, BEA Systems, Inc.
  • Paul Pedersen, Mark Logic Corporation
  • Shriram Revankar, Xerox
  • Mark Reinhold, Sun Microsystems
  • Jonathan Robie, Software AG
  • Cliff Schmidt, Microsoft
  • John C. Schneider, MITRE
  • Eric Sedlar, Oracle Corp.
  • Lew Shannon, NCR
  • Anli Shundi, TIBCO Extensibility
  • William Shea, Merrill Lynch
  • Jerry L. Smith, Defense Information Systems Agency (DISA)
  • John Stanton, Defense Information Systems Agency (DISA)
  • Tony Stewart, Rivcom
  • Bob Streich, Calico Commerce
  • William K. Stumbo, Xerox
  • Hoylen Sue, Distributed Systems Technology Centre (DSTC Pty Ltd)
  • Ralph Swick, W3C
  • John Tebbutt, NIST
  • Ross Thompson, Contivo
  • Matt Timmermans, Microstar
  • Jim Trezzo, Oracle Corp.
  • Steph Tryphonas, Microstar
  • Mark Tucker, Health Level Seven
  • Asir S. Vedamuthu, webMethods, Inc
  • Scott Vorthmann, TIBCO Extensibility
  • Priscilla Walmsley, XMLSolutions
  • Norm Walsh, Sun Microsystems
  • Cherry Washington, Defense Information Systems Agency (DISA)
  • Aki Yoshida, SAP AG
  • Kongyi Zhou, Oracle

conditional type assignment xsd

  • Latest Articles
  • Top Articles
  • Posting/Update Guidelines
  • Article Help Forum

conditional type assignment xsd

  • View Unanswered Questions
  • View All Questions
  • View C# questions
  • View C++ questions
  • View Javascript questions
  • View PHP questions
  • View Python questions
  • CodeProject.AI Server
  • All Message Boards...
  • Running a Business
  • Sales / Marketing
  • Collaboration / Beta Testing
  • Work Issues
  • Design and Architecture
  • Artificial Intelligence
  • Internet of Things
  • ATL / WTL / STL
  • Managed C++/CLI
  • Objective-C and Swift
  • System Admin
  • Hosting and Servers
  • Linux Programming
  • .NET (Core and Framework)
  • Visual Basic
  • Web Development
  • Site Bugs / Suggestions
  • Spam and Abuse Watch
  • Competitions
  • The Insider Newsletter
  • The Daily Build Newsletter
  • Newsletter archive
  • CodeProject Stuff
  • Most Valuable Professionals
  • The Lounge  
  • The CodeProject Blog
  • Where I Am: Member Photos
  • The Insider News
  • The Weird & The Wonderful
  • What is 'CodeProject'?
  • General FAQ
  • Ask a Question
  • Bugs and Suggestions

if condition in XSD file

conditional type assignment xsd

Add your solution here

  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Print

How to use Conditional Type Assignment for different integer types in XSD

XSD1.1 allows the type of an element to depend on one of its attributes. For example,

will cause the type of 'element' to be xs:short. Here is what I have got:

When I tried to save the file in Altova XMLSpy, an error occurred: cos-st-derived-ok.2: Simple type definition 'xs:byte' is not validly derived from 'GenericInt'.

So how should I correct the XSD code?

No comments:

Post a comment.

Mukul Gandhi

Friday, november 20, 2009, xsd 1.1: some cta samples with xerces-j, no comments:.

Post a Comment

IMAGES

  1. xsd validation

    conditional type assignment xsd

  2. Conditional Sentences with types, structures, and examples and PDF

    conditional type assignment xsd

  3. Conditionals

    conditional type assignment xsd

  4. Conditionals: 04 Types Of Conditional Sentences In Grammar

    conditional type assignment xsd

  5. Sentence formation

    conditional type assignment xsd

  6. Conditional Sentences

    conditional type assignment xsd

VIDEO

  1. [FREE] Type Beat "Challenge"

  2. Pop Smoke

  3. [SOLD] Scarlxrd X Bvdlvd X Trap Metal Type Beat 2023

  4. [FREE] EMOTIONAL DRILL Type Beat X OLDSCHOOL Type Beat

  5. Assassin's creed Rogue remastered #assassinscreed

  6. (FREE) TRAVIS SCOTT X DRAKE TYPE BEAT

COMMENTS

  1. W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures

    The purpose of XML Schema Definition Language: ... conditional type assignment using type alternatives allows the type of an element instance to be chosen based on properties of the element instance (in particular, based on the values of its attributes). 2.2.4.1 Identity-constraint Definition ...

  2. Conditional type assignment

    Conditional type assignment XSD 1.1 supports Conditional Type Assignment to allow the type of an element to depend on the value of one of its attributes. For example the content model for <product action="create"> might be different from the content model for <product action="delete">.

  3. Co-occurrence constraints and Conditional Type Assignment, with XML

    Conditional Type Assignment is an completely new facility introduces in XML Schema 1.1 language. XML Schema 1.1 language a backward compatible with XML Schema 1.0 language. This are that, XML Schema 1.0 validations will run fine with an XML Schema 1.1 processor.

  4. PDF SchemaPath, a Minimal Extension to XML Schema for Conditional Constraints

    of XML Schema to handle conditional constraints on XML documents. Two new constructs have been added to XML Schema: conditions - based on XPath patterns - on type assignments for elements and attributes; and a new simple type, xsd:error, for the direct expression of negative con-straints (e.g. it is prohibited for attribute A to be present if

  5. Xml

    Yes, but be aware that your XSD processor may use the XPath CTA (Conditional Type Assignment) subset by default. (Xerces, and therefore most Xerces-based tools, do this, for example.) (Xerces, and therefore most Xerces-based tools, do this, for example.)

  6. Xml

    I'd like to make an XSD, so that if the value of the attribute "type" is 1, the name and surname elements must be present, and when it's 2, name and id must be there. I tried to generate the XSD in XSD schema generator , but it made the surname and id element minOccurs=0.

  7. Co-occurrence constraints and Conditional Type Assignment, with XML

    The XSD processor that you're using, doesn't seem to support XSD 1.1, and that's why you're getting errors that xs:assert element isn't recognized within your schema document. Two good XSD 1.1 processors that I'm aware of are, Apache Xerces and Saxon (there could be others as well) that you may use.

  8. Answer: How to make type depend on attribute value using Conditional

    Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.. Hide child comments as well

  9. Co-occurrence constraints and Conditional Type Assignment, with XML

    Some form of co-occurrence constraints has past available in XML Schema 1.0 as well-being, which would be discussed as well in get article. Conditional Type Assignment lives a completely new facility introductory in XML Schema 1.1 english. XSD 1.1 xs:alternative/xs:assert

  10. XML Schema (XSD) 1.1: What's new?

    assertions (check clauses) Both involve evaluation of XPath expressions. Based on work by Fabio Vitali et al. Normal type assignment: one declared type for each element. Element E has type T. Conditional type assignment: sequence of test + type pairs. If 〈test 1〉 then type T1. else if 〈test 2〉 then type T2.

  11. Which is conditional required element in an XSD?

    Conditional type assignment: These are a specific type of constraints, that solve the following problems while modeling XML data using XML schemas. Some properties of an element (mainly the absence/presence, or values of its attributes), may require certain types (simple or complex types) to the element. What is if condition in xsd file ...

  12. XSD explained

    XSD is a specification developed by the World Wide Web Consortium (W3C) that defines the structure and content of XML documents. It is an XML-based language used to describe the elements, attributes, data types, and relationships within an XML document.

  13. Assertions on simple types

    XSD 1.1 allows assertions on simple types to be defined. The mechanism is to define an xs:assertion element as a child of the xs:restriction child of the xs:simpleType element (that is, it acts as an additional facet). The type must be an atomic type. The value of the test attribute of xs:assert is an XPath expression.

  14. How to make type depend on attribute value using Conditional Type

    You can do this using XSD 1.1's Conditional Type Assignment:

  15. ConditionalTypeAssignment

    Some proposals around conditional type assigment xsi:type by another name: atom example Usage of Conditional Type Assignment for XML Schema Internationalization and Localization Purposes

  16. Co-occurrence constraints and Conditional Type Assignment, with XML

    This article discusses the XML Schema 1.1 language and specifically its following two property in details: "Co-occurrence constraints", and "Conditional Type Assignment". And article assumes which readers has knowledge to XML, XML Namespaces and basic knowledge of XML Schema (likely the 1.0 version of XML Schedule language) as right.

  17. [TASK] Support for validation XSD version 1.1 #1500

    Issue Description Is your feature request related to a problem? Please describe. The XSD 1.1 allows for Conditional Type Assignment (see https://www.w3.org/TR ...

  18. W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures

    The conceptual overview now included in Constraint Components (§2.2.4) some discussion of the overlap in functionality among identity constraints, conditional type assignment, and assertions, and identifies some of the factors which may be relevant in choosing among them; this change resolves issue 5023 Relationship between identity constra...

  19. if condition in XSD file

    Is it possible to use a xsd schema against an xml file that validates the xml file in the following ways: 1. if Attibute1 value is "XYZ" then Attibute2 value should be "ABC"?

  20. How to use Conditional Type Assignment for different integer types in XSD

    How to use Conditional Type Assignment for different integer types in XSD XSD1.1 allows the type of an element to depend on one of its attributes. For example,

  21. Mukul Gandhi: XSD 1.1: some CTA samples with Xerces-J

    I've been trying to write few XSD 1.1 Conditional Type Assignment (CTA) samples, and trying them to run with the current Xerces-J schema development SVN code. To start with, here's the first example (a very simple one indeed) that I find, which runs fine with Xerces-J:

  22. XML Schema (W3C)

    In XSD 1.1, the type of the element may be conditional on the values of its attributes. An element may belong to a substitution group; if element E is in the substitution group of element H, then wherever the schema permits H to appear, E may appear in its place.

  23. xml

    The XML is validated against the XSD, but in the XSD: If I delete the version attribute, it validates, If I replace the version 1 by 3, it validates, If I delete all the content of person, it validates. There must be something missing on my XSD. See Question&Answers more detail:os