View Old View New View Both View Only Previous Next

This draft contains only sections that have differences from the version that it modified.

W3C

XSL Transformations (XSLT) Version 4.0

W3C Editor's Draft 23 February 2026

This version:
https://qt4cg.org/specifications/xslt-40/
Latest version:
https://qt4cg.org/specifications/xslt-40/
Most recent Recommendation of XSL Transformations (XSLT):
https://www.w3.org/TR/xslt-30/
Editor:
Michael Kay, Saxonica <http://www.saxonica.com/>

The following associated resources are available: Specification in XML format, XSD 1.1 Schema for XSLT 4.0 Stylesheets (non-normative), Relax-NG Schema for XSLT 4.0 Stylesheets (non-normative), Stylesheet for XML-to-JSON conversion (non-normative)


Abstract

This specification defines the syntax and semantics of XSLT 4.0, a language designed primarily for transforming XML documents into other XML documents, but also offering support for other data formats including JSON, HTML, and CSV.

XSLT 4.0 is a revised version of the XSLT 3.0 Recommendation [XSLT 3.0] published on 8 June 2017. Changes are presented in 1.2 What’s New in XSLT 4.0?.

XSLT 4.0 is designed to be used in conjunction with XPath 4.0, which is defined in [XPath 4.0]. XSLT shares the same data model as XPath 4.0, which is defined in [XDM 4.0], and it uses the library of functions and operators defined in [Functions and Operators 4.0]. XPath 4.0 and the underlying function library introduce a number of enhancements, for example the availability of union and record types.

This document contains hyperlinks to specific sections or definitions within other documents in this family of specifications. These links are indicated visually by a superscript identifying the target specification: for example XP for XPath 4.0, DM for the XDM data model version 4.0, FO for Functions and Operators version 4.0, SG for XSLT Streaming version 4.0.

An optional feature of the XSLT language is support for streamed transformations. The XSLT 4.0 specification has been modularized so that streaming is now described in a separate specification document. This has been done in order to make the specifications more manageable, both for editors and readers: it does not alter the status of streaming as an optional feature, available in some processors and not others.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document.

This document is a working draft developed and maintained by a W3C Community Group, the XQuery and XSLT Extensions Community Group unofficially known as QT4CG (where "QT" denotes Query and Transformation). This draft is work in progress and should not be considered either stable or complete. Standard W3C copyright and patent conditions apply.

The community group welcomes comments on the specification. Comments are best submitted as issues on the group's GitHub repository.

The community group maintains two extensive test suites, one oriented to XQuery and XPath, the other to XSLT. These can be found at qt4tests and xslt40-test respectively. New tests, or suggestions for correcting existing tests, are welcome. The test suites include extensive metadata describing the conditions for applicability of each test case as well as the expected results. They do not include any test drivers for executing the tests: each implementation is expected to provide its own test driver.

Dedication

The publications of this community group are dedicated to our co-chair, Michael Sperberg-McQueen (1954–2024).


11 Creating Nodes

This section describes instructions that directly create new nodes.

11.4 Creating Text Nodes

Changes in 4.0 (next | previous)

  1. The xsl:text instruction can now have a select attribute, and it can take a sequence constructor as its content. The only remaining distinction between the xsl:text and xsl:value-of instructions is that whitespace text node children of xsl:text are treated as significant, rather than being stripped during stylesheet preprocessing.   [Issue 323 PR 2251 14 October 2025]

This section describes three different ways of creating text nodes: by means of literal text nodes in the stylesheet, or by using the xsl:text and xsl:value-of instructions. It is also possible to create text nodes using the xsl:number instruction described in 12 Numbering.

If and when the sequence that results from evaluating a sequence constructor is used to form the content of a node, as described in 5.7.2 Constructing Simple Content and 5.7.1 Constructing Complex Content, adjacent text nodes in the sequence are merged. Within the sequence itself, however, they exist as distinct nodes.

Example: A Sequence of Text Nodes

The following function returns a sequence of three text nodes:

<xsl:function name="f:wrap">
  <xsl:param name="s"/>
  <xsl:text>(</xsl:text>
  <xsl:value-of select="$s"/>
  <xsl:text>)</xsl:text>
</xsl:function>

When this function is called as follows:

<xsl:value-of select="f:wrap('---')"/>

the result is:

(---)

No additional spaces are inserted, because the calling xsl:value-of instruction merges adjacent text nodes before atomizing the sequence. However, the result of the instruction:

<xsl:value-of select="data(f:wrap('---'))"/>

is:

( --- )

because in this case the three text nodes are atomized to form three strings, and spaces are inserted between adjacent strings.

This example reflects the traditional usage of xsl:text to output constant text and xsl:value-of to output variable text. In XSLT 4.0, however, either instruction can be used for either purpose, and in the example above either instruction could be replaced by the other.

It is possible to construct text nodes whose string value is zero-length. A zero-length text node, when atomized, produces a zero-length string. However, zero-length text nodes are ignored when they appear in a sequence that is used to form the content of a node, as described in 5.7.1 Constructing Complex Content and 5.7.2 Constructing Simple Content.

11.4.3 Generating CDATA Sections

Changes in 4.0 (next | previous)

  1. The attribute cdata is added to xsl:text and xsl:value-of to request serialization of a text node as a CDATA section.  [Issue 2198 PR 2301 19 November 2025]

The XDM data model (see [XDM 4.0]) does not recognize CDATA sections as a special kind of node; CDATA is regarded simply as one way of serializing a text node. The elements <e>x &lt; y</e> and <e><![CDATA[x < y]]></e> have exactly the same representation in XDM: an element node with a text node child, the string value of the text node being "x < y".

It is however possible to request that a text node should be serialized as a CDATA section. If all elements with a given name are to be serialized as CDATA, this can be achieved using the serialization parameter cdata-section-elements (available, for example, as an attribute on xsl:output and xsl:result-document). If CDATA serialization is to be used more selectively than this, it can also be requested using the cdata attribute on the xsl:text and xsl:value-of instructions.

The cdata attribute, if its effective value is yes, is a request to the processor to serialize the text node as a CDATA section. For example, the text node produced by the instruction <xsl:text cdata="yes">>>></xsl:text> might be serialized as <![CDATA[>>>]]>. Honoring this request requires close coupling between the processor and the serializer, and processors may therefore ignore the request. In particular, it is likely that a processor will ignore the request unless the result of the transformation is passed directly to the serializer, bypassing the construction of an in-memory result tree.

It is implementation-defined whether, and under what circumstances, the cdata attribute of the xsl:text and xsl:value-of instructions has any effect on the serialized output.

Note:

A processor delivering output in the form of an in-memory tree using a data model (such as the DOM model) that includes CDATA nodes may take account of the cdata attribute to generate such nodes.

If the cdata attribute is present, regardless of its effective value, then the disable-output-escaping attribute is ignored.

Note:

The attribute is likely to have no effect only in the following circumstances:

  • The output of the transformation is not sent directly to a serializer (or to another destination, such as a DOM, that recognizes CDATA).

  • The serialization method is not xml or xhtml (perhaps invoked indirectly via the html or adaptive output methods).

  • The text node produced by the xsl:text or xsl:value-of instruction is not bound to a variable.

  • The parent element of the text node is not listed in the cdata-section-elements serialization parameter (in this case every text node child of the element should be serialized as a CDATA section, regardless of any cdata attributes).

  • The text node is not used as input to the process of constructing an attribute, comment, processing instruction, or another text node: see 5.7.2 Constructing Simple Content.

  • The text node is not used as input to the process of constructing a temporary tree.

Note:

The cdata attribute is an attribute value template, so the value can be made conditional on the actual content of the text. For example, the instruction:

<xsl:value-of select="$s" cdata="{matches($s, '[&lt;&amp;]')}"/>

will request serialization as a CDATA section if the text contains either of the characters < or &.

The serializer should serialize the content of the text node following the same conventions as are used for cdata-section-elements: in particular, if the data includes the character sequence ]]>, then the CDATA section should be closed, and a new CDATA section opened, after the ]].

Editorial note 

Add this attribute to the schema for XSLT 4.0

Note:

Whether or not the output of an xsl:text or xsl:value-of instruction is “sent directly to a serializer” is essentially implementation-defined. There may be cases that vary between processors, for example an instruction that returns the result of a stylesheet function.

The effect of setting cdata="yes" (in cases where it has any effect at all) is as if the text node were wrapped in a containing element whose name is listed in the cdata-section-elements parameter, with the start and end tags of that element then being stripped from the serialized output.

This implies:

  • If the text node includes the character sequence ]]>, then the CDATA section must be closed, and a new CDATA section opened, after the ]].

  • Similarly, if the text node includes a codepoint that cannot be represented using the selected encoding, then the CDATA section must be closed, and a new CDATA section opened, after the escaped representation of that codepoint.

  • Unicode normalization does not operate across the boundary between a CDATA and a non-CDATA text node.

  • Character mapping (as defined by the use-character-maps parameter) does not take place within a CDATA text node.

  • Special characters such as & and < in a CDATA text node are not escaped.

H Schemas for XSLT 4.0 Stylesheets (Non-Normative)

For convenience, schemas are provided for validation of XSLT 4.0 stylesheets using the XSD 1.1 and Relax NG schema languages. These are non-normative. Neither will detect every static error that might arise in an XSLT 4.0 stylesheet (for example, there is no attempt to check the syntax of XPath expressions); in addition, these schemas may reject some stylesheets that are valid, for example because they rely on xsl:use-when to eliminate sections of code that would otherwise be invalid.

H.1 XSD 1.1 Schema for XSLT Stylesheets

The following XSD 1.1 schema describes the structure of an XSLT stylesheet module. There are some limitations:

  • It does not define all the constraints that apply to a stylesheet (for example, it does not attempt to define a datatype that precisely represents attributes containing XPath expressions).

  • Stylesheets that use forwards compatible behavior (an [xsl:]version attribute greater than 4.0), or that have sections excluded using [xsl:]use-when attributes, are not required to conform to the schema.

  • The specification allows xsl:note elements to appear anywhere, but this schema is more restrictive.

A copy of this schema is available at schema-for-xslt40.xsd

Note:

The schema as written uses a lax wildcard to permit literal result elements to appear in a sequence constructor. This assumes that the schema used for validation will not contain any global element declaration that matches the element name of a literal result element. The content model for an element such as invoice appearing within a stylesheet is not the same as the content model for the same element appearing within a source document (it is likely to contain XSLT instructions rather than other elements from the target vocabulary): therefore, including such declarations in the schema used for validating a stylesheet is inappropriate.

The reason that lax validation rather than skip validation is used is so that XSLT instructions appearing as children of the literal result element will themselves be validated, using the appropriate global element declaration.

Note:

The schema uses XSD 1.1 assertions to represent some of the non-grammatical constraints appearing in the specification, for example the rule that some elements can have either a select attribute or a contained sequence constructor, but not both. At this stage, no attempt has been made to represent every such constraint, even where it is not difficult to express the rule. There will always be some constraints that cannot be expressed at all, for example those that require access to multiple stylesheet modules, those that require access to the in-scope schema components, and those that involve parsing a non-regular grammar, such as the grammar for patterns.

Apart from assertions, the only other significant use of XSD 1.1 features is that the elements xsl:param and xsl:variable are in two substitution groups: one containing all instructions, and one containing all declarations. If the schema needs to be converted to an XSD 1.0 schema, removing all assertions is straightforward; the other change needed is to remove xsl:param and xsl:variable from the substitution group for declarations, and instead permit them explicitly as children of xsl:transform.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
           xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
           targetNamespace="http://www.w3.org/1999/XSL/Transform"
           elementFormDefault="qualified"
           vc:minVersion="1.1">

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         This is an XSD 1.1 schema for XSLT 4.0 stylesheets. It defines all the
         elements that appear in the XSLT namespace; it also provides hooks that
         allow the inclusion of user-defined literal result elements, extension
         instructions, and top-level data elements.
      </p>
      <p>
         This schema is available for use under the conditions of the W3C Software
         License published at
         http://www.w3.org/Consortium/Legal/copyright-software-19980720
      </p>
      <p>
         The schema is organized as follows:
      </p>
      <ul>
        <li>
           PART A: definitions of complex types and model groups used as the basis
           for element definitions
        </li>
        <li>
           PART B: definitions of individual XSLT elements
        </li>
        <li>
           PART C: definitions for literal result elements
        </li>
        <li>
           PART D: definitions of simple types used in attribute definitions
        </li>
      </ul>
      <p>
         The schema has a number of limitations:
      </p>
      <ul>
        <li>
           The XSLT specification allows additional elements and attributes to be
           present where forwards compatibility is invoked. This schema does not.
        </li>
        <li>
           The XSLT specification allows arbitrary content in a part of the
           stylesheet that is excluded by virtue of a use-when attribute. This
           schema does not.
        </li>
        <li>
           The handling of literal result elements in this schema is imperfect;
           although various options are allowed, none matches the specification
           exactly. For example, the content of a literal result element uses lax
           validation, which permits child elements in the XSLT namespace that have
           no declaration in this schema.
        </li>
        <li>
           The schema makes no attempt to check XPath expressions for syntactic or
           semantic correctness, nor to check that component references are
           resolved (for example that a template named in <code>xsl:call-template</code> has a
           declaration). Doing this in general requires cross-document validation,
           which is beyond the scope of XSD.
        </li>
        <li>
           The XSLT specification allows <code>xsl:note</code> elements to appear
           anywhere, with arbitrary content. This schema does not: for example, it does
           not allow <code>xsl:note</code> as a child of an element such as <code>xsl:text</code>
           or <code>xsl:strip-space</code>.
        </li>
        <li>
           The schema imports the schema for XSD 1.0 schema documents. In
           stylesheets that contain an inline XSD 1.1 schema, this import should be
           replaced with one for the schema for XSD 1.1 schema documents.
        </li>
      </ul>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <!--
The declaration of xml:space and xml:lang may need to be commented out because
of problems processing the schema using various tools
-->

  <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
  <!--schemaLocation="http://www.w3.org/2001/xml.xsd"-->

  <!-- 
    An XSLT stylesheet may contain an in-line schema within an xsl:import-schema element,
    so the Schema for schemas needs to be imported. We use the XSD 1.1 version.
-->

  <xs:import namespace="http://www.w3.org/2001/XMLSchema"
             schemaLocation="http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd"/>

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         PART A: definitions of complex types and model groups used as the basis
         for element definitions
      </p>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  
  <xs:defaultOpenContent>
    <!-- Allow xsl:note anywhere -->
    <xs:any processContents="strict" 
            namespace="##targetNamespace"
            notQName="xsl:accept 
                      xsl:accumulator 
                      xsl:accumulator-rule 
                      xsl:analyze-string 
                      xsl:apply-imports 
                      xsl:apply-templates 
                      xsl:array 
                      xsl:assert 
                      xsl:attribute 
                      xsl:attribute-set 
                      xsl:break 
                      xsl:call-template 
                      xsl:catch 
                      xsl:character-map 
                      xsl:choose 
                      xsl:comment 
                      xsl:context-item 
                      xsl:copy 
                      xsl:copy-of 
                      xsl:document 
                      xsl:decimal-format 
                      xsl:element 
                      xsl:evaluate 
                      xsl:expose 
                      xsl:fallback
                      xsl:field 
                      xsl:for-each 
                      xsl:for-each-group 
                      xsl:fork 
                      xsl:function 
                      xsl:global-context-item 
                      xsl:if 
                      xsl:import 
                      xsl:import-schema 
                      xsl:include 
                      xsl:iterate 
                      xsl:key 
                      xsl:map 
                      xsl:map-entry 
                      xsl:matching-substring 
                      xsl:merge 
                      xsl:merge-action 
                      xsl:merge-key 
                      xsl:merge-source 
                      xsl:message 
                      xsl:mode 
                      xsl:namespace 
                      xsl:namespace-alias 
                      xsl:next-iteration 
                      xsl:next-match 
                      xsl:non-matching-substring 
                      xsl:number 
                      xsl:on-completion 
                      xsl:on-empty 
                      xsl:on-non-empty 
                      xsl:otherwise 
                      xsl:output 
                      xsl:output-character 
                      xsl:override 
                      xsl:package 
                      xsl:param 
                      xsl:perform-sort 
                      xsl:preserve-space 
                      xsl:processing-instruction
                      xsl:record 
                      xsl:record-type 
                      xsl:result-document
                      xsl:select
                      xsl:sequence 
                      xsl:sort 
                      xsl:source-document 
                      xsl:strip-space 
                      xsl:stylesheet 
                      xsl:switch 
                      xsl:template 
                      xsl:text 
                      xsl:transform 
                      xsl:try 
                      xsl:use-package 
                      xsl:value-of 
                      xsl:variable 
                      xsl:when 
                      xsl:where-populated 
                      xsl:with-param
            "/>
  </xs:defaultOpenContent>
  
  <xs:complexType name="generic-element-type" mixed="true">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type provides a generic supertype for all XSLT elements except 
           <code>xsl:record</code>; it contains the definitions of the standard attributes 
           that may appear on any element.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="default-collation" type="xsl:uri-list"/>
    <xs:attribute name="default-mode" type="xsl:default-mode-type"/>
    <xs:attribute name="default-validation"
                  type="xsl:validation-strip-or-preserve"
                  default="strip"/>
    <xs:attribute name="exclude-result-prefixes" type="xsl:prefix-list-or-all"/>
    <xs:attribute name="expand-text" type="xsl:yes-or-no"/>
    <xs:attribute name="extension-element-prefixes" type="xsl:prefix-list"/>
    <xs:attribute name="schema-role" type="xs:NCName"/>
    <xs:attribute name="use-when" type="xsl:expression"/>
    <xs:attribute name="xpath-default-namespace" type="xs:anyURI"/>
    <xs:attribute name="_default-collation" type="xs:string"/>
    <xs:attribute name="_default-mode" type="xs:string"/>
    <xs:attribute name="_default-validation" type="xs:string"/>
    <xs:attribute name="_exclude-result-prefixes" type="xs:string"/>
    <xs:attribute name="_expand-text" type="xs:string"/>
    <xs:attribute name="_extension-element-prefixes" type="xs:string"/>
    <xs:attribute name="_schema-role" type="xs:string"/>
    <xs:attribute name="_use-when" type="xs:string"/>
    <xs:attribute name="_xpath-default-namespace" type="xs:string"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>
  
  <xs:complexType name="element-only-generic-element-type" mixed="false">
    <xs:complexContent>
      <xs:restriction base="xsl:generic-element-type"/>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="versioned-element-type" mixed="true">
    <xs:annotation>
      <xs:documentation>
        <p>This complex type provides a generic supertype for all XSLT elements with
                the exception of <code>xsl:output</code> and <code>xsl:record</code>; it contains the
                definitions of the <code>version</code> attribute that may appear on any element.
                </p>
        <p>The <code>xsl:output</code> element does not use this definition because, although it
             has a <code>version</code> attribute, the syntax and semantics of this attribute are
             unrelated to the standard <code>version</code> attribute allowed on other elements.</p>
        <p>Similarly <code>xsl:record</code> does not use this definition because it expects
        standard attributes (including [xsl:]version) to be in the XSLT namespace.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="xsl:generic-element-type">
        <xs:attribute name="version" type="xs:decimal" use="optional"/>
        <xs:attribute name="_version" type="xs:string"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="element-only-versioned-element-type" mixed="false">
    <xs:complexContent>
      <xs:restriction base="xsl:versioned-element-type">
        <xs:anyAttribute namespace="##other" processContents="lax"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="sequence-constructor">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type provides a generic supertype for all XSLT elements
           that allow a sequence constructor as their content.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="true">
      <xs:extension base="xsl:versioned-element-type">
        <xs:group ref="xsl:sequence-constructor-group"
                  minOccurs="0"
                  maxOccurs="unbounded"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="sequence-constructor-and-select">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type allows a sequence constructor and a select attribute.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="true">
      <xs:extension base="xsl:sequence-constructor">
        <xs:attribute name="select" type="xsl:expression"/>
        <xs:attribute name="_select" type="xs:string"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="sequence-constructor-or-select">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type allows a sequence constructor or a select attribute,
           but not both.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="true">
      <xs:restriction base="xsl:sequence-constructor-and-select">
        <xs:group ref="xsl:sequence-constructor-group"
                  minOccurs="0"
                  maxOccurs="unbounded"/>
        <xs:anyAttribute namespace="##other" processContents="lax"/>
        <xs:assert test="not(exists(@select | @_select) and 
          (exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:group name="sequence-constructor-group">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type provides a generic supertype for all XSLT elements
           that allow a sequence constructor as their content.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:choice>
      <xs:element ref="xsl:instruction"/>
      <xs:element ref="xsl:record"/>
      <xs:group ref="xsl:result-elements"/>
    </xs:choice>
  </xs:group>

  <xs:element name="declaration" type="xsl:generic-element-type" abstract="true"/>

  <xs:element name="instruction" type="xsl:versioned-element-type" abstract="true"/>

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         PART B: definitions of individual XSLT elements Elements are listed in
         alphabetical order.
      </p>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  
  <xs:element name="accept">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:use-package</code> and defines 
            any variations that the containing package wishes to make to the visibility of
            components made available from a library package. For example, it may indicate that
            some of the public components in the library package are not to be made available
            to the containing package.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="component" type="xsl:component-kind-type"/>
          <xs:attribute name="names" type="xsl:component-tests"/>
          <xs:attribute name="visibility" type="xsl:visibility-type"/>
          <xs:attribute name="_component" type="xs:string"/>
          <xs:attribute name="_names" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@component | @_component)"/>
          <xs:assert test="exists(@names | @_names)"/>
          <xs:assert test="exists(@visibility | @_visibility)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="accumulator" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:accumulator-rule" minOccurs="1" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="initial-value" type="xsl:expression"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_initial-value" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="accumulator-rule">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:sequence/>
          <xs:attribute name="match" type="xsl:pattern"/>
          <xs:attribute name="phase">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="start"/>
                <xs:enumeration value="end"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="capture" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="_match" type="xs:string"/>
          <xs:attribute name="_phase" type="xs:string"/>
          <xs:attribute name="_capture" type="xs:string"/>
          <xs:assert test="exists(@match | @_match)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="analyze-string" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:matching-substring" minOccurs="0"/>
            <xs:element ref="xsl:non-matching-substring" minOccurs="0"/>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="regex" type="xsl:avt"/>
          <xs:attribute name="flags" type="xsl:avt" default=""/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_regex" type="xs:string"/>
          <xs:attribute name="_flags" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
          <xs:assert test="exists(@regex | @_regex)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="apply-imports" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="apply-templates" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:sort"/>
            <xs:element ref="xsl:with-param"/>
          </xs:choice>
          <xs:attribute name="select" type="xsl:expression" default="child::node()"/>
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="mode" type="xsl:mode"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_mode" type="xs:string"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="array" 
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="for-each" type="xsl:expression"/>
          <xs:attribute name="_for-each" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="array-member"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="assert" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="test" type="xsl:expression"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="error-code" type="xsl:avt"/>
          <xs:attribute name="_test" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_error-code" type="xs:string"/>
          <xs:assert test="exists(@test | @_test)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="attribute" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="namespace" type="xsl:avt"/>
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_namespace" type="xs:string"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="attribute-set" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:attribute"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no"/>
          <xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-attribute-sets" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="break"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>

  <xs:element name="call-template" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="catch">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="errors" type="xsl:nametests" use="optional"/>
          <xs:attribute name="_errors" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="character-map" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:output-character" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="use-character-maps" type="xsl:EQNames" default=""/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_use-character-maps" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="choose" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:when" maxOccurs="unbounded"/>
            <xs:element ref="xsl:otherwise" minOccurs="0"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="comment"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="context-item">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="as" type="xsl:item-type"/>
          <xs:attribute name="use">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="required"/>
                <xs:enumeration value="optional"/>
                <xs:enumeration value="absent"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_use" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="copy" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_copy-namespaces" type="xs:string"/>
          <xs:attribute name="_inherit-namespaces" type="xs:string"/>
          <xs:attribute name="_use-attribute-sets" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="copy-of" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="copy-accumulators" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_copy-accumulators" type="xs:string"/>
          <xs:attribute name="_copy-namespaces" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="document" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="decimal-format" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="decimal-separator" type="xsl:char-optionally-expanded" default="."/>
          <xs:attribute name="grouping-separator" type="xsl:char-optionally-expanded" default=","/>
          <xs:attribute name="infinity" type="xs:string" default="Infinity"/>
          <xs:attribute name="minus-sign" type="xs:string" default="-"/>
          <xs:attribute name="exponent-separator" type="xsl:char-optionally-expanded" default="e"/>
          <xs:attribute name="NaN" type="xs:string" default="NaN"/>
          <xs:attribute name="percent" type="xsl:char-optionally-expanded" default="%"/>
          <xs:attribute name="per-mille" type="xsl:char-optionally-expanded" default="‰"/>
          <xs:attribute name="zero-digit" type="xsl:zero-digit" default="0"/>
          <xs:attribute name="digit" type="xsl:char" default="#"/>
          <xs:attribute name="pattern-separator" type="xsl:char" default=";"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_decimal-separator" type="xs:string"/>
          <xs:attribute name="_grouping-separator" type="xs:string"/>
          <xs:attribute name="_infinity" type="xs:string"/>
          <xs:attribute name="_minus-sign" type="xs:string"/>
          <xs:attribute name="_exponent-separator" type="xs:string"/>
          <xs:attribute name="_NaN" type="xs:string"/>
          <xs:attribute name="_percent" type="xs:string"/>
          <xs:attribute name="_per-mille" type="xs:string"/>
          <xs:attribute name="_zero-digit" type="xs:string"/>
          <xs:attribute name="_digit" type="xs:string"/>
          <xs:attribute name="_pattern-separator" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="element" substitutionGroup="xsl:instruction">
    <xs:complexType mixed="true">
      <xs:complexContent>
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="namespace" type="xsl:avt"/>
          <xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_namespace" type="xs:string"/>
          <xs:attribute name="_inherit-namespaces" type="xs:string"/>
          <xs:attribute name="_use-attribute-sets" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="evaluate" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:with-param"/>
            <xs:element ref="xsl:fallback"/>
          </xs:choice>
          <xs:attribute name="xpath" type="xsl:expression"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="base-uri" type="xsl:avt"/>
          <xs:attribute name="context-item" type="xsl:expression"/>
          <xs:attribute name="namespace-context" type="xsl:expression"/>
          <xs:attribute name="schema-aware" type="xsl:avt"/>
          <xs:attribute name="trusted" type="xsl:avt"/>
          <xs:attribute name="with-params" type="xsl:expression"/>
          <xs:attribute name="_xpath" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_base-uri" type="xs:string"/>
          <xs:attribute name="_context-item" type="xs:string"/>
          <xs:attribute name="_namespace-context" type="xs:string"/>
          <xs:attribute name="_schema-aware" type="xs:string"/>
          <xs:attribute name="_trusted" type="xs:string"/>
          <xs:attribute name="_with-params" type="xs:string"/>
          <xs:assert test="exists(@xpath | @_xpath)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="expose">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:use-package</code> and defines 
            the visibility of components that are made available (or not) by this package
            to other using packages.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="component" type="xsl:component-kind-type"/>
          <xs:attribute name="names" type="xsl:component-tests"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="_component" type="xs:string"/>
          <xs:attribute name="_names" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@component | @_component)"/>
          <xs:assert test="exists(@names | @_names)"/>
          <xs:assert test="exists(@visibility | @_visibility)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="fallback"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor"/>
  
  <xs:element name="field">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="name" type="xs:NCName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="required" type="xsl:yes-or-no"/>
          <xs:attribute name="default" type="xsl:expression"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_required" type="xs:string"/>
          <xs:attribute name="_default" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="for-each" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="for-each-group" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="group-by" type="xsl:expression"/>
          <xs:attribute name="group-adjacent" type="xsl:expression"/>
          <xs:attribute name="group-starting-with" type="xsl:pattern"/>
          <xs:attribute name="group-ending-with" type="xsl:pattern"/>
          <xs:attribute name="split-when" type="xsl:expression"/>
          <xs:attribute name="composite" type="xsl:yes-or-no"/>
          <xs:attribute name="collation" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_group-by" type="xs:string"/>
          <xs:attribute name="_group-adjacent" type="xs:string"/>
          <xs:attribute name="_group-starting-with" type="xs:string"/>
          <xs:attribute name="_group-ending-with" type="xs:string"/>
          <xs:attribute name="_split-when" type="xs:string"/>
          <xs:attribute name="_composite" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="count(((@group-by|@_group-by)[1], 
                                  (@group-adjacent|@_group-adjacent)[1], 
                                  (@group-starting-with|@_group-starting-with)[1], 
                                  (@group-ending-with|@_group-ending-with)[1],
                                  (@split-when|@_split-when)[1])) = 1">
            <xs:annotation>
              <xs:documentation>
                <p>
                   These four attributes are mutually exclusive: it is a static
                   error if none of these four attributes is present or if more
                   than one of them is present.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (exists(@collation|@_collation) or exists(@composite|@_composite)) 
                           then (exists(@group-by|@_group-by) or exists(@group-adjacent|@_group-adjacent)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is an error to specify the collation attribute or the
                   composite attribute if neither the group-by attribute nor
                   group-adjacent attribute is specified.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="fork" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
            <xs:choice>
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="xsl:sequence"/>
                <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
              <xs:sequence>
                <xs:element ref="xsl:for-each-group"/>
                <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
            </xs:choice>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="function" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="override" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="as" type="xsl:sequence-type" default="item()*"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="streamability" type="xsl:streamability-type"/>
          <xs:attribute name="override-extension-function" type="xsl:yes-or-no"/>
          <xs:attribute name="new-each-time" type="xsl:yes-or-no-or-maybe"/>
          <xs:attribute name="cache" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_override" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:attribute name="_streamability" type="xs:string"/>
          <xs:attribute name="_override-extension-function" type="xs:string"/>
          <xs:attribute name="_new-each-time" type="xs:string"/>
          <xs:attribute name="_cache" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="every $e in xsl:param satisfies empty($e/(@visibility | @_visibility))">
            <xs:annotation>
              <xs:documentation>
                <p>A parameter for a function must have no <code>visibility</code> attribute.</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="global-context-item" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="as" type="xsl:item-type"/>
          <xs:attribute name="use">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="required"/>
                <xs:enumeration value="optional"/>
                <xs:enumeration value="absent"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_use" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  

  <xs:element name="if" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="test" type="xsl:expression"/>
          <xs:attribute name="then" type="xsl:expression"/>
          <xs:attribute name="else" type="xsl:expression"/>
          <xs:attribute name="_test" type="xs:string"/>
          <xs:attribute name="_then" type="xs:string"/>
          <xs:attribute name="_else" type="xs:string"/>
          <xs:assert test="exists(@test | @_test)"/>
          <xs:assert test="not(exists(@then | @_then) and 
            (exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="import" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="href" type="xs:anyURI"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:assert test="exists(@href | @_href)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="import-schema" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xs:schema" minOccurs="0" maxOccurs="1"/>
          </xs:sequence>
          <xs:attribute name="namespace" type="xs:anyURI"/>
          <xs:attribute name="role" type="xs:NCName"/>
          <xs:attribute name="schema-location" type="xs:anyURI"/>
          <xs:attribute name="_namespace" type="xs:string"/>
          <xs:attribute name="_role" type="xs:string"/>
          <xs:attribute name="_schema-location" type="xs:string"/>
          <xs:assert test="not(exists(@schema-location | @_schema-location) and exists(xs:schema))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   XTSE0215: It is a static error if an <code>xsl:import-schema</code> element
                   that contains an xs:schema element has a <code>schema-location</code>
                   attribute
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="include" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="href" type="xs:anyURI"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:assert test="exists(@href | @_href)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="iterate" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element ref="xsl:on-completion" minOccurs="0" maxOccurs="1"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="key" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="match" type="xsl:pattern"/>
          <xs:attribute name="use" type="xsl:expression"/>
          <xs:attribute name="composite" type="xsl:yes-or-no"/>
          <xs:attribute name="collation" type="xs:anyURI"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_match" type="xs:string"/>
          <xs:attribute name="_use" type="xs:string"/>
          <xs:attribute name="_composite" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="exists(@match | @_match)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="map"
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-and-select">
          <xs:attribute name="duplicates" type="xsl:expression"/>
          <xs:attribute name="_duplicates" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="map-entry" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-and-select">
          <xs:attribute name="key" type="xsl:expression"/>
          <xs:attribute name="_key" type="xs:string"/>
          <xs:assert test="exists(@key | @_key)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="matching-substring" type="xsl:sequence-constructor-or-select"/>

  <xs:element name="merge" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:merge-source" minOccurs="1" maxOccurs="unbounded"/>
            <xs:element ref="xsl:merge-action" minOccurs="1" maxOccurs="1"/>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="merge-action" type="xsl:sequence-constructor"/>

  <xs:element name="merge-key" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="lang" type="xsl:avt"/>
          <xs:attribute name="order" type="xsl:avt"/>
          <xs:attribute name="collation" type="xsl:avt"/>
          <xs:attribute name="case-order" type="xsl:avt"/>
          <xs:attribute name="data-type" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_lang" type="xs:string"/>
          <xs:attribute name="_order" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:attribute name="_case-order" type="xs:string"/>
          <xs:attribute name="_data-type" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="merge-source">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:merge-key" minOccurs="1" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xs:NCName"/>
          <xs:attribute name="for-each-item" type="xsl:expression"/>
          <xs:attribute name="for-each-source" type="xsl:expression"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no"/>
          <xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
          <xs:attribute name="sort-before-merge" type="xsl:yes-or-no"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_for-each-item" type="xs:string"/>
          <xs:attribute name="_for-each-source" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-accumulators" type="xs:string"/>
          <xs:attribute name="_sort-before-merge" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="message" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="terminate" type="xsl:avt" default="no"/>
          <xs:attribute name="error-code" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_terminate" type="xs:string"/>
          <xs:attribute name="_error-code" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="mode" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="false">
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:template"/> 
            <xs:element ref="xsl:fallback"/> 
          </xs:choice>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
          <xs:attribute name="on-no-match" type="xsl:on-no-match-type" default="text-only-copy"/>
          <xs:attribute name="on-multiple-match"
                        type="xsl:on-multiple-match-type"
                        default="use-last"/>
          <xs:attribute name="warning-on-no-match" type="xsl:yes-or-no"/>
          <xs:attribute name="warning-on-multiple-match" type="xsl:yes-or-no"/>
          <xs:attribute name="typed" type="xsl:typed-type"/>
          <xs:attribute name="visibility">
            <xs:simpleType>
              <xs:restriction base="xsl:visibility-type">
                <xs:enumeration value="public"/>
                <xs:enumeration value="private"/>
                <xs:enumeration value="final"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_copy-namespaces" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-accumulators" type="xs:string"/>
          <xs:attribute name="_on-no-match" type="xs:string"/>
          <xs:attribute name="_on-multiple-match" type="xs:string"/>
          <xs:attribute name="_warning-on-no-match" type="xs:string"/>
          <xs:attribute name="_warning-on-multiple-match" type="xs:string"/>
          <xs:attribute name="_typed" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>


  <xs:element name="namespace" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="namespace-alias" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="stylesheet-prefix" type="xsl:prefix-or-default"/>
          <xs:attribute name="result-prefix" type="xsl:prefix-or-default"/>
          <xs:attribute name="_stylesheet-prefix" type="xs:string"/>
          <xs:attribute name="_result-prefix" type="xs:string"/>
          <xs:assert test="exists(@stylesheet-prefix | @_stylesheet-prefix)"/>
          <xs:assert test="exists(@result-prefix | @_result-prefix)"/>
          <xs:assert test="every $prefix in (@stylesheet-prefix, @result-prefix)/normalize-space(.)[. ne '#default']
                           satisfies $prefix = in-scope-prefixes(.)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>


  <xs:element name="next-iteration" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>


  <xs:element name="next-match" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:with-param"/>
            <xs:element ref="xsl:fallback"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="non-matching-substring" type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="note" type="xs:anyType"/>

  <xs:element name="number" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:attribute name="value" type="xsl:expression"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="level" type="xsl:level" default="single"/>
          <xs:attribute name="count" type="xsl:pattern"/>
          <xs:attribute name="from" type="xsl:pattern"/>
          <xs:attribute name="format" type="xsl:avt" default="1"/>
          <xs:attribute name="lang" type="xsl:avt"/>
          <xs:attribute name="letter-value" type="xsl:avt"/>
          <xs:attribute name="ordinal" type="xsl:avt"/>
          <xs:attribute name="start-at" type="xsl:avt"/>
          <xs:attribute name="grouping-separator" type="xsl:avt"/>
          <xs:attribute name="grouping-size" type="xsl:avt"/>
          <xs:attribute name="_value" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_level" type="xs:string"/>
          <xs:attribute name="_count" type="xs:string"/>
          <xs:attribute name="_from" type="xs:string"/>
          <xs:attribute name="_format" type="xs:string"/>
          <xs:attribute name="_lang" type="xs:string"/>
          <xs:attribute name="_letter-value" type="xs:string"/>
          <xs:attribute name="_ordinal" type="xs:string"/>
          <xs:attribute name="_start-at" type="xs:string"/>
          <xs:attribute name="_grouping-separator" type="xs:string"/>
          <xs:attribute name="_grouping-size" type="xs:string"/>
          <xs:assert test="if (exists(@value | @_value)) 
                           then empty((@select | @_select, @count | @_count, @from | @_from)) 
                            and (exists(@_level) or normalize-space(@level)='single') 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if the value attribute of <code>xsl:number</code> is
                   present unless the <code>select</code>, <code>level</code>, <code>count</code>, 
                   and <code>from</code> attributes are all absent.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="on-completion" type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="on-empty"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="on-non-empty"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>

  <xs:element name="otherwise" 
              type="xsl:sequence-constructor-or-select"/>

  <xs:element name="output" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent >
        <xs:extension base="xsl:element-only-generic-element-type">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="method" type="xsl:method"/>
          <xs:attribute name="allow-duplicate-names" type="xsl:yes-or-no"/>
          <xs:attribute name="build-tree" type="xsl:yes-or-no"/>
          <xs:attribute name="byte-order-mark" type="xsl:yes-or-no"/>
          <xs:attribute name="cdata-section-elements" type="xsl:EQNames"/>
          <xs:attribute name="doctype-public" type="xs:string"/>
          <xs:attribute name="doctype-system" type="xs:string"/>
          <xs:attribute name="encoding" type="xs:string"/>
          <xs:attribute name="escape-solidus" type="xsl:yes-or-no"/>
          <xs:attribute name="escape-uri-attributes" type="xsl:yes-or-no"/>
          <xs:attribute name="html-version" type="xs:decimal"/>
          <xs:attribute name="include-content-type" type="xsl:yes-or-no"/>
          <xs:attribute name="indent" type="xsl:yes-or-no"/>
          <xs:attribute name="item-separator" type="xs:string"/>
          <xs:attribute name="json-lines" type="xsl:yes-or-no"/>
          <xs:attribute name="json-node-output-method" type="xsl:method"/>
          <xs:attribute name="media-type" type="xs:string"/>
          <xs:attribute name="normalization-form" type="xs:NMTOKEN"/>
          <xs:attribute name="omit-xml-declaration" type="xsl:yes-or-no"/>
          <xs:attribute name="parameter-document" type="xs:anyURI"/>
          <xs:attribute name="standalone" type="xsl:yes-or-no-or-omit"/>
          <xs:attribute name="suppress-indentation" type="xsl:EQNames"/>
          <xs:attribute name="undeclare-prefixes" type="xsl:yes-or-no"/>
          <xs:attribute name="use-character-maps" type="xsl:EQNames"/>
          <xs:attribute name="version" type="xs:NMTOKEN"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_method" type="xs:string"/>
          <xs:attribute name="_allow-duplicate-names" type="xs:string"/>
          <xs:attribute name="_build-tree" type="xs:string"/>
          <xs:attribute name="_byte-order-mark" type="xs:string"/>
          <xs:attribute name="_cdata-section-elements" type="xs:string"/>
          <xs:attribute name="_doctype-public" type="xs:string"/>
          <xs:attribute name="_doctype-system" type="xs:string"/>
          <xs:attribute name="_encoding" type="xs:string"/>
          <xs:attribute name="_escape-solidus" type="xs:string"/>
          <xs:attribute name="_escape-uri-attributes" type="xs:string"/>
          <xs:attribute name="_html-version" type="xs:string"/>
          <xs:attribute name="_include-content-type" type="xs:string"/>
          <xs:attribute name="_indent" type="xs:string"/>
          <xs:attribute name="_item-separator" type="xs:string"/>
          <xs:attribute name="_json-lines" type="xs:string"/>
          <xs:attribute name="_json-node-output-method" type="xs:string"/>
          <xs:attribute name="_media-type" type="xs:string"/>
          <xs:attribute name="_normalization-form" type="xs:string"/>
          <xs:attribute name="_omit-xml-declaration" type="xs:string"/>
          <xs:attribute name="_parameter-document" type="xs:string"/>
          <xs:attribute name="_standalone" type="xs:string"/>
          <xs:attribute name="_suppress-indentation" type="xs:string"/>
          <xs:attribute name="_undeclare-prefixes" type="xs:string"/>
          <xs:attribute name="_use-character-maps" type="xs:string"/>
          <xs:attribute name="_version" type="xs:string"/>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="output-character">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="character" type="xsl:char"/>
          <xs:attribute name="string" type="xs:string"/>
          <xs:attribute name="_character" type="xs:string"/>
          <xs:attribute name="_string" type="xs:string"/>
          <xs:assert test="exists(@character | @_character)"/>
          <xs:assert test="exists(@string | @_string)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="override">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:use-package</code> and defines 
            any overriding definitions of components that the containing package wishes to make 
            to the components made available from a library package.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:template"/>
            <xs:element ref="xsl:function"/>
            <xs:element ref="xsl:variable"/>
            <xs:element ref="xsl:param"/>
            <xs:element ref="xsl:attribute-set"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
    
  <xs:element name="package">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="xsl:expose"/>
              <xs:element ref="xsl:declaration"/>
              <xs:any namespace="##other" processContents="lax"/>
            </xs:choice>
          </xs:sequence>
          <xs:attribute name="declared-modes" type="xsl:yes-or-no"/>
          <xs:attribute name="id" type="xs:ID"/>
          <xs:attribute name="name" type="xs:anyURI"/>
          <xs:attribute name="package-version" type="xs:string"/>
          <xs:attribute name="input-type-annotations" type="xsl:input-type-annotations-type"/>
          <xs:attribute name="fixed-namespaces" type="xsl:fixed-namespaces-type"/>
          <xs:attribute name="_declared-modes" type="xs:string"/>
          <xs:attribute name="_id" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_package-version" type="xs:string"/>
          <xs:attribute name="_input-type-annotations" type="xs:string"/>
          <xs:attribute name="_fixed-namespaces" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="param" substitutionGroup="xsl:declaration">
    <xs:annotation>
      <xs:documentation>
        <p>Declaration of the <code>xsl:param</code> element, used both defining function
            parameters, template parameters, parameters to <code>xsl:iterate</code>,
            and global stylesheet parameters.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="required" type="xsl:yes-or-no"/>
          <xs:attribute name="tunnel" type="xsl:yes-or-no"/>
          <xs:attribute name="static" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_required" type="xs:string"/>
          <xs:attribute name="_tunnel" type="xs:string"/>
          <xs:attribute name="_static" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1')) 
                           then empty((*,text())) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   When the attribute <code>static="yes"</code> is specified, the <code>xsl:param</code>
                   element must have empty content.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  

  <xs:element name="perform-sort" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:sort" minOccurs="1" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="preserve-space" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="elements" type="xsl:nametests"/>
          <xs:attribute name="_elements" type="xs:string"/>
          <xs:assert test="exists(@elements | @_elements)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="processing-instruction" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="record">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">  
          <xs:attribute name="as" form="qualified" type="xsl:sequence-type"/>
          <xs:attribute name="duplicates" form="qualified" type="xsl:sequence-type"/>
          <xs:attribute name="_as" form="qualified" type="xs:string"/>
          <xs:attribute name="_duplicates" form="qualified" type="xs:string"/>
          <xs:attributeGroup ref="xsl:literal-result-element-attributes"/>
          <xs:anyAttribute namespace="##local" processContents="lax"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="record-type" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:field" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="extensible" type="xsl:yes-or-no"/>
          <xs:attribute name="visibility" type="xsl:visibility-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_extensible" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="result-document" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="format" type="xsl:avt"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="href" type="xsl:avt"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="method" type="xsl:avt"/>
          <xs:attribute name="allow-duplicate-names" type="xsl:avt"/>
          <xs:attribute name="build-tree" type="xsl:avt"/>
          <xs:attribute name="byte-order-mark" type="xsl:avt"/>
          <xs:attribute name="cdata-section-elements" type="xsl:avt"/>
          <xs:attribute name="doctype-public" type="xsl:avt"/>
          <xs:attribute name="doctype-system" type="xsl:avt"/>
          <xs:attribute name="encoding" type="xsl:avt"/>
          <xs:attribute name="escape-solidus" type="xsl:avt"/>
          <xs:attribute name="escape-uri-attributes" type="xsl:avt"/>
          <xs:attribute name="html-version" type="xsl:avt"/>
          <xs:attribute name="include-content-type" type="xsl:avt"/>
          <xs:attribute name="indent" type="xsl:avt"/>
          <xs:attribute name="item-separator" type="xsl:avt"/>
          <xs:attribute name="json-lines" type="xsl:avt"/>
          <xs:attribute name="json-node-output-method" type="xsl:avt"/>
          <xs:attribute name="media-type" type="xsl:avt"/>
          <xs:attribute name="normalization-form" type="xsl:avt"/>
          <xs:attribute name="omit-xml-declaration" type="xsl:avt"/>
          <xs:attribute name="parameter-document" type="xsl:avt"/>
          <xs:attribute name="standalone" type="xsl:avt"/>
          <xs:attribute name="suppress-indentation" type="xsl:avt"/>
          <xs:attribute name="undeclare-prefixes" type="xsl:avt"/>
          <xs:attribute name="use-character-maps" type="xsl:EQNames"/>
          <xs:attribute name="output-version" type="xsl:avt"/>
          <xs:attribute name="_format" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:attribute name="_method" type="xs:string"/>
          <xs:attribute name="_allow-duplicate-names" type="xs:string"/>
          <xs:attribute name="_build-tree" type="xs:string"/>
          <xs:attribute name="_byte-order-mark" type="xs:string"/>
          <xs:attribute name="_cdata-section-elements" type="xs:string"/>
          <xs:attribute name="_doctype-public" type="xs:string"/>
          <xs:attribute name="_doctype-system" type="xs:string"/>
          <xs:attribute name="_encoding" type="xs:string"/>
          <xs:attribute name="_escape-solidus" type="xs:string"/>
          <xs:attribute name="_escape-uri-attributes" type="xs:string"/>
          <xs:attribute name="_html-version" type="xs:string"/>
          <xs:attribute name="_include-content-type" type="xs:string"/>
          <xs:attribute name="_indent" type="xs:string"/>
          <xs:attribute name="_item-separator" type="xs:string"/>
          <xs:attribute name="_json-lines" type="xs:string"/>
          <xs:attribute name="_json-node-output-method" type="xs:string"/>
          <xs:attribute name="_media-type" type="xs:string"/>
          <xs:attribute name="_normalization-form" type="xs:string"/>
          <xs:attribute name="_omit-xml-declaration" type="xs:string"/>
          <xs:attribute name="_parameter-document" type="xs:string"/>
          <xs:attribute name="_standalone" type="xs:string"/>
          <xs:attribute name="_suppress-indentation" type="xs:string"/>
          <xs:attribute name="_undeclare-prefixes" type="xs:string"/>
          <xs:attribute name="_use-character-maps" type="xs:string"/>
          <xs:attribute name="_output-version" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="select"
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>  
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:assert test="empty(xsl:fallback/preceding-sibling::text()[normalize-space()])">
            <xs:annotation>
              <xs:documentation>
                <p>An xsl:fallback child must not be preceded by a non-whitespace text node.</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="sequence"
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="_as" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="sort">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="lang" type="xsl:avt"/>
          <xs:attribute name="data-type" type="xsl:avt"/>
          <xs:attribute name="order" type="xsl:avt" default="ascending"/>
          <xs:attribute name="case-order" type="xsl:avt"/>
          <xs:attribute name="collation" type="xsl:avt"/>
          <xs:attribute name="stable" type="xsl:avt"/>
          <xs:attribute name="_lang" type="xs:string"/>
          <xs:attribute name="_data-type" type="xs:string"/>
          <xs:attribute name="_order" type="xs:string"/>
          <xs:attribute name="_case-order" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:attribute name="_stable" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="source-document" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="href" type="xsl:avt"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-accumulators" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="exists(@href | @_href)"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="strip-space" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="elements" type="xsl:nametests"/>
          <xs:attribute name="_elements" type="xs:string"/>
          <xs:assert test="exists(@elements | @_elements)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="stylesheet" substitutionGroup="xsl:transform"/>

  <xs:element name="switch" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:when" maxOccurs="unbounded"/>
            <xs:element ref="xsl:otherwise" minOccurs="0"/>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="_select" type="xsl:avt"/>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="template" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:context-item" minOccurs="0" maxOccurs="1"/>
            <xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="match" type="xsl:pattern"/>
          <xs:attribute name="priority" type="xs:decimal"/>
          <xs:attribute name="mode" type="xsl:modes"/>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type" default="item()*"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="_match" type="xs:string"/>
          <xs:attribute name="_priority" type="xs:string"/>
          <xs:attribute name="_mode" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@match | @_match) or exists(@name | @_name)">
            <xs:annotation>
              <xs:documentation>
                <p>
                   An <code>xsl:template</code> element must have either a <code>match</code> attribute or a
                   <code>name</code> attribute, or both.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (empty(@match | @_match)) 
                           then (empty(@mode | @_mode) and empty(@priority | @_priority)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   An <code>xsl:template</code> element that has no <code>match</code> attribute must have no
                   <code>mode</code> attribute and no <code>priority</code> attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="not(exists(@visibility | @_visibility) and empty(@name | @_name))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   An <code>xsl:template</code> element that has no <code>name</code> attribute must have no
                   <code>visibility</code> attribute
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (normalize-space(@visibility) = 'abstract') 
                           then empty(* except (xsl:context-item, xsl:param)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   If the <code>visibility</code> attribute is present with the value <code>abstract</code>
                   then (a) the sequence constructor defining the template body
                   must be empty: that is, the only permitted children are
                   <code>xsl:context-item</code> and <code>xsl:param</code>
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="not(normalize-space(@visibility) = 'abstract' and exists(@match))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   If the <code>visibility</code> attribute is present with the value <code>abstract</code>
                   then there must be no <code>match</code> attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="every $e in xsl:param satisfies empty($e/(@visibility | @_visibility))">
            <xs:annotation>
              <xs:documentation>
                <p>A parameter for a template must have no <code>visibility</code> attribute.</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="text" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_disable-output-escaping" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="transform-element-base-type">
    <xs:complexContent>
      <xs:restriction base="xsl:element-only-versioned-element-type">
        <xs:attribute name="version" type="xs:decimal" use="optional"/>
        <xs:attribute name="_version" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              <p>
                 The version attribute indicates the version of XSLT that the
                 stylesheet module requires. The attribute is required, unless the
                 <code>xsl:stylesheet</code> element is a child of an <code>xsl:package</code> element, in
                 which case it is optional: the default is then taken from the
                 parent <code>xsl:package</code> element.
              </p>
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:anyAttribute namespace="##other" processContents="lax"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:element name="transform">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:transform-element-base-type">
          <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="xsl:declaration"/>
              <xs:any namespace="##other" processContents="lax"/>
              <!-- weaker than XSLT 1.0 -->
            </xs:choice>
          </xs:sequence>
          <xs:attribute name="id" type="xs:ID"/>
          <xs:attribute name="input-type-annotations"
                        type="xsl:input-type-annotations-type"
                        default="unspecified"/>
          <xs:attribute name="fixed-namespaces"
                        type="xsl:fixed-namespaces-type"/>
          <xs:attribute name="_id" type="xs:string"/>
          <xs:attribute name="_input-type-annotations" type="xs:string"/>
          <xs:attribute name="_fixed-namespaces" type="xs:string"/>
          <!--* The 'static' attribute may be used on 'param' and 'variable'
              * only when they are top-level elements. *-->
          <xs:assert test="every $v in (.//xsl:param, .//xsl:variable)[exists(@static | @_static)] 
                           satisfies $v[parent::xsl:stylesheet or parent::xsl:transform or parent::xsl:override]">
            <xs:annotation>
              <xs:documentation>
                <p>
                   The static attribute must not be present on an <code>xsl:variable</code> or
                   <code>xsl:param</code> element unless it is a top-level element.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="every $prefix in (@exclude-result-prefixes[not(. = '#all')], 
                                             @extension-element-prefixes) 
                           satisfies ((if ($prefix = '#default') then '' else $prefix) = in-scope-prefixes(.))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   XTSE0808: It is a static error if a namespace prefix is used
                   within the <code>[xsl:]exclude-result-prefixes</code> attribute and there is
                   no namespace binding in scope for that prefix.
                </p>
                <p>
                   XTSE0809: It is a static error if the value #default is used
                   within the <code>[xsl:]exclude-result-prefixes</code> attribute and the
                   parent element of the <code>[xsl:]exclude-result-prefixes</code> attribute
                   has no default namespace.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="try" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
            <xs:element ref="xsl:catch" minOccurs="1" maxOccurs="1"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="xsl:catch"/>
              <xs:element ref="xsl:fallback"/>
            </xs:choice>
          </xs:sequence>
          <xs:attribute name="rollback-output" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="select" type="xsl:expression" use="optional"/>
          <xs:attribute name="_rollback-output" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="use-package" substitutionGroup="xsl:declaration">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:package</code> and defines a dependency
            of the containing package on another package, identified by URI in the <code>name</code>
            attribute. The <code>package-version</code> attribute indicates which version of the
            library package is required, or may indicate a range of versions.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent mixed="false">
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:accept"/>
            <xs:element ref="xsl:override"/>
          </xs:choice>
          <xs:attribute name="name" type="xs:anyURI"/>
          <xs:attribute name="package-version" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_package-version" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="value-of" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_disable-output-escaping" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="variable" substitutionGroup="xsl:declaration xsl:instruction">
    <xs:annotation>
      <xs:documentation>
        <p>Declaration of the <code>xsl:variable</code> element, used both for local
            and global variable bindings.</p>
        <p>
           This definition takes advantage of the ability in XSD 1.1 for an element
           to belong to more than one substitution group. A global variable is a
           declaration, while a local variable can appear as an instruction in a
           sequence constructor.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="static" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:attribute name="_static" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1')) 
                           then (exists(@_visibility) or normalize-space(@visibility) 
                                       = ('', 'private', 'final')) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   When the static attribute is present with the value yes, the
                   visibility attribute must not have a value other than private or
                   final.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1')) 
                           then (empty((*, text())) and exists(@select | @_select)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   When the attribute <code>static="yes"</code> is specified, the <code>xsl:variable</code>
                   element must have empty content, and the <code>select</code> attribute must
                   be present to define the value of the variable.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="when">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="test" type="xsl:expression"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_test" type="xs:string"/>
          <xs:assert test="exists(@test | @_test)"/>
          <xs:assert test="not(exists(@select | @_select) and 
            (exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="where-populated"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor"/>

  <xs:element name="with-param">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="tunnel" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_tunnel" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation> PART C: definition of literal result elements There are three ways to define
      the literal result elements permissible in a stylesheet. (a) do nothing. This allows any
      element to be used as a literal result element, provided it is not in the XSLT namespace (b)
      declare all permitted literal result elements as members of the <code>xsl:literal-result-element</code>
      substitution group (c) redefine the model group xsl:result-elements to accommodate all
      permitted literal result elements. Literal result elements are allowed to take certain
      attributes in the XSLT namespace. These are defined in the attribute group
      <code>literal-result-element-attributes</code>, which can be included in the definition of any literal
      result element. </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <xs:element name="literal-result-element" abstract="true" type="xs:anyType"/>

  <xs:attributeGroup name="literal-result-element-attributes">
    <xs:attribute name="default-collation" 
                  form="qualified" 
                  type="xsl:uri-list"/>
    <xs:attribute name="default-mode" 
                  form="qualified"  
                  type="xsl:default-mode-type"/>
    <xs:attribute name="default-validation" 
                  form="qualified" 
                  type="xsl:validation-strip-or-preserve"
                  default="strip"/>
    <xs:attribute name="expand-text" 
                  form="qualified"  
                  type="xsl:yes-or-no"/>
    <xs:attribute name="extension-element-prefixes" 
                  form="qualified" 
                  type="xsl:prefix-list"/>
    <xs:attribute name="exclude-result-prefixes" 
                  form="qualified" 
                  type="xsl:prefix-list-or-all"/>
    <xs:attribute name="inherit-namespaces"
                  form="qualified"
                  type="xsl:yes-or-no"
                  default="yes"/>
    <xs:attribute name="schema-role"
                  form="qualified"
                  type="xs:NCName"
                  default="yes"/>
    <xs:attribute name="use-attribute-sets"
                  form="qualified"
                  type="xsl:EQNames"
                  default=""/>
    <xs:attribute name="use-when" 
                  form="qualified" 
                  type="xsl:expression"/>
    <xs:attribute name="version" 
                  form="qualified" 
                  type="xs:decimal"/>
    <xs:attribute name="type" 
                  form="qualified" 
                  type="xsl:EQName"/>
    <xs:attribute name="validation" 
                  form="qualified" 
                  type="xsl:validation-type"/>
    <xs:attribute name="xpath-default-namespace" 
                  form="qualified" 
                  type="xs:anyURI"/>
  </xs:attributeGroup>

  <xs:group name="result-elements">
    <xs:choice>
      <xs:element ref="xsl:literal-result-element"/>
      <xs:any namespace="##other" processContents="lax"/>
      <xs:any namespace="##local" processContents="lax"/>
    </xs:choice>
  </xs:group>


  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         PART D: definitions of simple types used in stylesheet attributes
      </p>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <xs:simpleType name="accumulator-names">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>use-accumulators</code> attribute of <code>xsl:source-document</code>, 
           <code>xsl:merge-source</code>, or <code>xsl:global-context-item</code>: 
           either a list, each member being a QName; or the value <code>#all</code>
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union>
      <xs:simpleType>
        <xs:list itemType="xsl:EQName"/>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#all"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType> 
  
  <xs:simpleType name="avt">
    <xs:annotation>
      <xs:documentation>
        <p>
           This type is used for all attributes that allow an attribute value
           template. The general rules for the syntax of attribute value templates,
           and the specific rules for each such attribute, are described in the
           XSLT 4.0 Recommendation.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string"/>
  </xs:simpleType>
  
  <xs:simpleType name="char">
    <xs:annotation>
      <xs:documentation>
        <p>
           A string containing exactly one character.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:length value="1"/>
    </xs:restriction>
  </xs:simpleType>

           
  <xs:simpleType name="char-optionally-expanded">
    <xs:annotation>
      <xs:documentation>
        <p>
           A string containing either a single character, or a single character
           followed by a colon followed by an arbitrary string
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value=".(:.*)?"/>
    </xs:restriction>
  </xs:simpleType> 

           
  <xs:simpleType name="component-kind-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes a kind of component within a package.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="template"/>
      <xs:enumeration value="function"/>
      <xs:enumeration value="variable"/>
      <xs:enumeration value="attribute-set"/>
      <xs:enumeration value="mode"/>
      <xs:enumeration value="*"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="default-mode-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>default-mode</code> attribute of <code>xsl:stylesheet</code>, 
           <code>xsl:transform</code>, <code>xsl:package</code>
           (or any other xsl:* element): either a QName or #unnamed.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#unnamed"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
  
  <xs:simpleType name="component-test">
    <xs:annotation>
      <xs:documentation>
        <p> A NameTest or a named function reference. </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:nametest xsl:named-function-reference"/>
  </xs:simpleType>

  <xs:simpleType name="component-tests">
    <xs:annotation>
      <xs:documentation>
        <p> A list of NameTests or named function references</p>
      </xs:documentation>
    </xs:annotation>
    <xs:list itemType="xsl:component-test"/>
  </xs:simpleType>

  <xs:simpleType name="expression">
    <xs:annotation>
      <xs:documentation>
        <p>
           An XPath 4.0 expression.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value=".+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="fixed-namespaces-type">
    <xs:annotation>
      <xs:documentation>
        <p>
          A sequence of tokens, each of which may be one of #default, an NCName, a prefix=namespace binding, or a URI
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:list>
      <xs:simpleType>
        <xs:union memberTypes="xsl:fixed-namespaces-type-standard xs:NCName xsl:fixed-namespaces-type-prefix-binding xs:anyURI"/>
      </xs:simpleType>
    </xs:list>
 
  </xs:simpleType>
  
  <xs:simpleType name="fixed-namespaces-type-standard">
    <xs:restriction base="xs:token">
       <xs:enumeration value="#standard"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="fixed-namespaces-type-prefix-binding">
    <xs:restriction base="xs:string">
       <xs:pattern value="([\i-[:]][\c-[:]]*:)=.+"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="item-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           An XPath 4.0 ItemType
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value=".+"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="input-type-annotations-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes how type annotations in source documents are handled.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="preserve"/>
      <xs:enumeration value="strip"/>
      <xs:enumeration value="unspecified"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="level">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>level</code> attribute of <code>xsl:number</code>: 
           one of <code>single</code>, <code>multiple</code>, or <code>any</code>.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="single"/>
      <xs:enumeration value="multiple"/>
      <xs:enumeration value="any"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="mode">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>mode</code> attribute of <code>xsl:apply-templates</code>: 
           either a QName, or <code>#current</code>,
           or <code>#unnamed</code>, or <code>#default</code>.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#default"/>
          <xs:enumeration value="#unnamed"/>
          <xs:enumeration value="#current"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="modes">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>mode</code> attribute of <code>xsl:template</code>: either a list, each member being
           either a QName or <code>#default</code> or <code>#unnamed</code>; or the value <code>#all</code>
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union>
      <xs:simpleType>
        <xs:restriction>
          <xs:simpleType>
            <xs:list>
              <xs:simpleType>
                <xs:union memberTypes="xsl:EQName">
                  <xs:simpleType>
                    <xs:restriction base="xs:token">
                      <xs:enumeration value="#default"/>
                      <xs:enumeration value="#unnamed"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:union>
              </xs:simpleType>
            </xs:list>
          </xs:simpleType>
          <xs:assertion test="count($value) = count(distinct-values($value))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   XTSE0550: It is a static error if the same token is included
                   more than once in the list.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assertion>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#all"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

   <xs:simpleType name="named-function-reference">
    <xs:annotation>
      <xs:documentation>
        <p> In simple terms, this is an EQName followed by "#arity" where "arity" is a non-negative integer. However,
          XSD doesn't allow us to reuse the definition of EQName in this way, so it has to be defined from scratch. The simplest
          way to do this is with an assertion. However, the assertion cannot exploit types such as <code>xsl:EQName</code> defined in this
        schema</p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value="((Q\{.*\})|([\i-[:]][\c-[:]]*:))?[\i-[:]][\c-[:]]*#[0-9]+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="nametest">
    <xs:annotation>
      <xs:documentation>
        <p> A list of NameTests, as defined in the XPath 31 Recommendation. Each NameTest is either
          an EQName, or "*", or "prefix:*", or "*:localname", or the wildcard Q{uri}*. </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="*"/>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:pattern value="[\i-[:]][\c-[:]]*:\*"/>
          <xs:pattern value="\*:[\i-[:]][\c-[:]]*"/>
          <xs:pattern value="Q\{[^}]*\}\*"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="nametests">
    <xs:annotation>
      <xs:documentation>
        <p> A list of NameTests, as defined in the XPath 4.0 Recommendation. Each NameTest is either
          a QName, or "*", or "prefix:*", or "*:localname" </p>
      </xs:documentation>
    </xs:annotation>
    <xs:list itemType="xsl:nametest"/>
  </xs:simpleType>
  
  <xs:simpleType name="on-multiple-match-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the action to be taken when there are several template rules
           to match an item in a given mode.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="use-last"/>
      <xs:enumeration value="fail"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="on-no-match-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the action to be taken when there is no template rule to match
           an item in a given mode.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="deep-copy"/>
      <xs:enumeration value="shallow-copy"/>
      <xs:enumeration value="shallow-copy-all"/>
      <xs:enumeration value="deep-skip"/>
      <xs:enumeration value="shallow-skip"/>
      <xs:enumeration value="text-only-copy"/>
      <xs:enumeration value="fail"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="prefix-list-or-all">
    <xs:union memberTypes="xsl:prefix-list">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#all"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="prefix-list">
    <xs:list itemType="xsl:prefix-or-default"/>
  </xs:simpleType>

  <xs:simpleType name="method">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>method</code> attribute of <code>xsl:output</code>: Either one of the recognized names
           "xml", "xhtml", "html", "text", "json", or "adaptive",
            or an EQName that must include a prefix or namespace URI.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName-in-namespace">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="xml"/>
          <xs:enumeration value="xhtml"/>
          <xs:enumeration value="html"/>
          <xs:enumeration value="text"/>
          <xs:enumeration value="json"/>
          <xs:enumeration value="adaptive"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="pattern">
    <xs:annotation>
      <xs:documentation>
        <p>
           A match pattern as defined in the XSLT 4.0 Recommendation. The syntax
           for patterns is a restricted form of the syntax for XPath 4.0
           expressions. 
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:expression"/>
  </xs:simpleType>

  <xs:simpleType name="prefix-or-default">
    <xs:annotation>
      <xs:documentation>
        <p>
           Either a namespace prefix, or <code>#default</code>. Used in the <code>xsl:namespace-alias</code>
           element.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xs:NCName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#default"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="EQNames">
    <xs:annotation>
      <xs:documentation>
        <p>
           A list of QNames. Used in the <code>[xsl:]use-attribute-sets</code> attribute of
           various elements, and in the <code>cdata-section-elements</code> attribute of
           <code>xsl:output</code>.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:list itemType="xsl:EQName"/>
  </xs:simpleType>

  <xs:simpleType name="EQName">
    <xs:annotation>
      <xs:documentation>
        <p>
           An extended QName. This schema does not use the built-in type <code>xs:QName</code>,
           but rather defines its own QName type. This may be either a local name,
           or a prefixed QName, or a name written using the extended QName notation
           <code>Q{uri}[prefix:]local</code>
        </p>
        <p>In XSLT 4.0, where a QName is used in the <code>name</code> attribute
        of (say) <code>xsl:template</code> or <code>xsl:call-template</code>, the prefix
        does not have to be bound in an XML namespace declaration; rather it can be bound
        in a <code>fixed-namespaces</code> attribute on the <code>xsl:stylesheet</code>
        element. Therefore, the built-in <code>xs:QName</code> type cannot be used.
        This schema does not attempt to verify that namespace prefixes have been
        properly declared.</p>
        
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xs:NCName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:pattern value="[\i-[:]][\c-[:]]*:[\i-[:]][\c-[:]]*"/>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:pattern value="Q\{[^{}]*\}[\i-[:]][\c-[:]]*(:[\i-[:]][\c-[:]]*)?"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
  
  <xs:simpleType name="EQName-in-namespace">
    <xs:annotation>
      <xs:documentation>
        <p>
           A subtype of EQNames that excludes no-namespace names
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:EQName">
      <xs:pattern value="Q\{.+\}.+|\i\c*:.+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="sequence-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           The description of a datatype, conforming to the SequenceType production
           defined in the XPath 4.0 Recommendation
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value=".+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="streamability-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the category to which a function belongs, with regards to its
           streaming behavior.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName-in-namespace">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="unclassified"/>
          <xs:enumeration value="absorbing"/>
          <xs:enumeration value="inspection"/>
          <xs:enumeration value="filter"/>
          <xs:enumeration value="shallow-descent"/>
          <xs:enumeration value="deep-descent"/>
          <xs:enumeration value="ascent"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
  
  <xs:simpleType name="tokens">
    <xs:list itemType="xs:token"/>
  </xs:simpleType>

  <xs:simpleType name="typed-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes whether a mode is designed to match typed or untyped nodes.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
      <xs:enumeration value="strict"/>
      <xs:enumeration value="lax"/>
      <xs:enumeration value="unspecified"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="uri-list">
    <xs:list itemType="xs:anyURI"/>
  </xs:simpleType>

  <xs:simpleType name="validation-strip-or-preserve">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes different ways of type-annotating an element or attribute.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:validation-type">
      <xs:enumeration value="preserve"/>
      <xs:enumeration value="strip"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="validation-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes different ways of type-annotating an element or attribute.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="strict"/>
      <xs:enumeration value="lax"/>
      <xs:enumeration value="preserve"/>
      <xs:enumeration value="strip"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="visibility-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the visibility of a component within a package.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="public"/>
      <xs:enumeration value="private"/>
      <xs:enumeration value="final"/>
      <xs:enumeration value="abstract"/>
      <xs:enumeration value="hidden"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="visibility-not-hidden-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the visibility of a component within a package.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:visibility-type">
      <xs:enumeration value="public"/>
      <xs:enumeration value="private"/>
      <xs:enumeration value="final"/>
      <xs:enumeration value="abstract"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="yes-or-no">
    <xs:annotation>
      <xs:documentation>
        <p>
           One of the values "yes" or "no": the values "true" or "false", or "1" or
           "0" are accepted as synonyms.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="yes-or-no-or-maybe">
    <xs:annotation>
      <xs:documentation>
        <p>
           One of the values "yes" or "no" or "omit". The values "true" or "false",
           or "1" or "0" are accepted as synonyms of "yes" and "no" respectively.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
      <xs:enumeration value="maybe"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="yes-or-no-or-omit">
    <xs:annotation>
      <xs:documentation>
        <p>
           One of the values "yes" or "no" or "omit". The values "true" or "false",
           or "1" or "0" are accepted as synonyms of "yes" and "no" respectively.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
      <xs:enumeration value="omit"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="zero-digit">
    <xs:annotation>
      <xs:documentation>
        <p>
           A digit that has the numerical value zero.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:char">
      <xs:pattern value="\p{Nd}"/>
      <xs:assertion test="matches(string-join(codepoints-to-string(
           for $i in 0 to 9 return string-to-codepoints($value) + $i), ''), '\p{Nd}{10}')"/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
           xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
           targetNamespace="http://www.w3.org/1999/XSL/Transform"
           elementFormDefault="qualified"
           vc:minVersion="1.1">

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         This is an XSD 1.1 schema for XSLT 4.0 stylesheets. It defines all the
         elements that appear in the XSLT namespace; it also provides hooks that
         allow the inclusion of user-defined literal result elements, extension
         instructions, and top-level data elements.
      </p>
      <p>
         This schema is available for use under the conditions of the W3C Software
         License published at
         http://www.w3.org/Consortium/Legal/copyright-software-19980720
      </p>
      <p>
         The schema is organized as follows:
      </p>
      <ul>
        <li>
           PART A: definitions of complex types and model groups used as the basis
           for element definitions
        </li>
        <li>
           PART B: definitions of individual XSLT elements
        </li>
        <li>
           PART C: definitions for literal result elements
        </li>
        <li>
           PART D: definitions of simple types used in attribute definitions
        </li>
      </ul>
      <p>
         The schema has a number of limitations:
      </p>
      <ul>
        <li>
           The XSLT specification allows additional elements and attributes to be
           present where forwards compatibility is invoked. This schema does not.
        </li>
        <li>
           The XSLT specification allows arbitrary content in a part of the
           stylesheet that is excluded by virtue of a use-when attribute. This
           schema does not.
        </li>
        <li>
           The handling of literal result elements in this schema is imperfect;
           although various options are allowed, none matches the specification
           exactly. For example, the content of a literal result element uses lax
           validation, which permits child elements in the XSLT namespace that have
           no declaration in this schema.
        </li>
        <li>
           The schema makes no attempt to check XPath expressions for syntactic or
           semantic correctness, nor to check that component references are
           resolved (for example that a template named in <code>xsl:call-template</code> has a
           declaration). Doing this in general requires cross-document validation,
           which is beyond the scope of XSD.
        </li>
        <li>
           The XSLT specification allows <code>xsl:note</code> elements to appear
           anywhere, with arbitrary content. This schema does not: for example, it does
           not allow <code>xsl:note</code> as a child of an element such as <code>xsl:text</code>
           or <code>xsl:strip-space</code>.
        </li>
        <li>
           The schema imports the schema for XSD 1.0 schema documents. In
           stylesheets that contain an inline XSD 1.1 schema, this import should be
           replaced with one for the schema for XSD 1.1 schema documents.
        </li>
      </ul>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <!--
The declaration of xml:space and xml:lang may need to be commented out because
of problems processing the schema using various tools
-->

  <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
  <!--schemaLocation="http://www.w3.org/2001/xml.xsd"-->

  <!-- 
    An XSLT stylesheet may contain an in-line schema within an xsl:import-schema element,
    so the Schema for schemas needs to be imported. We use the XSD 1.1 version.
-->

  <xs:import namespace="http://www.w3.org/2001/XMLSchema"
             schemaLocation="http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd"/>

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         PART A: definitions of complex types and model groups used as the basis
         for element definitions
      </p>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  
  <xs:defaultOpenContent>
    <!-- Allow xsl:note anywhere -->
    <xs:any processContents="strict" 
            namespace="##targetNamespace"
            notQName="xsl:accept 
                      xsl:accumulator 
                      xsl:accumulator-rule 
                      xsl:analyze-string 
                      xsl:apply-imports 
                      xsl:apply-templates 
                      xsl:array 
                      xsl:assert 
                      xsl:attribute 
                      xsl:attribute-set 
                      xsl:break 
                      xsl:call-template 
                      xsl:catch 
                      xsl:character-map 
                      xsl:choose 
                      xsl:comment 
                      xsl:context-item 
                      xsl:copy 
                      xsl:copy-of 
                      xsl:document 
                      xsl:decimal-format 
                      xsl:element 
                      xsl:evaluate 
                      xsl:expose 
                      xsl:fallback
                      xsl:field 
                      xsl:for-each 
                      xsl:for-each-group 
                      xsl:fork 
                      xsl:function 
                      xsl:global-context-item 
                      xsl:if 
                      xsl:import 
                      xsl:import-schema 
                      xsl:include 
                      xsl:iterate 
                      xsl:key 
                      xsl:map 
                      xsl:map-entry 
                      xsl:matching-substring 
                      xsl:merge 
                      xsl:merge-action 
                      xsl:merge-key 
                      xsl:merge-source 
                      xsl:message 
                      xsl:mode 
                      xsl:namespace 
                      xsl:namespace-alias 
                      xsl:next-iteration 
                      xsl:next-match 
                      xsl:non-matching-substring 
                      xsl:number 
                      xsl:on-completion 
                      xsl:on-empty 
                      xsl:on-non-empty 
                      xsl:otherwise 
                      xsl:output 
                      xsl:output-character 
                      xsl:override 
                      xsl:package 
                      xsl:param 
                      xsl:perform-sort 
                      xsl:preserve-space 
                      xsl:processing-instruction
                      xsl:record 
                      xsl:record-type 
                      xsl:result-document
                      xsl:select
                      xsl:sequence 
                      xsl:sort 
                      xsl:source-document 
                      xsl:strip-space 
                      xsl:stylesheet 
                      xsl:switch 
                      xsl:template 
                      xsl:text 
                      xsl:transform 
                      xsl:try 
                      xsl:use-package 
                      xsl:value-of 
                      xsl:variable 
                      xsl:when 
                      xsl:where-populated 
                      xsl:with-param
            "/>
  </xs:defaultOpenContent>
  
  <xs:complexType name="generic-element-type" mixed="true">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type provides a generic supertype for all XSLT elements except 
           <code>xsl:record</code>; it contains the definitions of the standard attributes 
           that may appear on any element.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="default-collation" type="xsl:uri-list"/>
    <xs:attribute name="default-mode" type="xsl:default-mode-type"/>
    <xs:attribute name="default-validation"
                  type="xsl:validation-strip-or-preserve"
                  default="strip"/>
    <xs:attribute name="exclude-result-prefixes" type="xsl:prefix-list-or-all"/>
    <xs:attribute name="expand-text" type="xsl:yes-or-no"/>
    <xs:attribute name="extension-element-prefixes" type="xsl:prefix-list"/>
    <xs:attribute name="schema-role" type="xs:NCName"/>
    <xs:attribute name="use-when" type="xsl:expression"/>
    <xs:attribute name="xpath-default-namespace" type="xs:anyURI"/>
    <xs:attribute name="_default-collation" type="xs:string"/>
    <xs:attribute name="_default-mode" type="xs:string"/>
    <xs:attribute name="_default-validation" type="xs:string"/>
    <xs:attribute name="_exclude-result-prefixes" type="xs:string"/>
    <xs:attribute name="_expand-text" type="xs:string"/>
    <xs:attribute name="_extension-element-prefixes" type="xs:string"/>
    <xs:attribute name="_schema-role" type="xs:string"/>
    <xs:attribute name="_use-when" type="xs:string"/>
    <xs:attribute name="_xpath-default-namespace" type="xs:string"/>
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:complexType>
  
  <xs:complexType name="element-only-generic-element-type" mixed="false">
    <xs:complexContent>
      <xs:restriction base="xsl:generic-element-type"/>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="versioned-element-type" mixed="true">
    <xs:annotation>
      <xs:documentation>
        <p>This complex type provides a generic supertype for all XSLT elements with
                the exception of <code>xsl:output</code> and <code>xsl:record</code>; it contains the
                definitions of the <code>version</code> attribute that may appear on any element.
                </p>
        <p>The <code>xsl:output</code> element does not use this definition because, although it
             has a <code>version</code> attribute, the syntax and semantics of this attribute are
             unrelated to the standard <code>version</code> attribute allowed on other elements.</p>
        <p>Similarly <code>xsl:record</code> does not use this definition because it expects
        standard attributes (including [xsl:]version) to be in the XSLT namespace.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="xsl:generic-element-type">
        <xs:attribute name="version" type="xs:decimal" use="optional"/>
        <xs:attribute name="_version" type="xs:string"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="element-only-versioned-element-type" mixed="false">
    <xs:complexContent>
      <xs:restriction base="xsl:versioned-element-type">
        <xs:anyAttribute namespace="##other" processContents="lax"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="sequence-constructor">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type provides a generic supertype for all XSLT elements
           that allow a sequence constructor as their content.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="true">
      <xs:extension base="xsl:versioned-element-type">
        <xs:group ref="xsl:sequence-constructor-group"
                  minOccurs="0"
                  maxOccurs="unbounded"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="sequence-constructor-and-select">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type allows a sequence constructor and a select attribute.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="true">
      <xs:extension base="xsl:sequence-constructor">
        <xs:attribute name="select" type="xsl:expression"/>
        <xs:attribute name="_select" type="xs:string"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  
  <xs:complexType name="sequence-constructor-or-select">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type allows a sequence constructor or a select attribute,
           but not both.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="true">
      <xs:restriction base="xsl:sequence-constructor-and-select">
        <xs:group ref="xsl:sequence-constructor-group"
                  minOccurs="0"
                  maxOccurs="unbounded"/>
        <xs:anyAttribute namespace="##other" processContents="lax"/>
        <xs:assert test="not(exists(@select | @_select) and 
          (exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:group name="sequence-constructor-group">
    <xs:annotation>
      <xs:documentation>
        <p>
           This complex type provides a generic supertype for all XSLT elements
           that allow a sequence constructor as their content.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:choice>
      <xs:element ref="xsl:instruction"/>
      <xs:element ref="xsl:record"/>
      <xs:group ref="xsl:result-elements"/>
    </xs:choice>
  </xs:group>

  <xs:element name="declaration" type="xsl:generic-element-type" abstract="true"/>

  <xs:element name="instruction" type="xsl:versioned-element-type" abstract="true"/>

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         PART B: definitions of individual XSLT elements Elements are listed in
         alphabetical order.
      </p>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  
  <xs:element name="accept">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:use-package</code> and defines 
            any variations that the containing package wishes to make to the visibility of
            components made available from a library package. For example, it may indicate that
            some of the public components in the library package are not to be made available
            to the containing package.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="component" type="xsl:component-kind-type"/>
          <xs:attribute name="names" type="xsl:component-tests"/>
          <xs:attribute name="visibility" type="xsl:visibility-type"/>
          <xs:attribute name="_component" type="xs:string"/>
          <xs:attribute name="_names" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@component | @_component)"/>
          <xs:assert test="exists(@names | @_names)"/>
          <xs:assert test="exists(@visibility | @_visibility)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="accumulator" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:accumulator-rule" minOccurs="1" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="initial-value" type="xsl:expression"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_initial-value" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="accumulator-rule">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:sequence/>
          <xs:attribute name="match" type="xsl:pattern"/>
          <xs:attribute name="phase">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="start"/>
                <xs:enumeration value="end"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="capture" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="_match" type="xs:string"/>
          <xs:attribute name="_phase" type="xs:string"/>
          <xs:attribute name="_capture" type="xs:string"/>
          <xs:assert test="exists(@match | @_match)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="analyze-string" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:matching-substring" minOccurs="0"/>
            <xs:element ref="xsl:non-matching-substring" minOccurs="0"/>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="regex" type="xsl:avt"/>
          <xs:attribute name="flags" type="xsl:avt" default=""/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_regex" type="xs:string"/>
          <xs:attribute name="_flags" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
          <xs:assert test="exists(@regex | @_regex)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="apply-imports" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="apply-templates" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:sort"/>
            <xs:element ref="xsl:with-param"/>
          </xs:choice>
          <xs:attribute name="select" type="xsl:expression" default="child::node()"/>
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="mode" type="xsl:mode"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_mode" type="xs:string"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="array" 
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="for-each" type="xsl:expression"/>
          <xs:attribute name="_for-each" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="array-member"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="assert" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="test" type="xsl:expression"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="error-code" type="xsl:avt"/>
          <xs:attribute name="_test" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_error-code" type="xs:string"/>
          <xs:assert test="exists(@test | @_test)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="attribute" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="namespace" type="xsl:avt"/>
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_namespace" type="xs:string"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="attribute-set" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:attribute"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no"/>
          <xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-attribute-sets" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="break"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>

  <xs:element name="call-template" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="catch">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="errors" type="xsl:nametests" use="optional"/>
          <xs:attribute name="_errors" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="character-map" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:output-character" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="use-character-maps" type="xsl:EQNames" default=""/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_use-character-maps" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="choose" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:when" maxOccurs="unbounded"/>
            <xs:element ref="xsl:otherwise" minOccurs="0"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="comment"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="context-item">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="as" type="xsl:item-type"/>
          <xs:attribute name="use">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="required"/>
                <xs:enumeration value="optional"/>
                <xs:enumeration value="absent"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_use" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="copy" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_copy-namespaces" type="xs:string"/>
          <xs:attribute name="_inherit-namespaces" type="xs:string"/>
          <xs:attribute name="_use-attribute-sets" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="copy-of" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="copy-accumulators" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_copy-accumulators" type="xs:string"/>
          <xs:attribute name="_copy-namespaces" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="document" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="decimal-format" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="decimal-separator" type="xsl:char-optionally-expanded" default="."/>
          <xs:attribute name="grouping-separator" type="xsl:char-optionally-expanded" default=","/>
          <xs:attribute name="infinity" type="xs:string" default="Infinity"/>
          <xs:attribute name="minus-sign" type="xs:string" default="-"/>
          <xs:attribute name="exponent-separator" type="xsl:char-optionally-expanded" default="e"/>
          <xs:attribute name="NaN" type="xs:string" default="NaN"/>
          <xs:attribute name="percent" type="xsl:char-optionally-expanded" default="%"/>
          <xs:attribute name="per-mille" type="xsl:char-optionally-expanded" default="‰"/>
          <xs:attribute name="zero-digit" type="xsl:zero-digit" default="0"/>
          <xs:attribute name="digit" type="xsl:char" default="#"/>
          <xs:attribute name="pattern-separator" type="xsl:char" default=";"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_decimal-separator" type="xs:string"/>
          <xs:attribute name="_grouping-separator" type="xs:string"/>
          <xs:attribute name="_infinity" type="xs:string"/>
          <xs:attribute name="_minus-sign" type="xs:string"/>
          <xs:attribute name="_exponent-separator" type="xs:string"/>
          <xs:attribute name="_NaN" type="xs:string"/>
          <xs:attribute name="_percent" type="xs:string"/>
          <xs:attribute name="_per-mille" type="xs:string"/>
          <xs:attribute name="_zero-digit" type="xs:string"/>
          <xs:attribute name="_digit" type="xs:string"/>
          <xs:attribute name="_pattern-separator" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="element" substitutionGroup="xsl:instruction">
    <xs:complexType mixed="true">
      <xs:complexContent>
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="namespace" type="xsl:avt"/>
          <xs:attribute name="inherit-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="use-attribute-sets" type="xsl:EQNames" default=""/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_namespace" type="xs:string"/>
          <xs:attribute name="_inherit-namespaces" type="xs:string"/>
          <xs:attribute name="_use-attribute-sets" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="evaluate" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:with-param"/>
            <xs:element ref="xsl:fallback"/>
          </xs:choice>
          <xs:attribute name="xpath" type="xsl:expression"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="base-uri" type="xsl:avt"/>
          <xs:attribute name="context-item" type="xsl:expression"/>
          <xs:attribute name="namespace-context" type="xsl:expression"/>
          <xs:attribute name="schema-aware" type="xsl:avt"/>
          <xs:attribute name="trusted" type="xsl:avt"/>
          <xs:attribute name="with-params" type="xsl:expression"/>
          <xs:attribute name="_xpath" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_base-uri" type="xs:string"/>
          <xs:attribute name="_context-item" type="xs:string"/>
          <xs:attribute name="_namespace-context" type="xs:string"/>
          <xs:attribute name="_schema-aware" type="xs:string"/>
          <xs:attribute name="_trusted" type="xs:string"/>
          <xs:attribute name="_with-params" type="xs:string"/>
          <xs:assert test="exists(@xpath | @_xpath)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="expose">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:use-package</code> and defines 
            the visibility of components that are made available (or not) by this package
            to other using packages.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="component" type="xsl:component-kind-type"/>
          <xs:attribute name="names" type="xsl:component-tests"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="_component" type="xs:string"/>
          <xs:attribute name="_names" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@component | @_component)"/>
          <xs:assert test="exists(@names | @_names)"/>
          <xs:assert test="exists(@visibility | @_visibility)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="fallback"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor"/>
  
  <xs:element name="field">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="name" type="xs:NCName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="required" type="xsl:yes-or-no"/>
          <xs:attribute name="default" type="xsl:expression"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_required" type="xs:string"/>
          <xs:attribute name="_default" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="for-each" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="for-each-group" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:sort" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="group-by" type="xsl:expression"/>
          <xs:attribute name="group-adjacent" type="xsl:expression"/>
          <xs:attribute name="group-starting-with" type="xsl:pattern"/>
          <xs:attribute name="group-ending-with" type="xsl:pattern"/>
          <xs:attribute name="split-when" type="xsl:expression"/>
          <xs:attribute name="composite" type="xsl:yes-or-no"/>
          <xs:attribute name="collation" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_group-by" type="xs:string"/>
          <xs:attribute name="_group-adjacent" type="xs:string"/>
          <xs:attribute name="_group-starting-with" type="xs:string"/>
          <xs:attribute name="_group-ending-with" type="xs:string"/>
          <xs:attribute name="_split-when" type="xs:string"/>
          <xs:attribute name="_composite" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="count(((@group-by|@_group-by)[1], 
                                  (@group-adjacent|@_group-adjacent)[1], 
                                  (@group-starting-with|@_group-starting-with)[1], 
                                  (@group-ending-with|@_group-ending-with)[1],
                                  (@split-when|@_split-when)[1])) = 1">
            <xs:annotation>
              <xs:documentation>
                <p>
                   These four attributes are mutually exclusive: it is a static
                   error if none of these four attributes is present or if more
                   than one of them is present.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (exists(@collation|@_collation) or exists(@composite|@_composite)) 
                           then (exists(@group-by|@_group-by) or exists(@group-adjacent|@_group-adjacent)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is an error to specify the collation attribute or the
                   composite attribute if neither the group-by attribute nor
                   group-adjacent attribute is specified.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="fork" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
            <xs:choice>
              <xs:sequence minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="xsl:sequence"/>
                <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
              <xs:sequence>
                <xs:element ref="xsl:for-each-group"/>
                <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
            </xs:choice>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="function" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="override" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="as" type="xsl:sequence-type" default="item()*"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="streamability" type="xsl:streamability-type"/>
          <xs:attribute name="override-extension-function" type="xsl:yes-or-no"/>
          <xs:attribute name="new-each-time" type="xsl:yes-or-no-or-maybe"/>
          <xs:attribute name="cache" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_override" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:attribute name="_streamability" type="xs:string"/>
          <xs:attribute name="_override-extension-function" type="xs:string"/>
          <xs:attribute name="_new-each-time" type="xs:string"/>
          <xs:attribute name="_cache" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="every $e in xsl:param satisfies empty($e/(@visibility | @_visibility))">
            <xs:annotation>
              <xs:documentation>
                <p>A parameter for a function must have no <code>visibility</code> attribute.</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="global-context-item" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="as" type="xsl:item-type"/>
          <xs:attribute name="use">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="required"/>
                <xs:enumeration value="optional"/>
                <xs:enumeration value="absent"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_use" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  

  <xs:element name="if" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="test" type="xsl:expression"/>
          <xs:attribute name="then" type="xsl:expression"/>
          <xs:attribute name="else" type="xsl:expression"/>
          <xs:attribute name="_test" type="xs:string"/>
          <xs:attribute name="_then" type="xs:string"/>
          <xs:attribute name="_else" type="xs:string"/>
          <xs:assert test="exists(@test | @_test)"/>
          <xs:assert test="not(exists(@then | @_then) and 
            (exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="import" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="href" type="xs:anyURI"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:assert test="exists(@href | @_href)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="import-schema" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xs:schema" minOccurs="0" maxOccurs="1"/>
          </xs:sequence>
          <xs:attribute name="namespace" type="xs:anyURI"/>
          <xs:attribute name="role" type="xs:NCName"/>
          <xs:attribute name="schema-location" type="xs:anyURI"/>
          <xs:attribute name="_namespace" type="xs:string"/>
          <xs:attribute name="_role" type="xs:string"/>
          <xs:attribute name="_schema-location" type="xs:string"/>
          <xs:assert test="not(exists(@schema-location | @_schema-location) and exists(xs:schema))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   XTSE0215: It is a static error if an <code>xsl:import-schema</code> element
                   that contains an xs:schema element has a <code>schema-location</code>
                   attribute
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="include" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="href" type="xs:anyURI"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:assert test="exists(@href | @_href)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="iterate" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element ref="xsl:on-completion" minOccurs="0" maxOccurs="1"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="key" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="match" type="xsl:pattern"/>
          <xs:attribute name="use" type="xsl:expression"/>
          <xs:attribute name="composite" type="xsl:yes-or-no"/>
          <xs:attribute name="collation" type="xs:anyURI"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_match" type="xs:string"/>
          <xs:attribute name="_use" type="xs:string"/>
          <xs:attribute name="_composite" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="exists(@match | @_match)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="map"
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-and-select">
          <xs:attribute name="duplicates" type="xsl:expression"/>
          <xs:attribute name="_duplicates" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="map-entry" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-and-select">
          <xs:attribute name="key" type="xsl:expression"/>
          <xs:attribute name="_key" type="xs:string"/>
          <xs:assert test="exists(@key | @_key)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="matching-substring" type="xsl:sequence-constructor-or-select"/>

  <xs:element name="merge" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:merge-source" minOccurs="1" maxOccurs="unbounded"/>
            <xs:element ref="xsl:merge-action" minOccurs="1" maxOccurs="1"/>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="merge-action" type="xsl:sequence-constructor"/>

  <xs:element name="merge-key" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="lang" type="xsl:avt"/>
          <xs:attribute name="order" type="xsl:avt"/>
          <xs:attribute name="collation" type="xsl:avt"/>
          <xs:attribute name="case-order" type="xsl:avt"/>
          <xs:attribute name="data-type" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_lang" type="xs:string"/>
          <xs:attribute name="_order" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:attribute name="_case-order" type="xs:string"/>
          <xs:attribute name="_data-type" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="merge-source">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:merge-key" minOccurs="1" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xs:NCName"/>
          <xs:attribute name="for-each-item" type="xsl:expression"/>
          <xs:attribute name="for-each-source" type="xsl:expression"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no"/>
          <xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
          <xs:attribute name="sort-before-merge" type="xsl:yes-or-no"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_for-each-item" type="xs:string"/>
          <xs:attribute name="_for-each-source" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-accumulators" type="xs:string"/>
          <xs:attribute name="_sort-before-merge" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="message" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="terminate" type="xsl:avt" default="no"/>
          <xs:attribute name="error-code" type="xsl:avt"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_terminate" type="xs:string"/>
          <xs:attribute name="_error-code" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="mode" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="false">
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:template"/> 
            <xs:element ref="xsl:fallback"/> 
          </xs:choice>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="copy-namespaces" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
          <xs:attribute name="on-no-match" type="xsl:on-no-match-type" default="text-only-copy"/>
          <xs:attribute name="on-multiple-match"
                        type="xsl:on-multiple-match-type"
                        default="use-last"/>
          <xs:attribute name="warning-on-no-match" type="xsl:yes-or-no"/>
          <xs:attribute name="warning-on-multiple-match" type="xsl:yes-or-no"/>
          <xs:attribute name="typed" type="xsl:typed-type"/>
          <xs:attribute name="visibility">
            <xs:simpleType>
              <xs:restriction base="xsl:visibility-type">
                <xs:enumeration value="public"/>
                <xs:enumeration value="private"/>
                <xs:enumeration value="final"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_copy-namespaces" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-accumulators" type="xs:string"/>
          <xs:attribute name="_on-no-match" type="xs:string"/>
          <xs:attribute name="_on-multiple-match" type="xs:string"/>
          <xs:attribute name="_warning-on-no-match" type="xs:string"/>
          <xs:attribute name="_warning-on-multiple-match" type="xs:string"/>
          <xs:attribute name="_typed" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>


  <xs:element name="namespace" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="namespace-alias" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="stylesheet-prefix" type="xsl:prefix-or-default"/>
          <xs:attribute name="result-prefix" type="xsl:prefix-or-default"/>
          <xs:attribute name="_stylesheet-prefix" type="xs:string"/>
          <xs:attribute name="_result-prefix" type="xs:string"/>
          <xs:assert test="exists(@stylesheet-prefix | @_stylesheet-prefix)"/>
          <xs:assert test="exists(@result-prefix | @_result-prefix)"/>
          <xs:assert test="every $prefix in (@stylesheet-prefix, @result-prefix)/normalize-space(.)[. ne '#default']
                           satisfies $prefix = in-scope-prefixes(.)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>


  <xs:element name="next-iteration" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:with-param" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>


  <xs:element name="next-match" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:with-param"/>
            <xs:element ref="xsl:fallback"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="non-matching-substring" type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="note" type="xs:anyType"/>

  <xs:element name="number" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:attribute name="value" type="xsl:expression"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="level" type="xsl:level" default="single"/>
          <xs:attribute name="count" type="xsl:pattern"/>
          <xs:attribute name="from" type="xsl:pattern"/>
          <xs:attribute name="format" type="xsl:avt" default="1"/>
          <xs:attribute name="lang" type="xsl:avt"/>
          <xs:attribute name="letter-value" type="xsl:avt"/>
          <xs:attribute name="ordinal" type="xsl:avt"/>
          <xs:attribute name="start-at" type="xsl:avt"/>
          <xs:attribute name="grouping-separator" type="xsl:avt"/>
          <xs:attribute name="grouping-size" type="xsl:avt"/>
          <xs:attribute name="_value" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_level" type="xs:string"/>
          <xs:attribute name="_count" type="xs:string"/>
          <xs:attribute name="_from" type="xs:string"/>
          <xs:attribute name="_format" type="xs:string"/>
          <xs:attribute name="_lang" type="xs:string"/>
          <xs:attribute name="_letter-value" type="xs:string"/>
          <xs:attribute name="_ordinal" type="xs:string"/>
          <xs:attribute name="_start-at" type="xs:string"/>
          <xs:attribute name="_grouping-separator" type="xs:string"/>
          <xs:attribute name="_grouping-size" type="xs:string"/>
          <xs:assert test="if (exists(@value | @_value)) 
                           then empty((@select | @_select, @count | @_count, @from | @_from)) 
                            and (exists(@_level) or normalize-space(@level)='single') 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if the value attribute of <code>xsl:number</code> is
                   present unless the <code>select</code>, <code>level</code>, <code>count</code>, 
                   and <code>from</code> attributes are all absent.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="on-completion" type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="on-empty"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>
  
  <xs:element name="on-non-empty"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor-or-select"/>

  <xs:element name="otherwise" 
              type="xsl:sequence-constructor-or-select"/>

  <xs:element name="output" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent >
        <xs:extension base="xsl:element-only-generic-element-type">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="method" type="xsl:method"/>
          <xs:attribute name="allow-duplicate-names" type="xsl:yes-or-no"/>
          <xs:attribute name="build-tree" type="xsl:yes-or-no"/>
          <xs:attribute name="byte-order-mark" type="xsl:yes-or-no"/>
          <xs:attribute name="cdata-section-elements" type="xsl:EQNames"/>
          <xs:attribute name="doctype-public" type="xs:string"/>
          <xs:attribute name="doctype-system" type="xs:string"/>
          <xs:attribute name="encoding" type="xs:string"/>
          <xs:attribute name="escape-solidus" type="xsl:yes-or-no"/>
          <xs:attribute name="escape-uri-attributes" type="xsl:yes-or-no"/>
          <xs:attribute name="html-version" type="xs:decimal"/>
          <xs:attribute name="include-content-type" type="xsl:yes-or-no"/>
          <xs:attribute name="indent" type="xsl:yes-or-no"/>
          <xs:attribute name="item-separator" type="xs:string"/>
          <xs:attribute name="json-lines" type="xsl:yes-or-no"/>
          <xs:attribute name="json-node-output-method" type="xsl:method"/>
          <xs:attribute name="media-type" type="xs:string"/>
          <xs:attribute name="normalization-form" type="xs:NMTOKEN"/>
          <xs:attribute name="omit-xml-declaration" type="xsl:yes-or-no"/>
          <xs:attribute name="parameter-document" type="xs:anyURI"/>
          <xs:attribute name="standalone" type="xsl:yes-or-no-or-omit"/>
          <xs:attribute name="suppress-indentation" type="xsl:EQNames"/>
          <xs:attribute name="undeclare-prefixes" type="xsl:yes-or-no"/>
          <xs:attribute name="use-character-maps" type="xsl:EQNames"/>
          <xs:attribute name="version" type="xs:NMTOKEN"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_method" type="xs:string"/>
          <xs:attribute name="_allow-duplicate-names" type="xs:string"/>
          <xs:attribute name="_build-tree" type="xs:string"/>
          <xs:attribute name="_byte-order-mark" type="xs:string"/>
          <xs:attribute name="_cdata-section-elements" type="xs:string"/>
          <xs:attribute name="_doctype-public" type="xs:string"/>
          <xs:attribute name="_doctype-system" type="xs:string"/>
          <xs:attribute name="_encoding" type="xs:string"/>
          <xs:attribute name="_escape-solidus" type="xs:string"/>
          <xs:attribute name="_escape-uri-attributes" type="xs:string"/>
          <xs:attribute name="_html-version" type="xs:string"/>
          <xs:attribute name="_include-content-type" type="xs:string"/>
          <xs:attribute name="_indent" type="xs:string"/>
          <xs:attribute name="_item-separator" type="xs:string"/>
          <xs:attribute name="_json-lines" type="xs:string"/>
          <xs:attribute name="_json-node-output-method" type="xs:string"/>
          <xs:attribute name="_media-type" type="xs:string"/>
          <xs:attribute name="_normalization-form" type="xs:string"/>
          <xs:attribute name="_omit-xml-declaration" type="xs:string"/>
          <xs:attribute name="_parameter-document" type="xs:string"/>
          <xs:attribute name="_standalone" type="xs:string"/>
          <xs:attribute name="_suppress-indentation" type="xs:string"/>
          <xs:attribute name="_undeclare-prefixes" type="xs:string"/>
          <xs:attribute name="_use-character-maps" type="xs:string"/>
          <xs:attribute name="_version" type="xs:string"/>
          <xs:anyAttribute namespace="##other" processContents="lax"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="output-character">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="character" type="xsl:char"/>
          <xs:attribute name="string" type="xs:string"/>
          <xs:attribute name="_character" type="xs:string"/>
          <xs:attribute name="_string" type="xs:string"/>
          <xs:assert test="exists(@character | @_character)"/>
          <xs:assert test="exists(@string | @_string)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="override">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:use-package</code> and defines 
            any overriding definitions of components that the containing package wishes to make 
            to the components made available from a library package.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:template"/>
            <xs:element ref="xsl:function"/>
            <xs:element ref="xsl:variable"/>
            <xs:element ref="xsl:param"/>
            <xs:element ref="xsl:attribute-set"/>
          </xs:choice>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
    
  <xs:element name="package">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="xsl:expose"/>
              <xs:element ref="xsl:declaration"/>
              <xs:any namespace="##other" processContents="lax"/>
            </xs:choice>
          </xs:sequence>
          <xs:attribute name="declared-modes" type="xsl:yes-or-no"/>
          <xs:attribute name="id" type="xs:ID"/>
          <xs:attribute name="name" type="xs:anyURI"/>
          <xs:attribute name="package-version" type="xs:string"/>
          <xs:attribute name="input-type-annotations" type="xsl:input-type-annotations-type"/>
          <xs:attribute name="fixed-namespaces" type="xsl:fixed-namespaces-type"/>
          <xs:attribute name="_declared-modes" type="xs:string"/>
          <xs:attribute name="_id" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_package-version" type="xs:string"/>
          <xs:attribute name="_input-type-annotations" type="xs:string"/>
          <xs:attribute name="_fixed-namespaces" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="param" substitutionGroup="xsl:declaration">
    <xs:annotation>
      <xs:documentation>
        <p>Declaration of the <code>xsl:param</code> element, used both defining function
            parameters, template parameters, parameters to <code>xsl:iterate</code>,
            and global stylesheet parameters.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="required" type="xsl:yes-or-no"/>
          <xs:attribute name="tunnel" type="xsl:yes-or-no"/>
          <xs:attribute name="static" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_required" type="xs:string"/>
          <xs:attribute name="_tunnel" type="xs:string"/>
          <xs:attribute name="_static" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1')) 
                           then empty((*,text())) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   When the attribute <code>static="yes"</code> is specified, the <code>xsl:param</code>
                   element must have empty content.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  

  <xs:element name="perform-sort" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:sort" minOccurs="1" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:assert test="every $e in subsequence(xsl:sort, 2) 
                           satisfies empty($e/(@stable | @_stable))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   It is a static error if an <code>xsl:sort</code> element other than the first
                   in a sequence of sibling <code>xsl:sort</code> elements has a <code>stable</code>
                   attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="preserve-space" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="elements" type="xsl:nametests"/>
          <xs:attribute name="_elements" type="xs:string"/>
          <xs:assert test="exists(@elements | @_elements)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="processing-instruction" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:avt"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="record">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">  
          <xs:attribute name="as" form="qualified" type="xsl:sequence-type"/>
          <xs:attribute name="duplicates" form="qualified" type="xsl:sequence-type"/>
          <xs:attribute name="_as" form="qualified" type="xs:string"/>
          <xs:attribute name="_duplicates" form="qualified" type="xs:string"/>
          <xs:attributeGroup ref="xsl:literal-result-element-attributes"/>
          <xs:anyAttribute namespace="##local" processContents="lax"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="record-type" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:field" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="extensible" type="xsl:yes-or-no"/>
          <xs:attribute name="visibility" type="xsl:visibility-type"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_extensible" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="result-document" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="format" type="xsl:avt"/>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="href" type="xsl:avt"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="method" type="xsl:avt"/>
          <xs:attribute name="allow-duplicate-names" type="xsl:avt"/>
          <xs:attribute name="build-tree" type="xsl:avt"/>
          <xs:attribute name="byte-order-mark" type="xsl:avt"/>
          <xs:attribute name="cdata-section-elements" type="xsl:avt"/>
          <xs:attribute name="doctype-public" type="xsl:avt"/>
          <xs:attribute name="doctype-system" type="xsl:avt"/>
          <xs:attribute name="encoding" type="xsl:avt"/>
          <xs:attribute name="escape-solidus" type="xsl:avt"/>
          <xs:attribute name="escape-uri-attributes" type="xsl:avt"/>
          <xs:attribute name="html-version" type="xsl:avt"/>
          <xs:attribute name="include-content-type" type="xsl:avt"/>
          <xs:attribute name="indent" type="xsl:avt"/>
          <xs:attribute name="item-separator" type="xsl:avt"/>
          <xs:attribute name="json-lines" type="xsl:avt"/>
          <xs:attribute name="json-node-output-method" type="xsl:avt"/>
          <xs:attribute name="media-type" type="xsl:avt"/>
          <xs:attribute name="normalization-form" type="xsl:avt"/>
          <xs:attribute name="omit-xml-declaration" type="xsl:avt"/>
          <xs:attribute name="parameter-document" type="xsl:avt"/>
          <xs:attribute name="standalone" type="xsl:avt"/>
          <xs:attribute name="suppress-indentation" type="xsl:avt"/>
          <xs:attribute name="undeclare-prefixes" type="xsl:avt"/>
          <xs:attribute name="use-character-maps" type="xsl:EQNames"/>
          <xs:attribute name="output-version" type="xsl:avt"/>
          <xs:attribute name="_format" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:attribute name="_method" type="xs:string"/>
          <xs:attribute name="_allow-duplicate-names" type="xs:string"/>
          <xs:attribute name="_build-tree" type="xs:string"/>
          <xs:attribute name="_byte-order-mark" type="xs:string"/>
          <xs:attribute name="_cdata-section-elements" type="xs:string"/>
          <xs:attribute name="_doctype-public" type="xs:string"/>
          <xs:attribute name="_doctype-system" type="xs:string"/>
          <xs:attribute name="_encoding" type="xs:string"/>
          <xs:attribute name="_escape-solidus" type="xs:string"/>
          <xs:attribute name="_escape-uri-attributes" type="xs:string"/>
          <xs:attribute name="_html-version" type="xs:string"/>
          <xs:attribute name="_include-content-type" type="xs:string"/>
          <xs:attribute name="_indent" type="xs:string"/>
          <xs:attribute name="_item-separator" type="xs:string"/>
          <xs:attribute name="_json-lines" type="xs:string"/>
          <xs:attribute name="_json-node-output-method" type="xs:string"/>
          <xs:attribute name="_media-type" type="xs:string"/>
          <xs:attribute name="_normalization-form" type="xs:string"/>
          <xs:attribute name="_omit-xml-declaration" type="xs:string"/>
          <xs:attribute name="_parameter-document" type="xs:string"/>
          <xs:attribute name="_standalone" type="xs:string"/>
          <xs:attribute name="_suppress-indentation" type="xs:string"/>
          <xs:attribute name="_undeclare-prefixes" type="xs:string"/>
          <xs:attribute name="_use-character-maps" type="xs:string"/>
          <xs:attribute name="_output-version" type="xs:string"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="select"
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>  
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:assert test="empty(xsl:fallback/preceding-sibling::text()[normalize-space()])">
            <xs:annotation>
              <xs:documentation>
                <p>An xsl:fallback child must not be preceded by a non-whitespace text node.</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="sequence"
              substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="_as" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="sort">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="lang" type="xsl:avt"/>
          <xs:attribute name="data-type" type="xsl:avt"/>
          <xs:attribute name="order" type="xsl:avt" default="ascending"/>
          <xs:attribute name="case-order" type="xsl:avt"/>
          <xs:attribute name="collation" type="xsl:avt"/>
          <xs:attribute name="stable" type="xsl:avt"/>
          <xs:attribute name="_lang" type="xs:string"/>
          <xs:attribute name="_data-type" type="xs:string"/>
          <xs:attribute name="_order" type="xs:string"/>
          <xs:attribute name="_case-order" type="xs:string"/>
          <xs:attribute name="_collation" type="xs:string"/>
          <xs:attribute name="_stable" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="source-document" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="href" type="xsl:avt"/>
          <xs:attribute name="streamable" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="use-accumulators" type="xsl:accumulator-names"/>
          <xs:attribute name="type" type="xsl:EQName"/>
          <xs:attribute name="validation" type="xsl:validation-type"/>
          <xs:attribute name="_href" type="xs:string"/>
          <xs:attribute name="_streamable" type="xs:string"/>
          <xs:attribute name="_use-accumulators" type="xs:string"/>
          <xs:attribute name="_type" type="xs:string"/>
          <xs:attribute name="_validation" type="xs:string"/>
          <xs:assert test="exists(@href | @_href)"/>
          <xs:assert test="not(exists(@type | @_type) and exists(@validation | @_validation))">
            <xs:annotation>
              <xs:documentation>
                <p>The <code>type</code> and <code>validation</code> attributes are mutually exclusive
                  (if one is present, the other must be absent).</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="strip-space" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:attribute name="elements" type="xsl:nametests"/>
          <xs:attribute name="_elements" type="xs:string"/>
          <xs:assert test="exists(@elements | @_elements)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="stylesheet" substitutionGroup="xsl:transform"/>

  <xs:element name="switch" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:when" maxOccurs="unbounded"/>
            <xs:element ref="xsl:otherwise" minOccurs="0"/>
            <xs:element ref="xsl:fallback" minOccurs="0" maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="_select" type="xsl:avt"/>
          <xs:assert test="exists(@select | @_select)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="template" substitutionGroup="xsl:declaration">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:element ref="xsl:context-item" minOccurs="0" maxOccurs="1"/>
            <xs:element ref="xsl:param" minOccurs="0" maxOccurs="unbounded"/>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
          </xs:sequence>
          <xs:attribute name="match" type="xsl:pattern"/>
          <xs:attribute name="priority" type="xs:decimal"/>
          <xs:attribute name="mode" type="xsl:modes"/>
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type" default="item()*"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="_match" type="xs:string"/>
          <xs:attribute name="_priority" type="xs:string"/>
          <xs:attribute name="_mode" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:assert test="exists(@match | @_match) or exists(@name | @_name)">
            <xs:annotation>
              <xs:documentation>
                <p>
                   An <code>xsl:template</code> element must have either a <code>match</code> attribute or a
                   <code>name</code> attribute, or both.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (empty(@match | @_match)) 
                           then (empty(@mode | @_mode) and empty(@priority | @_priority)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   An <code>xsl:template</code> element that has no <code>match</code> attribute must have no
                   <code>mode</code> attribute and no <code>priority</code> attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="not(exists(@visibility | @_visibility) and empty(@name | @_name))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   An <code>xsl:template</code> element that has no <code>name</code> attribute must have no
                   <code>visibility</code> attribute
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (normalize-space(@visibility) = 'abstract') 
                           then empty(* except (xsl:context-item, xsl:param)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   If the <code>visibility</code> attribute is present with the value <code>abstract</code>
                   then (a) the sequence constructor defining the template body
                   must be empty: that is, the only permitted children are
                   <code>xsl:context-item</code> and <code>xsl:param</code>
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="not(normalize-space(@visibility) = 'abstract' and exists(@match))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   If the <code>visibility</code> attribute is present with the value <code>abstract</code>
                   then there must be no <code>match</code> attribute.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="every $e in xsl:param satisfies empty($e/(@visibility | @_visibility))">
            <xs:annotation>
              <xs:documentation>
                <p>A parameter for a template must have no <code>visibility</code> attribute.</p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="text" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="cdata" type="xsl:avt"/>
          <xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_cdata" type="xs:string"/>
          <xs:attribute name="_disable-output-escaping" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="transform-element-base-type">
    <xs:complexContent>
      <xs:restriction base="xsl:element-only-versioned-element-type">
        <xs:attribute name="version" type="xs:decimal" use="optional"/>
        <xs:attribute name="_version" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              <p>
                 The version attribute indicates the version of XSLT that the
                 stylesheet module requires. The attribute is required, unless the
                 <code>xsl:stylesheet</code> element is a child of an <code>xsl:package</code> element, in
                 which case it is optional: the default is then taken from the
                 parent <code>xsl:package</code> element.
              </p>
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:anyAttribute namespace="##other" processContents="lax"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:element name="transform">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="xsl:transform-element-base-type">
          <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="xsl:declaration"/>
              <xs:any namespace="##other" processContents="lax"/>
              <!-- weaker than XSLT 1.0 -->
            </xs:choice>
          </xs:sequence>
          <xs:attribute name="id" type="xs:ID"/>
          <xs:attribute name="input-type-annotations"
                        type="xsl:input-type-annotations-type"
                        default="unspecified"/>
          <xs:attribute name="fixed-namespaces"
                        type="xsl:fixed-namespaces-type"/>
          <xs:attribute name="_id" type="xs:string"/>
          <xs:attribute name="_input-type-annotations" type="xs:string"/>
          <xs:attribute name="_fixed-namespaces" type="xs:string"/>
          <!--* The 'static' attribute may be used on 'param' and 'variable'
              * only when they are top-level elements. *-->
          <xs:assert test="every $v in (.//xsl:param, .//xsl:variable)[exists(@static | @_static)] 
                           satisfies $v[parent::xsl:stylesheet or parent::xsl:transform or parent::xsl:override]">
            <xs:annotation>
              <xs:documentation>
                <p>
                   The static attribute must not be present on an <code>xsl:variable</code> or
                   <code>xsl:param</code> element unless it is a top-level element.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="every $prefix in (@exclude-result-prefixes[not(. = '#all')], 
                                             @extension-element-prefixes) 
                           satisfies ((if ($prefix = '#default') then '' else $prefix) = in-scope-prefixes(.))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   XTSE0808: It is a static error if a namespace prefix is used
                   within the <code>[xsl:]exclude-result-prefixes</code> attribute and there is
                   no namespace binding in scope for that prefix.
                </p>
                <p>
                   XTSE0809: It is a static error if the value #default is used
                   within the <code>[xsl:]exclude-result-prefixes</code> attribute and the
                   parent element of the <code>[xsl:]exclude-result-prefixes</code> attribute
                   has no default namespace.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="try" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:versioned-element-type">
          <xs:sequence>
            <xs:group ref="xsl:sequence-constructor-group"
                      minOccurs="0"
                      maxOccurs="unbounded"/>
            <xs:element ref="xsl:catch" minOccurs="1" maxOccurs="1"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="xsl:catch"/>
              <xs:element ref="xsl:fallback"/>
            </xs:choice>
          </xs:sequence>
          <xs:attribute name="rollback-output" type="xsl:yes-or-no" default="yes"/>
          <xs:attribute name="select" type="xsl:expression" use="optional"/>
          <xs:attribute name="_rollback-output" type="xs:string"/>
          <xs:attribute name="_select" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="use-package" substitutionGroup="xsl:declaration">
    <xs:annotation>
      <xs:documentation>
        <p>This element appears as a child of <code>xsl:package</code> and defines a dependency
            of the containing package on another package, identified by URI in the <code>name</code>
            attribute. The <code>package-version</code> attribute indicates which version of the
            library package is required, or may indicate a range of versions.</p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent mixed="false">
        <xs:extension base="xsl:element-only-versioned-element-type">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="xsl:accept"/>
            <xs:element ref="xsl:override"/>
          </xs:choice>
          <xs:attribute name="name" type="xs:anyURI"/>
          <xs:attribute name="package-version" type="xs:string"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_package-version" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="value-of" substitutionGroup="xsl:instruction">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="separator" type="xsl:avt"/>
          <xs:attribute name="cdata" type="xsl:avt"/>
          <xs:attribute name="disable-output-escaping" type="xsl:yes-or-no" default="no"/>
          <xs:attribute name="_separator" type="xs:string"/>
          <xs:attribute name="_cdata" type="xs:string"/>
          <xs:attribute name="_disable-output-escaping" type="xs:string"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="variable" substitutionGroup="xsl:declaration xsl:instruction">
    <xs:annotation>
      <xs:documentation>
        <p>Declaration of the <code>xsl:variable</code> element, used both for local
            and global variable bindings.</p>
        <p>
           This definition takes advantage of the ability in XSD 1.1 for an element
           to belong to more than one substitution group. A global variable is a
           declaration, while a local variable can appear as an instruction in a
           sequence constructor.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="visibility" type="xsl:visibility-not-hidden-type"/>
          <xs:attribute name="static" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_visibility" type="xs:string"/>
          <xs:attribute name="_static" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
          <xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1')) 
                           then (exists(@_visibility) or normalize-space(@visibility) 
                                       = ('', 'private', 'final')) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   When the static attribute is present with the value yes, the
                   visibility attribute must not have a value other than private or
                   final.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
          <xs:assert test="if (normalize-space(@static) = ('yes', 'true', '1')) 
                           then (empty((*, text())) and exists(@select | @_select)) 
                           else true()">
            <xs:annotation>
              <xs:documentation>
                <p>
                   When the attribute <code>static="yes"</code> is specified, the <code>xsl:variable</code>
                   element must have empty content, and the <code>select</code> attribute must
                   be present to define the value of the variable.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assert>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="when">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor">
          <xs:attribute name="select" type="xsl:expression"/>
          <xs:attribute name="test" type="xsl:expression"/>
          <xs:attribute name="_select" type="xs:string"/>
          <xs:attribute name="_test" type="xs:string"/>
          <xs:assert test="exists(@test | @_test)"/>
          <xs:assert test="not(exists(@select | @_select) and 
            (exists(* except xsl:fallback) or exists(text()[normalize-space()])))"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="where-populated"
              substitutionGroup="xsl:instruction"
              type="xsl:sequence-constructor"/>

  <xs:element name="with-param">
    <xs:complexType>
      <xs:complexContent mixed="true">
        <xs:extension base="xsl:sequence-constructor-or-select">
          <xs:attribute name="name" type="xsl:EQName"/>
          <xs:attribute name="as" type="xsl:sequence-type"/>
          <xs:attribute name="tunnel" type="xsl:yes-or-no"/>
          <xs:attribute name="_name" type="xs:string"/>
          <xs:attribute name="_as" type="xs:string"/>
          <xs:attribute name="_tunnel" type="xs:string"/>
          <xs:assert test="exists(@name | @_name)"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>

  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation> PART C: definition of literal result elements There are three ways to define
      the literal result elements permissible in a stylesheet. (a) do nothing. This allows any
      element to be used as a literal result element, provided it is not in the XSLT namespace (b)
      declare all permitted literal result elements as members of the <code>xsl:literal-result-element</code>
      substitution group (c) redefine the model group xsl:result-elements to accommodate all
      permitted literal result elements. Literal result elements are allowed to take certain
      attributes in the XSLT namespace. These are defined in the attribute group
      <code>literal-result-element-attributes</code>, which can be included in the definition of any literal
      result element. </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <xs:element name="literal-result-element" abstract="true" type="xs:anyType"/>

  <xs:attributeGroup name="literal-result-element-attributes">
    <xs:attribute name="default-collation" 
                  form="qualified" 
                  type="xsl:uri-list"/>
    <xs:attribute name="default-mode" 
                  form="qualified"  
                  type="xsl:default-mode-type"/>
    <xs:attribute name="default-validation" 
                  form="qualified" 
                  type="xsl:validation-strip-or-preserve"
                  default="strip"/>
    <xs:attribute name="expand-text" 
                  form="qualified"  
                  type="xsl:yes-or-no"/>
    <xs:attribute name="extension-element-prefixes" 
                  form="qualified" 
                  type="xsl:prefix-list"/>
    <xs:attribute name="exclude-result-prefixes" 
                  form="qualified" 
                  type="xsl:prefix-list-or-all"/>
    <xs:attribute name="inherit-namespaces"
                  form="qualified"
                  type="xsl:yes-or-no"
                  default="yes"/>
    <xs:attribute name="schema-role"
                  form="qualified"
                  type="xs:NCName"
                  default="yes"/>
    <xs:attribute name="use-attribute-sets"
                  form="qualified"
                  type="xsl:EQNames"
                  default=""/>
    <xs:attribute name="use-when" 
                  form="qualified" 
                  type="xsl:expression"/>
    <xs:attribute name="version" 
                  form="qualified" 
                  type="xs:decimal"/>
    <xs:attribute name="type" 
                  form="qualified" 
                  type="xsl:EQName"/>
    <xs:attribute name="validation" 
                  form="qualified" 
                  type="xsl:validation-type"/>
    <xs:attribute name="xpath-default-namespace" 
                  form="qualified" 
                  type="xs:anyURI"/>
  </xs:attributeGroup>

  <xs:group name="result-elements">
    <xs:choice>
      <xs:element ref="xsl:literal-result-element"/>
      <xs:any namespace="##other" processContents="lax"/>
      <xs:any namespace="##local" processContents="lax"/>
    </xs:choice>
  </xs:group>


  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
  <xs:annotation>
    <xs:documentation>
      <p>
         PART D: definitions of simple types used in stylesheet attributes
      </p>
    </xs:documentation>
  </xs:annotation>
  <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

  <xs:simpleType name="accumulator-names">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>use-accumulators</code> attribute of <code>xsl:source-document</code>, 
           <code>xsl:merge-source</code>, or <code>xsl:global-context-item</code>: 
           either a list, each member being a QName; or the value <code>#all</code>
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union>
      <xs:simpleType>
        <xs:list itemType="xsl:EQName"/>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#all"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType> 
  
  <xs:simpleType name="avt">
    <xs:annotation>
      <xs:documentation>
        <p>
           This type is used for all attributes that allow an attribute value
           template. The general rules for the syntax of attribute value templates,
           and the specific rules for each such attribute, are described in the
           XSLT 4.0 Recommendation.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string"/>
  </xs:simpleType>
  
  <xs:simpleType name="char">
    <xs:annotation>
      <xs:documentation>
        <p>
           A string containing exactly one character.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:length value="1"/>
    </xs:restriction>
  </xs:simpleType>

           
  <xs:simpleType name="char-optionally-expanded">
    <xs:annotation>
      <xs:documentation>
        <p>
           A string containing either a single character, or a single character
           followed by a colon followed by an arbitrary string
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value=".(:.*)?"/>
    </xs:restriction>
  </xs:simpleType> 

           
  <xs:simpleType name="component-kind-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes a kind of component within a package.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="template"/>
      <xs:enumeration value="function"/>
      <xs:enumeration value="variable"/>
      <xs:enumeration value="attribute-set"/>
      <xs:enumeration value="mode"/>
      <xs:enumeration value="*"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="default-mode-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>default-mode</code> attribute of <code>xsl:stylesheet</code>, 
           <code>xsl:transform</code>, <code>xsl:package</code>
           (or any other xsl:* element): either a QName or #unnamed.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#unnamed"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
  
  <xs:simpleType name="component-test">
    <xs:annotation>
      <xs:documentation>
        <p> A NameTest or a named function reference. </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:nametest xsl:named-function-reference"/>
  </xs:simpleType>

  <xs:simpleType name="component-tests">
    <xs:annotation>
      <xs:documentation>
        <p> A list of NameTests or named function references</p>
      </xs:documentation>
    </xs:annotation>
    <xs:list itemType="xsl:component-test"/>
  </xs:simpleType>

  <xs:simpleType name="expression">
    <xs:annotation>
      <xs:documentation>
        <p>
           An XPath 4.0 expression.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value=".+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="fixed-namespaces-type">
    <xs:annotation>
      <xs:documentation>
        <p>
          A sequence of tokens, each of which may be one of #default, an NCName, a prefix=namespace binding, or a URI
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:list>
      <xs:simpleType>
        <xs:union memberTypes="xsl:fixed-namespaces-type-standard xs:NCName xsl:fixed-namespaces-type-prefix-binding xs:anyURI"/>
      </xs:simpleType>
    </xs:list>
 
  </xs:simpleType>
  
  <xs:simpleType name="fixed-namespaces-type-standard">
    <xs:restriction base="xs:token">
       <xs:enumeration value="#standard"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="fixed-namespaces-type-prefix-binding">
    <xs:restriction base="xs:string">
       <xs:pattern value="([\i-[:]][\c-[:]]*:)=.+"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="item-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           An XPath 4.0 ItemType
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value=".+"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="input-type-annotations-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes how type annotations in source documents are handled.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="preserve"/>
      <xs:enumeration value="strip"/>
      <xs:enumeration value="unspecified"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="level">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>level</code> attribute of <code>xsl:number</code>: 
           one of <code>single</code>, <code>multiple</code>, or <code>any</code>.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="single"/>
      <xs:enumeration value="multiple"/>
      <xs:enumeration value="any"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="mode">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>mode</code> attribute of <code>xsl:apply-templates</code>: 
           either a QName, or <code>#current</code>,
           or <code>#unnamed</code>, or <code>#default</code>.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#default"/>
          <xs:enumeration value="#unnamed"/>
          <xs:enumeration value="#current"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="modes">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>mode</code> attribute of <code>xsl:template</code>: either a list, each member being
           either a QName or <code>#default</code> or <code>#unnamed</code>; or the value <code>#all</code>
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union>
      <xs:simpleType>
        <xs:restriction>
          <xs:simpleType>
            <xs:list>
              <xs:simpleType>
                <xs:union memberTypes="xsl:EQName">
                  <xs:simpleType>
                    <xs:restriction base="xs:token">
                      <xs:enumeration value="#default"/>
                      <xs:enumeration value="#unnamed"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:union>
              </xs:simpleType>
            </xs:list>
          </xs:simpleType>
          <xs:assertion test="count($value) = count(distinct-values($value))">
            <xs:annotation>
              <xs:documentation>
                <p>
                   XTSE0550: It is a static error if the same token is included
                   more than once in the list.
                </p>
              </xs:documentation>
            </xs:annotation>
          </xs:assertion>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#all"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

   <xs:simpleType name="named-function-reference">
    <xs:annotation>
      <xs:documentation>
        <p> In simple terms, this is an EQName followed by "#arity" where "arity" is a non-negative integer. However,
          XSD doesn't allow us to reuse the definition of EQName in this way, so it has to be defined from scratch. The simplest
          way to do this is with an assertion. However, the assertion cannot exploit types such as <code>xsl:EQName</code> defined in this
        schema</p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value="((Q\{.*\})|([\i-[:]][\c-[:]]*:))?[\i-[:]][\c-[:]]*#[0-9]+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="nametest">
    <xs:annotation>
      <xs:documentation>
        <p> A list of NameTests, as defined in the XPath 31 Recommendation. Each NameTest is either
          an EQName, or "*", or "prefix:*", or "*:localname", or the wildcard Q{uri}*. </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="*"/>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:pattern value="[\i-[:]][\c-[:]]*:\*"/>
          <xs:pattern value="\*:[\i-[:]][\c-[:]]*"/>
          <xs:pattern value="Q\{[^}]*\}\*"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="nametests">
    <xs:annotation>
      <xs:documentation>
        <p> A list of NameTests, as defined in the XPath 4.0 Recommendation. Each NameTest is either
          a QName, or "*", or "prefix:*", or "*:localname" </p>
      </xs:documentation>
    </xs:annotation>
    <xs:list itemType="xsl:nametest"/>
  </xs:simpleType>
  
  <xs:simpleType name="on-multiple-match-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the action to be taken when there are several template rules
           to match an item in a given mode.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="use-last"/>
      <xs:enumeration value="fail"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="on-no-match-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the action to be taken when there is no template rule to match
           an item in a given mode.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="deep-copy"/>
      <xs:enumeration value="shallow-copy"/>
      <xs:enumeration value="shallow-copy-all"/>
      <xs:enumeration value="deep-skip"/>
      <xs:enumeration value="shallow-skip"/>
      <xs:enumeration value="text-only-copy"/>
      <xs:enumeration value="fail"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="prefix-list-or-all">
    <xs:union memberTypes="xsl:prefix-list">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#all"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="prefix-list">
    <xs:list itemType="xsl:prefix-or-default"/>
  </xs:simpleType>

  <xs:simpleType name="method">
    <xs:annotation>
      <xs:documentation>
        <p>
           The <code>method</code> attribute of <code>xsl:output</code>: Either one of the recognized names
           "xml", "xhtml", "html", "text", "json", or "adaptive",
            or an EQName that must include a prefix or namespace URI.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName-in-namespace">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="xml"/>
          <xs:enumeration value="xhtml"/>
          <xs:enumeration value="html"/>
          <xs:enumeration value="text"/>
          <xs:enumeration value="json"/>
          <xs:enumeration value="adaptive"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="pattern">
    <xs:annotation>
      <xs:documentation>
        <p>
           A match pattern as defined in the XSLT 4.0 Recommendation. The syntax
           for patterns is a restricted form of the syntax for XPath 4.0
           expressions. 
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:expression"/>
  </xs:simpleType>

  <xs:simpleType name="prefix-or-default">
    <xs:annotation>
      <xs:documentation>
        <p>
           Either a namespace prefix, or <code>#default</code>. Used in the <code>xsl:namespace-alias</code>
           element.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xs:NCName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="#default"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="EQNames">
    <xs:annotation>
      <xs:documentation>
        <p>
           A list of QNames. Used in the <code>[xsl:]use-attribute-sets</code> attribute of
           various elements, and in the <code>cdata-section-elements</code> attribute of
           <code>xsl:output</code>.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:list itemType="xsl:EQName"/>
  </xs:simpleType>

  <xs:simpleType name="EQName">
    <xs:annotation>
      <xs:documentation>
        <p>
           An extended QName. This schema does not use the built-in type <code>xs:QName</code>,
           but rather defines its own QName type. This may be either a local name,
           or a prefixed QName, or a name written using the extended QName notation
           <code>Q{uri}[prefix:]local</code>
        </p>
        <p>In XSLT 4.0, where a QName is used in the <code>name</code> attribute
        of (say) <code>xsl:template</code> or <code>xsl:call-template</code>, the prefix
        does not have to be bound in an XML namespace declaration; rather it can be bound
        in a <code>fixed-namespaces</code> attribute on the <code>xsl:stylesheet</code>
        element. Therefore, the built-in <code>xs:QName</code> type cannot be used.
        This schema does not attempt to verify that namespace prefixes have been
        properly declared.</p>
        
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xs:NCName">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:pattern value="[\i-[:]][\c-[:]]*:[\i-[:]][\c-[:]]*"/>
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:pattern value="Q\{[^{}]*\}[\i-[:]][\c-[:]]*(:[\i-[:]][\c-[:]]*)?"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
  
  <xs:simpleType name="EQName-in-namespace">
    <xs:annotation>
      <xs:documentation>
        <p>
           A subtype of EQNames that excludes no-namespace names
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:EQName">
      <xs:pattern value="Q\{.+\}.+|\i\c*:.+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="sequence-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           The description of a datatype, conforming to the SequenceType production
           defined in the XPath 4.0 Recommendation
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:pattern value=".+"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="streamability-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the category to which a function belongs, with regards to its
           streaming behavior.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="xsl:EQName-in-namespace">
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:enumeration value="unclassified"/>
          <xs:enumeration value="absorbing"/>
          <xs:enumeration value="inspection"/>
          <xs:enumeration value="filter"/>
          <xs:enumeration value="shallow-descent"/>
          <xs:enumeration value="deep-descent"/>
          <xs:enumeration value="ascent"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
  
  <xs:simpleType name="tokens">
    <xs:list itemType="xs:token"/>
  </xs:simpleType>

  <xs:simpleType name="typed-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes whether a mode is designed to match typed or untyped nodes.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
      <xs:enumeration value="strict"/>
      <xs:enumeration value="lax"/>
      <xs:enumeration value="unspecified"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="uri-list">
    <xs:list itemType="xs:anyURI"/>
  </xs:simpleType>

  <xs:simpleType name="validation-strip-or-preserve">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes different ways of type-annotating an element or attribute.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:validation-type">
      <xs:enumeration value="preserve"/>
      <xs:enumeration value="strip"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="validation-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes different ways of type-annotating an element or attribute.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="strict"/>
      <xs:enumeration value="lax"/>
      <xs:enumeration value="preserve"/>
      <xs:enumeration value="strip"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="visibility-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the visibility of a component within a package.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="public"/>
      <xs:enumeration value="private"/>
      <xs:enumeration value="final"/>
      <xs:enumeration value="abstract"/>
      <xs:enumeration value="hidden"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="visibility-not-hidden-type">
    <xs:annotation>
      <xs:documentation>
        <p>
           Describes the visibility of a component within a package.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:visibility-type">
      <xs:enumeration value="public"/>
      <xs:enumeration value="private"/>
      <xs:enumeration value="final"/>
      <xs:enumeration value="abstract"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="yes-or-no">
    <xs:annotation>
      <xs:documentation>
        <p>
           One of the values "yes" or "no": the values "true" or "false", or "1" or
           "0" are accepted as synonyms.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="yes-or-no-or-maybe">
    <xs:annotation>
      <xs:documentation>
        <p>
           One of the values "yes" or "no" or "omit". The values "true" or "false",
           or "1" or "0" are accepted as synonyms of "yes" and "no" respectively.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
      <xs:enumeration value="maybe"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="yes-or-no-or-omit">
    <xs:annotation>
      <xs:documentation>
        <p>
           One of the values "yes" or "no" or "omit". The values "true" or "false",
           or "1" or "0" are accepted as synonyms of "yes" and "no" respectively.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:token">
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="false"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="0"/>
      <xs:enumeration value="omit"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="zero-digit">
    <xs:annotation>
      <xs:documentation>
        <p>
           A digit that has the numerical value zero.
        </p>
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xsl:char">
      <xs:pattern value="\p{Nd}"/>
      <xs:assertion test="matches(string-join(codepoints-to-string(
           for $i in 0 to 9 return string-to-codepoints($value) + $i), ''), '\p{Nd}{10}')"/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

H.2 Relax-NG Schema for XSLT Stylesheets

The following Relax-NG schema may be used to validate XSLT 4.0 stylesheet modules. Similar caveats apply as for the XSD 1.1 version.

A copy of this schema is available at schema-for-xslt30.rnc

TODO: Needs updating for 4.0.

# XSLT 4.0 Relax NG Schema
# 
# Copyright (c) 2010-2016, Mohamed ZERGAOUI (Innovimax)
# Portions © 2024, XQuery and XSLT Extensions Community Group
# 
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer. Redistributions in binary
# form must reproduce the above copyright notice, this list of conditions and
# the following disclaimer in the documentation and/or other materials provided
# with the distribution. Neither the name of the Mohamed ZERGAOUI or Innovimax
# nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
namespace local = ""
default namespace xsl = "http://www.w3.org/1999/XSL/Transform"
namespace xs = "http://www.w3.org/2001/XMLSchema"

start =
  stylesheet.element
  | transform.element
  | package.element  
  | literal-result-element-as-stylesheet
  
sequence-constructor.model = (instruction.category | record.element | literal-result-element | text)*

literal-result-element-as-stylesheet =
  element * - xsl:* {
    attribute xsl:version { decimal.datatype },
    literal-result-element-no-version.atts,
    sequence-constructor.model
  }

literal-result-element =
  element * - xsl:* {
     literal-result-element.atts,
     sequence-constructor.model
  }

literal-result-element.atts =
  literal-result-element-no-version.atts,
  attribute xsl:version { text }?

# These attributes may also appear on a literal result element, but in this case, to distinguish them from user-defined attributes, 
# the names of the attributes are in the XSLT namespace. They are thus typically written as 
# xsl:default-collation,
# xsl:default-mode,
# xsl:default-validation,
# xsl:exclude-result-prefixes,
# xsl:expand-text,
# xsl:extension-element-prefixes,
# xsl:use-when,
# xsl:version,
# or xsl:xpath-default-namespace.
literal-result-element-no-version.atts =
   attribute * - xsl:* { avt.datatype }*
 & attribute xsl:default-collation { uris.datatype }?
 & attribute xsl:default-mode { eqname.datatype | '#unnamed' }?
 & attribute xsl:default-validation  { "preserve" | "strip" }?
 & attribute xsl:exclude-result-prefixes { exclude.prefixes.datatype }? # or prefixes.datatype ?
 & attribute xsl:expand-text { boolean.datatype }?
 & attribute xsl:extension-element-prefixes { extension.prefixes.datatype }? # or prefixes.datatype ?
 & attribute xsl:inherit-namespaces { boolean.datatype }?
 & attribute xsl:on-empty { expression.datatype }?
 & attribute xsl:use-attribute-sets { eqnames.datatype }?
 & attribute xsl:use-when { expression.datatype }?
 & attribute xsl:xpath-default-namespace { xsd:anyURI }?
 & attribute xsl:schema-role { ncname.datatype }?
 & (attribute xsl:type { eqname.datatype }
    | attribute xsl:validation { "strict" | "lax" | "preserve" | "strip" })?


top-level-extension =
  element * - (xsl:* | local:*) {
     anyElement
  }

anyElement =
   grammar {
      start = any
      any =
        (attribute * { text }
         | text
         | element * { any })*
    }
    
extension.atts = attribute * - (xsl:* | local:*) { text }*

declarations.model = (declaration.category | top-level-extension)*

# [Definition: There are a number of standard attributes that may appear on any XSLT element: specifically 
# default-collation, 
# default-mode, 
# default-validation, 
# exclude-result-prefixes, 
# expand-text, 
# extension-element-prefixes, 
# use-when, 
# version, 
# and xpath-default-namespace.]

global.atts = 
   attribute default-collation { uris.datatype }?,
   attribute _default-collation { avt.datatype }?,
   attribute default-mode { eqname.datatype | '#unnamed' }?,
   attribute _default-mode { avt.datatype }?,
   attribute default-validation  { "preserve" | "strip" }?,
   attribute _default-validation { avt.datatype }?,   
   attribute exclude-result-prefixes { exclude.prefixes.datatype }?,
   attribute _exclude-result-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute expand-text { boolean.datatype }?,
   attribute _expand-text { avt.datatype }?,
   attribute extension-element-prefixes { extension.prefixes.datatype }?,
   attribute _extension-element-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute use-when { expression.datatype }?,
   attribute _use-when { avt.datatype }?,
   attribute version { decimal.datatype }?,
   attribute _version { avt.datatype }?,
   attribute xpath-default-namespace { uri.datatype }?,
   attribute _xpath-default-namespace { avt.datatype }?
   

global.atts.except.version = 
   attribute default-collation { uris.datatype }?,
   attribute _default-collation { avt.datatype }?,
   attribute exclude-result-prefixes { exclude.prefixes.datatype }?,
   attribute _exclude-result-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute expand-text { boolean.datatype }?,
   attribute _expand-text { avt.datatype }?,
   attribute extension-element-prefixes { extension.prefixes.datatype }?,
   attribute _extension-element-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute use-when { expression.datatype }?,
   attribute _use-when { avt.datatype }?,
   attribute xpath-default-namespace { uri.datatype }?,
   attribute _xpath-default-namespace { avt.datatype }?
   
# In XSLT 4.0, prefixes can be defined with the fixed-namespaces attribute
# on the xsl:stylesheet, so we can't rely on XML declarations for QNames.
qname.strict = xsd:token { pattern = "[\i-[:]][\c-[:]]*:[\i-[:]][\c-[:]]*" }
qname.datatype = xsd:NCName | qname.strict

# Extract from XPath 3.0
#[94]   EQName           ::= QName | URIQualifiedName
#[104]  QName            ::= [http://www.w3.org/TR/REC-xml-names/#NT-QName]Names
#[105]  NCName           ::= [http://www.w3.org/TR/REC-xml-names/#NT-NCName]Names
#[99]   URIQualifiedName ::= BracedURILiteral NCName
#[100]  BracedURILiteral ::= "Q" "{" [^{}]* "}"

uri.qualified.name = xsd:token { pattern = "Q\{[^\{\}]*\}[\i-[:]][\c-[:]]*" } 
eqname.datatype = qname.datatype | uri.qualified.name
qnames.datatype = list { qname.datatype* }
eqnames.datatype = list { eqname.datatype* }
ncname.datatype = xsd:NCName
prefix.datatype = xsd:NCName
boolean.datatype = "yes" | "no" | "true" | "false" | "0" | "1" 
expression.datatype = text
char.datatype = xsd:string { length = "1" }
string.datatype = text
id.datatype = xsd:NCName
tokens.datatype = list { token* }
prefixes.datatype = list { token* }
extension.prefixes.datatype = list { xsd:NCName* }
exclude.prefixes.datatype = list { "#all" | (xsd:NCName | "#default")* }
token.datatype = token
language.datatype = xsd:language
nmtoken.datatype = xsd:NMTOKEN
decimal.datatype = xsd:decimal
integer.datatype = xsd:integer
uri.datatype = xsd:anyURI
uris.datatype = list { xsd:anyURI* }
pattern.datatype = text
qname-but-not-ncname.datatype = xsd:QName { pattern = ".*:.*" }
xs_schema.element = element xs:schema { anyElement* }
item-type.datatype = text
sequence-type.datatype = text

# #standard or NCName or prefix=URI or URI
fixed-namespaces.datatype = xsd:string

select-or-sequence-constructor.model =
  ((attribute select { expression.datatype }
    | attribute _select { avt.datatype })+
   | sequence-constructor.model)

declaration.category =
   use-package.element
 | include.element
 | import.element
 | import-schema.element
 | strip-space.element
 | preserve-space.element
 | decimal-format.element
 | template.element
 | mode.element
 | global-context-item.element
 | variable.element
 | param.element
 | attribute-set.element
 | function.element
 | namespace-alias.element
 | accumulator.element
 | key.element
 | output.element
 | character-map.element

instruction.category =
   apply-templates.element
 | apply-imports.element
 | next-match.element
 | for-each.element
 | iterate.element
 | next-iteration.element
 | break.element
 | if.element
 | choose.element
 | switch.element
 | try.element
 | variable.element
 | call-template.element
 | evaluate.element
 | element.element
 | attribute.element
 | text.element
 | value-of.element
 | document.element
 | processing-instruction.element
 | namespace.element
 | comment.element
 | copy.element
 | copy-of.element
 | sequence.element
 | where-populated.element
 | on-empty.element
 | on-non-empty.element
 | number.element
 | perform-sort.element
 | for-each-group.element
 | merge.element
 | fork.element
 | analyze-string.element
 | source-document.element
 | map.element
 | map-entry.element
 | array.element
 | array-member.element
 | message.element
 | assert.element
 | fallback.element
 | result-document.element
 | select.element
package.element =
   element package {
      extension.atts,
      attribute id { id.datatype }?,
      attribute _id { avt.datatype }?,
      attribute name { uri.datatype }?,
      attribute _name { avt.datatype }?,
      attribute package-version { string.datatype }?,
      attribute _package-version { avt.datatype }?,
      attribute version { decimal.datatype }?,
      attribute _version { avt.datatype }?,
      attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
      attribute _input-type-annotations { avt.datatype }?,
      attribute declared-modes { boolean.datatype }?,
      attribute _declared-modes { avt.datatype }?,
      attribute default-mode { eqname.datatype | "#unnamed" }?,
      attribute _default-mode { avt.datatype }?,
      attribute default-validation { "preserve" | "strip" }?,
      attribute _default-validation { avt.datatype }?,
      attribute default-collation { uris.datatype }?,
      attribute _default-collation { avt.datatype }?,
      attribute extension-element-prefixes { prefixes.datatype }?,
      attribute _extension-element-prefixes { avt.datatype }?,
      attribute exclude-result-prefixes { prefixes.datatype }?,
      attribute _exclude-result-prefixes { avt.datatype }?,
      attribute expand-text { boolean.datatype }?,
      attribute _expand-text { avt.datatype }?,
      attribute use-when { expression.datatype }?,
      attribute _use-when { avt.datatype }?,
      attribute xpath-default-namespace { uri.datatype }?,
      attribute _xpath-default-namespace { avt.datatype }?,
      attribute fixed-namespaces { fixed-namespaces.datatype }?,
      attribute _fixed-namespaces { fixed-namespaces.datatype }?,
      ((expose.element | declarations.model)*)
   }
use-package.element =
   element use-package {
      extension.atts,
      global.atts,
      attribute name { uri.datatype }?,
      attribute _name { avt.datatype }?,
      attribute package-version { string.datatype }?,
      attribute _package-version { avt.datatype }?,
      (accept.element | override.element)*
   }
expose.element =
   element expose {
      extension.atts,
      global.atts,
      attribute component { "template" | "function" | "attribute-set" | "variable" | "mode" | "*" }?,
      attribute _component { avt.datatype }?,
      attribute names { tokens.datatype }?,
      attribute _names { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      empty
   }
accept.element =
   element accept {
      extension.atts,
      global.atts,
      (attribute component { "template" | "function" | "attribute-set" | "variable" | "mode" | "*" } |
      attribute _component { avt.datatype })+,
      (attribute names { tokens.datatype } |
      attribute _names { avt.datatype })+,
      (attribute visibility { "public" | "private" | "final" | "abstract" | "hidden" } |
      attribute _visibility { avt.datatype })+,
      empty
   }
override.element =
   element override {
      extension.atts,
      global.atts,
      (template.element | function.element | variable.element | param.element | attribute-set.element)*
   }
stylesheet.element =
   element stylesheet {
      extension.atts,
      attribute id { id.datatype }?,
      attribute _id { avt.datatype }?,
      attribute version { decimal.datatype }?,
      attribute _version { avt.datatype }?,
      attribute default-mode { eqname.datatype | "#unnamed" }?,
      attribute _default-mode { avt.datatype }?,
      attribute default-validation { "preserve" | "strip" }?,
      attribute _default-validation { avt.datatype }?,
      attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
      attribute _input-type-annotations { avt.datatype }?,
      attribute default-collation { uris.datatype }?,
      attribute _default-collation { avt.datatype }?,
      attribute extension-element-prefixes { prefixes.datatype }?,
      attribute _extension-element-prefixes { avt.datatype }?,
      attribute exclude-result-prefixes { prefixes.datatype }?,
      attribute _exclude-result-prefixes { avt.datatype }?,
      attribute expand-text { boolean.datatype }?,
      attribute _expand-text { avt.datatype }?,
      attribute use-when { expression.datatype }?,
      attribute _use-when { avt.datatype }?,
      attribute xpath-default-namespace { uri.datatype }?,
      attribute _xpath-default-namespace { avt.datatype }?,
      attribute fixed-namespaces { fixed-namespaces.datatype }?,
      attribute _fixed-namespaces { fixed-namespaces.datatype }?,
      (declarations.model)
   }
transform.element =
   element transform {
      extension.atts,
      attribute id { id.datatype }?,
      attribute _id { avt.datatype }?,
      attribute version { decimal.datatype }?,
      attribute _version { avt.datatype }?,
      attribute default-mode { eqname.datatype | "#unnamed" }?,
      attribute _default-mode { avt.datatype }?,
      attribute default-validation { "preserve" | "strip" }?,
      attribute _default-validation { avt.datatype }?,
      attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
      attribute _input-type-annotations { avt.datatype }?,
      attribute default-collation { uris.datatype }?,
      attribute _default-collation { avt.datatype }?,
      attribute extension-element-prefixes { prefixes.datatype }?,
      attribute _extension-element-prefixes { avt.datatype }?,
      attribute exclude-result-prefixes { prefixes.datatype }?,
      attribute _exclude-result-prefixes { avt.datatype }?,
      attribute expand-text { boolean.datatype }?,
      attribute _expand-text { avt.datatype }?,
      attribute use-when { expression.datatype }?,
      attribute _use-when { avt.datatype }?,
      attribute xpath-default-namespace { uri.datatype }?,
      attribute _xpath-default-namespace { avt.datatype }?,
      attribute fixed-namespaces { fixed-namespaces.datatype }?,
      attribute _fixed-namespaces { fixed-namespaces.datatype }?,
      (declarations.model)
   }
include.element =
   element include {
      extension.atts,
      global.atts,
      attribute href { uri.datatype }?,
      attribute _href { avt.datatype }?,
      empty
   }
import.element =
   element import {
      extension.atts,
      global.atts,
      (attribute href { uri.datatype }
      | attribute _href { avt.datatype })+,
      empty
   }
import-schema.element =
   element import-schema {
      extension.atts,
      global.atts,
      attribute namespace { uri.datatype }?,
      attribute _namespace { avt.datatype }?,
      attribute schema-location { uri.datatype }?,
      attribute _schema-location { avt.datatype }?,
      xs_schema.element?
   }
strip-space.element =
   element strip-space {
      extension.atts,
      global.atts,
      (attribute elements { tokens.datatype }
      | attribute _elements { avt.datatype })+,
      empty
   }
preserve-space.element =
   element preserve-space {
      extension.atts,
      global.atts,
      (attribute elements { tokens.datatype }
      | attribute _elements { avt.datatype })+,
      empty
   }
decimal-format.element =
   element decimal-format {
      extension.atts,
      global.atts,
      attribute name { eqname.datatype }?,
      attribute _name { avt.datatype }?,
      attribute decimal-separator { char.datatype }?,
      attribute _decimal-separator { avt.datatype }?,
      attribute grouping-separator { char.datatype }?,
      attribute _grouping-separator { avt.datatype }?,
      attribute infinity { string.datatype }?,
      attribute _infinity { avt.datatype }?,
      attribute minus-sign { char.datatype }?,
      attribute _minus-sign { avt.datatype }?,
      attribute exponent-separator { char.datatype }?,
      attribute _exponent-separator { avt.datatype }?,
      attribute NaN { string.datatype }?,
      attribute _NaN { avt.datatype }?,
      attribute percent { char.datatype }?,
      attribute _percent { avt.datatype }?,
      attribute per-mille { char.datatype }?,
      attribute _per-mille { avt.datatype }?,
      attribute zero-digit { char.datatype }?,
      attribute _zero-digit { avt.datatype }?,
      attribute digit { char.datatype }?,
      attribute _digit { avt.datatype }?,
      attribute pattern-separator { char.datatype }?,
      attribute _pattern-separator { avt.datatype }?,
      empty
   }
template.element =
   element template {
      extension.atts,
      global.atts,
      (attribute match { pattern.datatype }
      | attribute _match { avt.datatype }
      | attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute priority { decimal.datatype }?,
      attribute _priority { avt.datatype }?,
      attribute mode { list { '#all' | ('#default' | '#unnamed' | eqname.datatype)* } }?,
      attribute _mode { avt.datatype }?,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      (context-item.element?, param.element*, sequence-constructor.model)
   }
apply-templates.element =
   element apply-templates {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute mode { (eqname.datatype | '#unnamed' | '#default' | '#current') }?,
      attribute _mode { avt.datatype }?,
      attribute separator { avt.datatype }?,
      attribute _separator { avt.datatype }?,
      (sort.element | with-param.element)*
   }
mode.element =
   element mode {
      extension.atts,
      global.atts,
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute copy-namespaces { boolean.datatype }?
      | attribute _copy-namespaces { boolean.datatype }?),
      (attribute name { eqname.datatype }?
      | attribute _name { avt.datatype }?),
      (attribute streamable { boolean.datatype }?
      | attribute _streamable { avt.datatype }?),
      (attribute on-no-match { "deep-copy" | "shallow-copy" | "shallow-copy-all" | "deep-skip" | "shallow-skip" | "text-only-copy" | "fail" }?
      | attribute _on-no-match { avt.datatype }?),
      (attribute on-multiple-match { "use-last" | "fail" }?
      | attribute _on-multiple-match { avt.datatype }?),
      (attribute warning-on-no-match { boolean.datatype }?
      | attribute _warning-on-no-match { avt.datatype }?),
      (attribute warning-on-multiple-match { boolean.datatype }?
      | attribute _warning-on-multiple-match { avt.datatype }?),
      (attribute typed { boolean.datatype | "strict" | "lax" | "unspecified" }?
      | attribute _typed { avt.datatype }?),
      (attribute visibility { "public" | "private" | "final" }?
      | attribute _visibility { avt.datatype }?),
      (attribute use-accumulators { tokens.datatype }?
      | attribute _use-accumulators { avt.datatype }?),
      empty
   }
context-item.element =
   element context-item {
      extension.atts,
      global.atts,
      attribute as { item-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute use { "required" | "optional" | "absent" }?,
      attribute _use { avt.datatype }?,
      empty
   }
global-context-item.element =
   element global-context-item {
      extension.atts,
      global.atts,
      attribute as { item-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute use { "required" | "optional" | "absent" }?,
      attribute _use { avt.datatype }?,
      empty
   }
apply-imports.element =
   element apply-imports {
      extension.atts,
      global.atts,
      with-param.element*
   }
next-match.element =
   element next-match {
      extension.atts,
      global.atts,
      (with-param.element | fallback.element)*
   }
for-each.element =
   element for-each {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      (sort.element*, sequence-constructor.model)
   }
iterate.element =
   element iterate {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      (param.element*, on-completion.element?, sequence-constructor.model)
   }
next-iteration.element =
   element next-iteration {
      extension.atts,
      global.atts,
      (with-param.element*)
   }
break.element =
   element break {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })?,
      sequence-constructor.model
   }
on-completion.element =
   element on-completion {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      sequence-constructor.model
   }
if.element =
   element if {
      extension.atts,
      global.atts,
      (attribute test { expression.datatype }
      | attribute _test { avt.datatype })+,
      sequence-constructor.model
   }
choose.element =
   element choose {
      extension.atts,
      global.atts,
      (when.element+, otherwise.element?)
   }
when.element =
   element when {
      extension.atts,
      global.atts,
      (attribute test { expression.datatype }
      | attribute _test { avt.datatype })+,
      select-or-sequence-constructor.model
   }
otherwise.element =
   element otherwise {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }

switch.element =
  element switch {
    extension.atts,
    global.atts,
    (attribute select { expression.datatype }
    | attribute _select { avt.datatype })+,
    (when.element+, otherwise.element?, fallback.element*)
  }

try.element =
   element try {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute rollback-output { boolean.datatype }?,
      attribute _rollback-output { avt.datatype }?,
      (sequence-constructor.model, catch.element, (catch.element | fallback.element)*)
   }
catch.element =
   element catch {
      extension.atts,
      global.atts,
      attribute errors { tokens.datatype }?,
      attribute _errors { avt.datatype }?,
      select-or-sequence-constructor.model
   }
variable.element =
   element variable {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute static { boolean.datatype }?,
      attribute _static { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      select-or-sequence-constructor.model
   }
param.element =
   element param {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute required { boolean.datatype }?,
      attribute _required { avt.datatype }?,
      attribute tunnel { boolean.datatype }?,
      attribute _tunnel { avt.datatype }?,
      attribute static { boolean.datatype }?,
      attribute _static { avt.datatype }?,
      select-or-sequence-constructor.model
   }
with-param.element =
   element with-param {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute tunnel { boolean.datatype }?,
      attribute _tunnel { avt.datatype }?,
      select-or-sequence-constructor.model
   }
call-template.element =
   element call-template {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      with-param.element*
   }
attribute-set.element =
   element attribute-set {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute use-attribute-sets { eqnames.datatype }?,
      attribute _use-attribute-sets { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      attribute.element*
   }
function.element =
   element function {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute visibility { "public" | "private" | "final" | "abstract" }?
      | attribute _visibility { avt.datatype }?),
      (attribute streamability { "unclassified" | "absorbing" | "inspection" | "filter" | "shallow-descent" | "deep-descent" | "ascent" | eqname.datatype }?
      | attribute _streamability { avt.datatype }?),
      (attribute override-extension-function { boolean.datatype }?
      | attribute _override-extension-function { avt.datatype }?),
      (attribute override { boolean.datatype }?
      | attribute _override { avt.datatype }?),
      (attribute new-each-time { "yes" | "true" | "1" | "no" | "false" | "0" | "maybe" }?
      | attribute _new-each-time { avt.datatype }?),
      (attribute cache { boolean.datatype }?
      | attribute _cache { avt.datatype }?),
      (param.element*, sequence-constructor.model)
   }
evaluate.element =
   element evaluate {
      extension.atts,
      global.atts,
      (attribute xpath { expression.datatype }
      | attribute _xpath { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute base-uri { uri.datatype | avt.datatype }?,
      attribute _base-uri { avt.datatype }?,
      attribute with-params { expression.datatype }?,
      attribute _with-params { avt.datatype }?,
      attribute context-item { expression.datatype }?,
      attribute _context-item { avt.datatype }?,
      attribute namespace-context { expression.datatype }?,
      attribute _namespace-context { avt.datatype }?,
      attribute schema-aware { boolean.datatype | avt.datatype }?,
      attribute _schema-aware { avt.datatype }?,
      (with-param.element | fallback.element)*
   }
namespace-alias.element =
   element namespace-alias {
      extension.atts,
      global.atts,
      (attribute stylesheet-prefix { prefix.datatype | "#default" }
      | attribute _stylesheet-prefix { avt.datatype })+,
      (attribute result-prefix { prefix.datatype | "#default" }
      | attribute _result-prefix { avt.datatype })+,
      empty
   }
element.element =
   element element {
      extension.atts,
      global.atts,
      (attribute name { qname.datatype | avt.datatype }
      | attribute _name { avt.datatype })+,
      attribute namespace { uri.datatype | avt.datatype }?,
      attribute _namespace { avt.datatype }?,
      attribute inherit-namespaces { boolean.datatype }?,
      attribute _inherit-namespaces { avt.datatype }?,
      attribute use-attribute-sets { eqnames.datatype }?,
      attribute _use-attribute-sets { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      sequence-constructor.model
   }
attribute.element =
   element attribute {
      extension.atts,
      global.atts,
      (attribute name { qname.datatype | avt.datatype }
      | attribute _name { avt.datatype })+,
      attribute namespace { uri.datatype | avt.datatype }?,
      attribute _namespace { avt.datatype }?,
      attribute separator { string.datatype | avt.datatype }?,
      attribute _separator { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      select-or-sequence-constructor.model
   }
text.element =
   element text {
      extension.atts,
      global.atts,
      attribute disable-output-escaping { boolean.datatype }?,
      attribute _disable-output-escaping { avt.datatype }?,
      text
   }
value-of.element =
   element value-of {
      extension.atts,
      global.atts,
      attribute separator { string.datatype | avt.datatype }?,
      attribute _separator { avt.datatype }?,
      attribute disable-output-escaping { boolean.datatype }?,
      attribute _disable-output-escaping { avt.datatype }?,
      select-or-sequence-constructor.model
   }
document.element =
   element document {
      extension.atts,
      global.atts,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      sequence-constructor.model
   }
processing-instruction.element =
   element processing-instruction {
      extension.atts,
      global.atts,
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype }),
      select-or-sequence-constructor.model
   }
record.element = 
   element record {
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute duplicates { expression.datatype }?
      | attribute _duplicates { avt.datatype }?),
      sequence-constructor.model
  }
record-type.element = 
   element record-type {
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype }),
      (attribute extensible { boolean.datatype }?
      | attribute _extensible { avt.datatype }?),
      (attribute visibility { "public" | "private" | "final" | "abstract" | "hidden" }?
      | attribute _visibility { avt.datatype }?),
      field.element*
  }
field.element = 
   element field {
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype }),
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute required { boolean.datatype }?
      | attribute _required { avt.datatype }?),
      (attribute \default { expression.datatype }?
      |attribute _default { expression.datatype }?),
      empty
  }

select.element = 
   element select {
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (fallback.element | text)*
  }
namespace.element =
   element namespace {
      extension.atts,
      global.atts,
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype })+,
      select-or-sequence-constructor.model
   }
comment.element =
   element comment {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
copy.element =
   element copy {
      extension.atts,
      global.atts,
      attribute copy-namespaces { boolean.datatype }?,
      attribute _copy-namespaces { avt.datatype }?,
      attribute inherit-namespaces { boolean.datatype }?,
      attribute _inherit-namespaces { avt.datatype }?,
      attribute use-attribute-sets { eqnames.datatype }?,
      attribute _use-attribute-sets { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      sequence-constructor.model
   }
copy-of.element =
   element copy-of {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      attribute copy-accumulators { boolean.datatype }?,
      attribute _copy-accumulators { avt.datatype }?,
      attribute copy-namespaces { boolean.datatype }?,
      attribute _copy-namespaces { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      empty
   }
sequence.element =
   element sequence {
      extension.atts,
      global.atts,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      select-or-sequence-constructor.model
   }
where-populated.element =
   element where-populated {
      extension.atts,
      global.atts,
      sequence-constructor.model
   }
on-empty.element =
   element on-empty {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
on-non-empty.element =
   element on-non-empty {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
number.element =
   element number {
      extension.atts,
      global.atts,
      attribute value { expression.datatype }?,
      attribute _value { avt.datatype }?,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute level { "single" | "multiple" | "any" }?,
      attribute _level { avt.datatype }?,
      attribute count { pattern.datatype }?,
      attribute _count { avt.datatype }?,
      attribute from { pattern.datatype }?,
      attribute _from { avt.datatype }?,
      attribute format { string.datatype | avt.datatype }?,
      attribute _format { avt.datatype }?,
      attribute lang { language.datatype | avt.datatype }?,
      attribute _lang { avt.datatype }?,
      attribute letter-value { "alphabetic" | "traditional" | avt.datatype }?,
      attribute _letter-value { avt.datatype }?,
      attribute ordinal { string.datatype | avt.datatype }?,
      attribute _ordinal { avt.datatype }?,
      attribute start-at { integer.datatype | avt.datatype }?,
      attribute _start-at { avt.datatype }?,
      attribute grouping-separator { char.datatype | avt.datatype }?,
      attribute _grouping-separator { avt.datatype }?,
      attribute grouping-size { integer.datatype | avt.datatype }?,
      attribute _grouping-size { avt.datatype }?,
      empty
   }
sort.element =
   element sort {
      extension.atts,
      global.atts,
      attribute lang { language.datatype | avt.datatype }?,
      attribute _lang { avt.datatype }?,
      attribute order { "ascending" | "descending" | avt.datatype }?,
      attribute _order { avt.datatype }?,
      attribute collation { uri.datatype | avt.datatype }?,
      attribute _collation { avt.datatype }?,
      attribute stable { boolean.datatype | avt.datatype }?,
      attribute _stable { avt.datatype }?,
      attribute case-order { "upper-first" | "lower-first" | avt.datatype }?,
      attribute _case-order { avt.datatype }?,
      attribute data-type { "text" | "number" | eqname.datatype | avt.datatype }?,
      attribute _data-type { avt.datatype }?,
      select-or-sequence-constructor.model
   }
perform-sort.element =
   element perform-sort {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      (sort.element+, sequence-constructor.model)
   }
for-each-group.element =
   element for-each-group {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      ((attribute group-by { expression.datatype }?,
      attribute _group-by { avt.datatype }?) |
      (attribute group-adjacent { expression.datatype }?,
      attribute _group-adjacent { avt.datatype }?) |
      (attribute group-starting-with { pattern.datatype }?,
      attribute _group-starting-with { avt.datatype }?) |
      (attribute group-ending-with { pattern.datatype }?,
      attribute _group-ending-with { avt.datatype }?)),
      attribute composite { boolean.datatype }?,
      attribute _composite { avt.datatype }?,
      attribute collation { uri.datatype | avt.datatype }?,
      attribute _collation { avt.datatype }?,
      (sort.element*, sequence-constructor.model)
   }
merge.element =
   element merge {
      extension.atts,
      global.atts,
      (merge-source.element+, merge-action.element, fallback.element*)
   }
merge-source.element =
   element merge-source {
      extension.atts,
      global.atts,
      attribute name { ncname.datatype }?,
      attribute _name { avt.datatype }?,
      attribute for-each-item { expression.datatype }?,
      attribute _for-each-item { avt.datatype }?,
      attribute for-each-stream { expression.datatype }?,
      attribute _for-each-stream { avt.datatype }?,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      attribute use-accumulators { tokens.datatype }?,
      attribute _use-accumulators { avt.datatype }?,
      attribute sort-before-merge { boolean.datatype }?,
      attribute _sort-before-merge { avt.datatype }?,
      attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }?,
      attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?,
      attribute for-each-source { expression.datatype }?,
      attribute _for-each-source { avt.datatype }?,
      merge-key.element+
   }
merge-key.element =
   element merge-key {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute lang { language.datatype | avt.datatype }?,
      attribute _lang { avt.datatype }?,
      attribute order { "ascending" | "descending" | avt.datatype }?,
      attribute _order { avt.datatype }?,
      attribute collation { uri.datatype | avt.datatype }?,
      attribute _collation { avt.datatype }?,
      attribute case-order { "upper-first" | "lower-first" | avt.datatype }?,
      attribute _case-order { avt.datatype }?,
      attribute data-type { "text" | "number" | eqname.datatype | avt.datatype }?,
      attribute _data-type { avt.datatype }?,
      sequence-constructor.model
   }
merge-action.element =
   element merge-action {
      extension.atts,
      global.atts,
      sequence-constructor.model
   }
fork.element =
   element fork {
      extension.atts,
      global.atts,
      (fallback.element*, ((sequence.element, fallback.element*)* | (for-each-group.element, fallback.element*)))
   }
analyze-string.element =
   element analyze-string {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      (attribute regex { string.datatype | avt.datatype }
      | attribute _regex { avt.datatype })+,
      attribute flags { string.datatype | avt.datatype }?,
      attribute _flags { avt.datatype }?,
      (matching-substring.element?, non-matching-substring.element?, fallback.element*)
   }
matching-substring.element =
   element matching-substring {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
non-matching-substring.element =
   element non-matching-substring {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
source-document.element =
   element source-document {
      extension.atts,
      global.atts,
      (attribute href { uri.datatype | avt.datatype }
      | attribute _href { avt.datatype })+,
      attribute use-accumulators { tokens.datatype }?,
      attribute _use-accumulators { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      sequence-constructor.model
   }
accumulator.element =
   element accumulator {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype }),
      (attribute initial-value { expression.datatype }
      | attribute _initial-value { avt.datatype }),
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      accumulator-rule.element+
   }
accumulator-rule.element =
   element accumulator-rule {
      extension.atts,
      global.atts,
      (attribute match { pattern.datatype } |
      attribute _match { avt.datatype })+,
      attribute phase { "start" | "end" }?,
      attribute _phase { avt.datatype }?,
      select-or-sequence-constructor.model
   }
key.element =
   element key {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      (attribute match { pattern.datatype }
      | attribute _match { avt.datatype })+,
      attribute use { expression.datatype }?,
      attribute _use { avt.datatype }?,
      attribute composite { boolean.datatype }?,
      attribute _composite { avt.datatype }?,
      attribute collation { uri.datatype }?,
      attribute _collation { avt.datatype }?,
      sequence-constructor.model
   }
map.element =
   element map {
      (attribute duplicates { expression.datatype }?
      | attribute _duplicates { avt.datatype }?),
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }

map-entry.element =
   element map-entry {
      extension.atts,
      global.atts,
      (attribute key { expression.datatype }
      | attribute _key { avt.datatype }),
      select-or-sequence-constructor.model
   }

array.element =
  element array {
    (attribute for-each { expression.datatype }
     | attribute _for-each { expression.datatype }),
    extension.atts,
    global.atts,
    select-or-sequence-constructor.model
  }

array-member.element =
  element array-member {
    extension.atts,
    global.atts,
    select-or-sequence-constructor.model
  }

message.element =
   element message {
      extension.atts,
      global.atts,
      attribute terminate { boolean.datatype | avt.datatype }?,
      attribute _terminate { avt.datatype }?,
      attribute error-code { eqname.datatype | avt.datatype }?,
      attribute _error-code { avt.datatype }?,
      select-or-sequence-constructor.model
   }
assert.element =
   element assert {
      extension.atts,
      global.atts,
      (attribute test { expression.datatype }
      | attribute _test { avt.datatype })+,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute error-code { eqname.datatype | avt.datatype }?,
      attribute _error-code { avt.datatype }?,
      sequence-constructor.model
   }
fallback.element =
   element fallback {
      extension.atts,
      global.atts,
      sequence-constructor.model
   }
result-document.element =
   element result-document {
      extension.atts,
      global.atts,
      attribute format { eqname.datatype | avt.datatype }?,
      attribute _format { avt.datatype }?,
      attribute href { uri.datatype | avt.datatype }?,
      attribute _href { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive      
      attribute method { "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname.datatype | avt.datatype }?,
      attribute _method { avt.datatype }?,
      attribute allow-duplicate-names { boolean.datatype | avt.datatype }?,
      attribute _allow-duplicate-names { avt.datatype }?,
      attribute build-tree { boolean.datatype | avt.datatype }?,
      attribute _build-tree { avt.datatype }?,
      attribute byte-order-mark { boolean.datatype | avt.datatype }?,
      attribute _byte-order-mark { avt.datatype }?,
      attribute cdata-section-elements { eqnames.datatype | avt.datatype }?,
      attribute _cdata-section-elements { avt.datatype }?,
      attribute doctype-public { string.datatype | avt.datatype }?,
      attribute _doctype-public { avt.datatype }?,
      attribute doctype-system { string.datatype | avt.datatype }?,
      attribute _doctype-system { avt.datatype }?,
      attribute encoding { string.datatype | avt.datatype }?,
      attribute _encoding { avt.datatype }?,
      attribute escape-uri-attributes { boolean.datatype | avt.datatype }?,
      attribute _escape-uri-attributes { avt.datatype }?,
      attribute html-version { decimal.datatype | avt.datatype }?,
      attribute _html-version { avt.datatype }?,
      attribute include-content-type { boolean.datatype | avt.datatype }?,
      attribute _include-content-type { avt.datatype }?,
      attribute indent { boolean.datatype | avt.datatype }?,
      attribute _indent { avt.datatype }?,
      attribute item-separator { string.datatype | avt.datatype }?,
      attribute _item-separator { avt.datatype }?,
      attribute json-node-output-method { "xml" | "html" | "xhtml" | "text" | eqname.datatype | avt.datatype }?,
      attribute _json-node-output-method { avt.datatype }?,
      attribute media-type { string.datatype | avt.datatype }?,
      attribute _media-type { avt.datatype }?,
      attribute normalization-form { "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken.datatype | avt.datatype }?,
      attribute _normalization-form { avt.datatype }?,
      attribute omit-xml-declaration { boolean.datatype | avt.datatype }?,
      attribute _omit-xml-declaration { avt.datatype }?,
      attribute parameter-document { uri.datatype | avt.datatype }?,
      attribute _parameter-document { avt.datatype }?,
      attribute standalone { boolean.datatype | "omit" | avt.datatype }?,
      attribute _standalone { avt.datatype }?,
      attribute suppress-indentation { eqnames.datatype | avt.datatype }?,
      attribute _suppress-indentation { avt.datatype }?,
      attribute undeclare-prefixes { boolean.datatype | avt.datatype }?,
      attribute _undeclare-prefixes { avt.datatype }?,
      attribute use-character-maps { eqnames.datatype }?,
      attribute _use-character-maps { avt.datatype }?,
      attribute output-version { nmtoken.datatype | avt.datatype }?,
      attribute _output-version { avt.datatype }?,
      sequence-constructor.model
   }
output.element =
   element output {
      extension.atts,
      global.atts.except.version,
      attribute name { eqname.datatype }?,
      attribute _name { avt.datatype }?,
      attribute method { "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname.datatype }?,
      attribute _method { avt.datatype }?,
      attribute allow-duplicate-names { boolean.datatype }?,
      attribute _allow-duplicate-names { avt.datatype }?,
      attribute build-tree { boolean.datatype }?,
      attribute _build-tree { avt.datatype }?,
      attribute byte-order-mark { boolean.datatype }?,
      attribute _byte-order-mark { avt.datatype }?,
      attribute cdata-section-elements { eqnames.datatype }?,
      attribute _cdata-section-elements { avt.datatype }?,
      attribute doctype-public { string.datatype }?,
      attribute _doctype-public { avt.datatype }?,
      attribute doctype-system { string.datatype }?,
      attribute _doctype-system { avt.datatype }?,
      attribute encoding { string.datatype }?,
      attribute _encoding { avt.datatype }?,
      attribute escape-uri-attributes { boolean.datatype }?,
      attribute _escape-uri-attributes { avt.datatype }?,
      attribute html-version { decimal.datatype }?,
      attribute _html-version { avt.datatype }?,
      attribute include-content-type { boolean.datatype }?,
      attribute _include-content-type { avt.datatype }?,
      attribute indent { boolean.datatype }?,
      attribute _indent { avt.datatype }?,
      attribute item-separator { string.datatype }?,
      attribute _item-separator { avt.datatype }?,
      attribute json-node-output-method { "xml" | "html" | "xhtml" | "text" | eqname.datatype }?,
      attribute _json-node-output-method { avt.datatype }?,
      attribute media-type { string.datatype }?,
      attribute _media-type { avt.datatype }?,
      attribute normalization-form { "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken.datatype }?,
      attribute _normalization-form { avt.datatype }?,
      attribute omit-xml-declaration { boolean.datatype }?,
      attribute _omit-xml-declaration { avt.datatype }?,
      attribute parameter-document { uri.datatype }?,
      attribute _parameter-document { avt.datatype }?,
      attribute standalone { boolean.datatype | "omit" }?,
      attribute _standalone { avt.datatype }?,
      attribute suppress-indentation { eqnames.datatype }?,
      attribute _suppress-indentation { avt.datatype }?,
      attribute undeclare-prefixes { boolean.datatype }?,
      attribute _undeclare-prefixes { avt.datatype }?,
      attribute use-character-maps { eqnames.datatype }?,
      attribute _use-character-maps { avt.datatype }?,
      attribute version { nmtoken.datatype }?,
      attribute _version { avt.datatype }?,
      empty
   }
character-map.element =
   element character-map {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute use-character-maps { eqnames.datatype }?,
      attribute _use-character-maps { avt.datatype }?,
      (output-character.element*)
   }
output-character.element =
   element output-character {
      extension.atts,
      global.atts,
      (attribute character { char.datatype }
      | attribute _character { avt.datatype })+,
      (attribute string { string.datatype }
      | attribute _string { avt.datatype })+,
      empty
   }
avt.datatype =
  xsd:string
# {
#    pattern =
#      """([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*""" # this regexp will not work in all the case.
#      }
# XSLT 4.0 Relax NG Schema
# 
# Copyright (c) 2010-2016, Mohamed ZERGAOUI (Innovimax)
# Portions © 2024, XQuery and XSLT Extensions Community Group
# 
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer. Redistributions in binary
# form must reproduce the above copyright notice, this list of conditions and
# the following disclaimer in the documentation and/or other materials provided
# with the distribution. Neither the name of the Mohamed ZERGAOUI or Innovimax
# nor the names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
namespace local = ""
default namespace xsl = "http://www.w3.org/1999/XSL/Transform"
namespace xs = "http://www.w3.org/2001/XMLSchema"

start =
  stylesheet.element
  | transform.element
  | package.element  
  | literal-result-element-as-stylesheet
  
sequence-constructor.model = (instruction.category | record.element | literal-result-element | text)*

literal-result-element-as-stylesheet =
  element * - xsl:* {
    attribute xsl:version { decimal.datatype },
    literal-result-element-no-version.atts,
    sequence-constructor.model
  }

literal-result-element =
  element * - xsl:* {
     literal-result-element.atts,
     sequence-constructor.model
  }

literal-result-element.atts =
  literal-result-element-no-version.atts,
  attribute xsl:version { text }?

# These attributes may also appear on a literal result element, but in this case, to distinguish them from user-defined attributes, 
# the names of the attributes are in the XSLT namespace. They are thus typically written as 
# xsl:default-collation,
# xsl:default-mode,
# xsl:default-validation,
# xsl:exclude-result-prefixes,
# xsl:expand-text,
# xsl:extension-element-prefixes,
# xsl:use-when,
# xsl:version,
# or xsl:xpath-default-namespace.
literal-result-element-no-version.atts =
   attribute * - xsl:* { avt.datatype }*
 & attribute xsl:default-collation { uris.datatype }?
 & attribute xsl:default-mode { eqname.datatype | '#unnamed' }?
 & attribute xsl:default-validation  { "preserve" | "strip" }?
 & attribute xsl:exclude-result-prefixes { exclude.prefixes.datatype }? # or prefixes.datatype ?
 & attribute xsl:expand-text { boolean.datatype }?
 & attribute xsl:extension-element-prefixes { extension.prefixes.datatype }? # or prefixes.datatype ?
 & attribute xsl:inherit-namespaces { boolean.datatype }?
 & attribute xsl:on-empty { expression.datatype }?
 & attribute xsl:use-attribute-sets { eqnames.datatype }?
 & attribute xsl:use-when { expression.datatype }?
 & attribute xsl:xpath-default-namespace { xsd:anyURI }?
 & attribute xsl:schema-role { ncname.datatype }?
 & (attribute xsl:type { eqname.datatype }
    | attribute xsl:validation { "strict" | "lax" | "preserve" | "strip" })?


top-level-extension =
  element * - (xsl:* | local:*) {
     anyElement
  }

anyElement =
   grammar {
      start = any
      any =
        (attribute * { text }
         | text
         | element * { any })*
    }
    
extension.atts = attribute * - (xsl:* | local:*) { text }*

declarations.model = (declaration.category | top-level-extension)*

# [Definition: There are a number of standard attributes that may appear on any XSLT element: specifically 
# default-collation, 
# default-mode, 
# default-validation, 
# exclude-result-prefixes, 
# expand-text, 
# extension-element-prefixes, 
# use-when, 
# version, 
# and xpath-default-namespace.]

global.atts = 
   attribute default-collation { uris.datatype }?,
   attribute _default-collation { avt.datatype }?,
   attribute default-mode { eqname.datatype | '#unnamed' }?,
   attribute _default-mode { avt.datatype }?,
   attribute default-validation  { "preserve" | "strip" }?,
   attribute _default-validation { avt.datatype }?,   
   attribute exclude-result-prefixes { exclude.prefixes.datatype }?,
   attribute _exclude-result-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute expand-text { boolean.datatype }?,
   attribute _expand-text { avt.datatype }?,
   attribute extension-element-prefixes { extension.prefixes.datatype }?,
   attribute _extension-element-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute use-when { expression.datatype }?,
   attribute _use-when { avt.datatype }?,
   attribute version { decimal.datatype }?,
   attribute _version { avt.datatype }?,
   attribute xpath-default-namespace { uri.datatype }?,
   attribute _xpath-default-namespace { avt.datatype }?
   

global.atts.except.version = 
   attribute default-collation { uris.datatype }?,
   attribute _default-collation { avt.datatype }?,
   attribute exclude-result-prefixes { exclude.prefixes.datatype }?,
   attribute _exclude-result-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute expand-text { boolean.datatype }?,
   attribute _expand-text { avt.datatype }?,
   attribute extension-element-prefixes { extension.prefixes.datatype }?,
   attribute _extension-element-prefixes { avt.datatype }?, # or prefixes.datatype ?
   attribute use-when { expression.datatype }?,
   attribute _use-when { avt.datatype }?,
   attribute xpath-default-namespace { uri.datatype }?,
   attribute _xpath-default-namespace { avt.datatype }?
   
# In XSLT 4.0, prefixes can be defined with the fixed-namespaces attribute
# on the xsl:stylesheet, so we can't rely on XML declarations for QNames.
qname.strict = xsd:token { pattern = "[\i-[:]][\c-[:]]*:[\i-[:]][\c-[:]]*" }
qname.datatype = xsd:NCName | qname.strict

# Extract from XPath 3.0
#[94]   EQName           ::= QName | URIQualifiedName
#[104]  QName            ::= [http://www.w3.org/TR/REC-xml-names/#NT-QName]Names
#[105]  NCName           ::= [http://www.w3.org/TR/REC-xml-names/#NT-NCName]Names
#[99]   URIQualifiedName ::= BracedURILiteral NCName
#[100]  BracedURILiteral ::= "Q" "{" [^{}]* "}"

uri.qualified.name = xsd:token { pattern = "Q\{[^\{\}]*\}[\i-[:]][\c-[:]]*" } 
eqname.datatype = qname.datatype | uri.qualified.name
qnames.datatype = list { qname.datatype* }
eqnames.datatype = list { eqname.datatype* }
ncname.datatype = xsd:NCName
prefix.datatype = xsd:NCName
boolean.datatype = "yes" | "no" | "true" | "false" | "0" | "1" 
expression.datatype = text
char.datatype = xsd:string { length = "1" }
string.datatype = text
id.datatype = xsd:NCName
tokens.datatype = list { token* }
prefixes.datatype = list { token* }
extension.prefixes.datatype = list { xsd:NCName* }
exclude.prefixes.datatype = list { "#all" | (xsd:NCName | "#default")* }
token.datatype = token
language.datatype = xsd:language
nmtoken.datatype = xsd:NMTOKEN
decimal.datatype = xsd:decimal
integer.datatype = xsd:integer
uri.datatype = xsd:anyURI
uris.datatype = list { xsd:anyURI* }
pattern.datatype = text
qname-but-not-ncname.datatype = xsd:QName { pattern = ".*:.*" }
xs_schema.element = element xs:schema { anyElement* }
item-type.datatype = text
sequence-type.datatype = text

# #standard or NCName or prefix=URI or URI
fixed-namespaces.datatype = xsd:string

select-or-sequence-constructor.model =
  ((attribute select { expression.datatype }
    | attribute _select { avt.datatype })+
   | sequence-constructor.model)

declaration.category =
   use-package.element
 | include.element
 | import.element
 | import-schema.element
 | strip-space.element
 | preserve-space.element
 | decimal-format.element
 | template.element
 | mode.element
 | global-context-item.element
 | variable.element
 | param.element
 | attribute-set.element
 | function.element
 | namespace-alias.element
 | accumulator.element
 | key.element
 | output.element
 | character-map.element

instruction.category =
   apply-templates.element
 | apply-imports.element
 | next-match.element
 | for-each.element
 | iterate.element
 | next-iteration.element
 | break.element
 | if.element
 | choose.element
 | switch.element
 | try.element
 | variable.element
 | call-template.element
 | evaluate.element
 | element.element
 | attribute.element
 | text.element
 | value-of.element
 | document.element
 | processing-instruction.element
 | namespace.element
 | comment.element
 | copy.element
 | copy-of.element
 | sequence.element
 | where-populated.element
 | on-empty.element
 | on-non-empty.element
 | number.element
 | perform-sort.element
 | for-each-group.element
 | merge.element
 | fork.element
 | analyze-string.element
 | source-document.element
 | map.element
 | map-entry.element
 | array.element
 | array-member.element
 | message.element
 | assert.element
 | fallback.element
 | result-document.element
 | select.element
package.element =
   element package {
      extension.atts,
      attribute id { id.datatype }?,
      attribute _id { avt.datatype }?,
      attribute name { uri.datatype }?,
      attribute _name { avt.datatype }?,
      attribute package-version { string.datatype }?,
      attribute _package-version { avt.datatype }?,
      attribute version { decimal.datatype }?,
      attribute _version { avt.datatype }?,
      attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
      attribute _input-type-annotations { avt.datatype }?,
      attribute declared-modes { boolean.datatype }?,
      attribute _declared-modes { avt.datatype }?,
      attribute default-mode { eqname.datatype | "#unnamed" }?,
      attribute _default-mode { avt.datatype }?,
      attribute default-validation { "preserve" | "strip" }?,
      attribute _default-validation { avt.datatype }?,
      attribute default-collation { uris.datatype }?,
      attribute _default-collation { avt.datatype }?,
      attribute extension-element-prefixes { prefixes.datatype }?,
      attribute _extension-element-prefixes { avt.datatype }?,
      attribute exclude-result-prefixes { prefixes.datatype }?,
      attribute _exclude-result-prefixes { avt.datatype }?,
      attribute expand-text { boolean.datatype }?,
      attribute _expand-text { avt.datatype }?,
      attribute use-when { expression.datatype }?,
      attribute _use-when { avt.datatype }?,
      attribute xpath-default-namespace { uri.datatype }?,
      attribute _xpath-default-namespace { avt.datatype }?,
      attribute fixed-namespaces { fixed-namespaces.datatype }?,
      attribute _fixed-namespaces { fixed-namespaces.datatype }?,
      ((expose.element | declarations.model)*)
   }
use-package.element =
   element use-package {
      extension.atts,
      global.atts,
      attribute name { uri.datatype }?,
      attribute _name { avt.datatype }?,
      attribute package-version { string.datatype }?,
      attribute _package-version { avt.datatype }?,
      (accept.element | override.element)*
   }
expose.element =
   element expose {
      extension.atts,
      global.atts,
      attribute component { "template" | "function" | "attribute-set" | "variable" | "mode" | "*" }?,
      attribute _component { avt.datatype }?,
      attribute names { tokens.datatype }?,
      attribute _names { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      empty
   }
accept.element =
   element accept {
      extension.atts,
      global.atts,
      (attribute component { "template" | "function" | "attribute-set" | "variable" | "mode" | "*" } |
      attribute _component { avt.datatype })+,
      (attribute names { tokens.datatype } |
      attribute _names { avt.datatype })+,
      (attribute visibility { "public" | "private" | "final" | "abstract" | "hidden" } |
      attribute _visibility { avt.datatype })+,
      empty
   }
override.element =
   element override {
      extension.atts,
      global.atts,
      (template.element | function.element | variable.element | param.element | attribute-set.element)*
   }
stylesheet.element =
   element stylesheet {
      extension.atts,
      attribute id { id.datatype }?,
      attribute _id { avt.datatype }?,
      attribute version { decimal.datatype }?,
      attribute _version { avt.datatype }?,
      attribute default-mode { eqname.datatype | "#unnamed" }?,
      attribute _default-mode { avt.datatype }?,
      attribute default-validation { "preserve" | "strip" }?,
      attribute _default-validation { avt.datatype }?,
      attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
      attribute _input-type-annotations { avt.datatype }?,
      attribute default-collation { uris.datatype }?,
      attribute _default-collation { avt.datatype }?,
      attribute extension-element-prefixes { prefixes.datatype }?,
      attribute _extension-element-prefixes { avt.datatype }?,
      attribute exclude-result-prefixes { prefixes.datatype }?,
      attribute _exclude-result-prefixes { avt.datatype }?,
      attribute expand-text { boolean.datatype }?,
      attribute _expand-text { avt.datatype }?,
      attribute use-when { expression.datatype }?,
      attribute _use-when { avt.datatype }?,
      attribute xpath-default-namespace { uri.datatype }?,
      attribute _xpath-default-namespace { avt.datatype }?,
      attribute fixed-namespaces { fixed-namespaces.datatype }?,
      attribute _fixed-namespaces { fixed-namespaces.datatype }?,
      (declarations.model)
   }
transform.element =
   element transform {
      extension.atts,
      attribute id { id.datatype }?,
      attribute _id { avt.datatype }?,
      attribute version { decimal.datatype }?,
      attribute _version { avt.datatype }?,
      attribute default-mode { eqname.datatype | "#unnamed" }?,
      attribute _default-mode { avt.datatype }?,
      attribute default-validation { "preserve" | "strip" }?,
      attribute _default-validation { avt.datatype }?,
      attribute input-type-annotations { "preserve" | "strip" | "unspecified" }?,
      attribute _input-type-annotations { avt.datatype }?,
      attribute default-collation { uris.datatype }?,
      attribute _default-collation { avt.datatype }?,
      attribute extension-element-prefixes { prefixes.datatype }?,
      attribute _extension-element-prefixes { avt.datatype }?,
      attribute exclude-result-prefixes { prefixes.datatype }?,
      attribute _exclude-result-prefixes { avt.datatype }?,
      attribute expand-text { boolean.datatype }?,
      attribute _expand-text { avt.datatype }?,
      attribute use-when { expression.datatype }?,
      attribute _use-when { avt.datatype }?,
      attribute xpath-default-namespace { uri.datatype }?,
      attribute _xpath-default-namespace { avt.datatype }?,
      attribute fixed-namespaces { fixed-namespaces.datatype }?,
      attribute _fixed-namespaces { fixed-namespaces.datatype }?,
      (declarations.model)
   }
include.element =
   element include {
      extension.atts,
      global.atts,
      attribute href { uri.datatype }?,
      attribute _href { avt.datatype }?,
      empty
   }
import.element =
   element import {
      extension.atts,
      global.atts,
      (attribute href { uri.datatype }
      | attribute _href { avt.datatype })+,
      empty
   }
import-schema.element =
   element import-schema {
      extension.atts,
      global.atts,
      attribute namespace { uri.datatype }?,
      attribute _namespace { avt.datatype }?,
      attribute schema-location { uri.datatype }?,
      attribute _schema-location { avt.datatype }?,
      xs_schema.element?
   }
strip-space.element =
   element strip-space {
      extension.atts,
      global.atts,
      (attribute elements { tokens.datatype }
      | attribute _elements { avt.datatype })+,
      empty
   }
preserve-space.element =
   element preserve-space {
      extension.atts,
      global.atts,
      (attribute elements { tokens.datatype }
      | attribute _elements { avt.datatype })+,
      empty
   }
decimal-format.element =
   element decimal-format {
      extension.atts,
      global.atts,
      attribute name { eqname.datatype }?,
      attribute _name { avt.datatype }?,
      attribute decimal-separator { char.datatype }?,
      attribute _decimal-separator { avt.datatype }?,
      attribute grouping-separator { char.datatype }?,
      attribute _grouping-separator { avt.datatype }?,
      attribute infinity { string.datatype }?,
      attribute _infinity { avt.datatype }?,
      attribute minus-sign { char.datatype }?,
      attribute _minus-sign { avt.datatype }?,
      attribute exponent-separator { char.datatype }?,
      attribute _exponent-separator { avt.datatype }?,
      attribute NaN { string.datatype }?,
      attribute _NaN { avt.datatype }?,
      attribute percent { char.datatype }?,
      attribute _percent { avt.datatype }?,
      attribute per-mille { char.datatype }?,
      attribute _per-mille { avt.datatype }?,
      attribute zero-digit { char.datatype }?,
      attribute _zero-digit { avt.datatype }?,
      attribute digit { char.datatype }?,
      attribute _digit { avt.datatype }?,
      attribute pattern-separator { char.datatype }?,
      attribute _pattern-separator { avt.datatype }?,
      empty
   }
template.element =
   element template {
      extension.atts,
      global.atts,
      (attribute match { pattern.datatype }
      | attribute _match { avt.datatype }
      | attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute priority { decimal.datatype }?,
      attribute _priority { avt.datatype }?,
      attribute mode { list { '#all' | ('#default' | '#unnamed' | eqname.datatype)* } }?,
      attribute _mode { avt.datatype }?,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      (context-item.element?, param.element*, sequence-constructor.model)
   }
apply-templates.element =
   element apply-templates {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute mode { (eqname.datatype | '#unnamed' | '#default' | '#current') }?,
      attribute _mode { avt.datatype }?,
      attribute separator { avt.datatype }?,
      attribute _separator { avt.datatype }?,
      (sort.element | with-param.element)*
   }
mode.element =
   element mode {
      extension.atts,
      global.atts,
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute copy-namespaces { boolean.datatype }?
      | attribute _copy-namespaces { boolean.datatype }?),
      (attribute name { eqname.datatype }?
      | attribute _name { avt.datatype }?),
      (attribute streamable { boolean.datatype }?
      | attribute _streamable { avt.datatype }?),
      (attribute on-no-match { "deep-copy" | "shallow-copy" | "shallow-copy-all" | "deep-skip" | "shallow-skip" | "text-only-copy" | "fail" }?
      | attribute _on-no-match { avt.datatype }?),
      (attribute on-multiple-match { "use-last" | "fail" }?
      | attribute _on-multiple-match { avt.datatype }?),
      (attribute warning-on-no-match { boolean.datatype }?
      | attribute _warning-on-no-match { avt.datatype }?),
      (attribute warning-on-multiple-match { boolean.datatype }?
      | attribute _warning-on-multiple-match { avt.datatype }?),
      (attribute typed { boolean.datatype | "strict" | "lax" | "unspecified" }?
      | attribute _typed { avt.datatype }?),
      (attribute visibility { "public" | "private" | "final" }?
      | attribute _visibility { avt.datatype }?),
      (attribute use-accumulators { tokens.datatype }?
      | attribute _use-accumulators { avt.datatype }?),
      empty
   }
context-item.element =
   element context-item {
      extension.atts,
      global.atts,
      attribute as { item-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute use { "required" | "optional" | "absent" }?,
      attribute _use { avt.datatype }?,
      empty
   }
global-context-item.element =
   element global-context-item {
      extension.atts,
      global.atts,
      attribute as { item-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute use { "required" | "optional" | "absent" }?,
      attribute _use { avt.datatype }?,
      empty
   }
apply-imports.element =
   element apply-imports {
      extension.atts,
      global.atts,
      with-param.element*
   }
next-match.element =
   element next-match {
      extension.atts,
      global.atts,
      (with-param.element | fallback.element)*
   }
for-each.element =
   element for-each {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      (sort.element*, sequence-constructor.model)
   }
iterate.element =
   element iterate {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      (param.element*, on-completion.element?, sequence-constructor.model)
   }
next-iteration.element =
   element next-iteration {
      extension.atts,
      global.atts,
      (with-param.element*)
   }
break.element =
   element break {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })?,
      sequence-constructor.model
   }
on-completion.element =
   element on-completion {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      sequence-constructor.model
   }
if.element =
   element if {
      extension.atts,
      global.atts,
      (attribute test { expression.datatype }
      | attribute _test { avt.datatype })+,
      sequence-constructor.model
   }
choose.element =
   element choose {
      extension.atts,
      global.atts,
      (when.element+, otherwise.element?)
   }
when.element =
   element when {
      extension.atts,
      global.atts,
      (attribute test { expression.datatype }
      | attribute _test { avt.datatype })+,
      select-or-sequence-constructor.model
   }
otherwise.element =
   element otherwise {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }

switch.element =
  element switch {
    extension.atts,
    global.atts,
    (attribute select { expression.datatype }
    | attribute _select { avt.datatype })+,
    (when.element+, otherwise.element?, fallback.element*)
  }

try.element =
   element try {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute rollback-output { boolean.datatype }?,
      attribute _rollback-output { avt.datatype }?,
      (sequence-constructor.model, catch.element, (catch.element | fallback.element)*)
   }
catch.element =
   element catch {
      extension.atts,
      global.atts,
      attribute errors { tokens.datatype }?,
      attribute _errors { avt.datatype }?,
      select-or-sequence-constructor.model
   }
variable.element =
   element variable {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute static { boolean.datatype }?,
      attribute _static { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      select-or-sequence-constructor.model
   }
param.element =
   element param {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute required { boolean.datatype }?,
      attribute _required { avt.datatype }?,
      attribute tunnel { boolean.datatype }?,
      attribute _tunnel { avt.datatype }?,
      attribute static { boolean.datatype }?,
      attribute _static { avt.datatype }?,
      select-or-sequence-constructor.model
   }
with-param.element =
   element with-param {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute tunnel { boolean.datatype }?,
      attribute _tunnel { avt.datatype }?,
      select-or-sequence-constructor.model
   }
call-template.element =
   element call-template {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      with-param.element*
   }
attribute-set.element =
   element attribute-set {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute use-attribute-sets { eqnames.datatype }?,
      attribute _use-attribute-sets { avt.datatype }?,
      attribute visibility { "public" | "private" | "final" | "abstract" }?,
      attribute _visibility { avt.datatype }?,
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      attribute.element*
   }
function.element =
   element function {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute visibility { "public" | "private" | "final" | "abstract" }?
      | attribute _visibility { avt.datatype }?),
      (attribute streamability { "unclassified" | "absorbing" | "inspection" | "filter" | "shallow-descent" | "deep-descent" | "ascent" | eqname.datatype }?
      | attribute _streamability { avt.datatype }?),
      (attribute override-extension-function { boolean.datatype }?
      | attribute _override-extension-function { avt.datatype }?),
      (attribute override { boolean.datatype }?
      | attribute _override { avt.datatype }?),
      (attribute new-each-time { "yes" | "true" | "1" | "no" | "false" | "0" | "maybe" }?
      | attribute _new-each-time { avt.datatype }?),
      (attribute cache { boolean.datatype }?
      | attribute _cache { avt.datatype }?),
      (param.element*, sequence-constructor.model)
   }
evaluate.element =
   element evaluate {
      extension.atts,
      global.atts,
      (attribute xpath { expression.datatype }
      | attribute _xpath { avt.datatype })+,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute base-uri { uri.datatype | avt.datatype }?,
      attribute _base-uri { avt.datatype }?,
      attribute with-params { expression.datatype }?,
      attribute _with-params { avt.datatype }?,
      attribute context-item { expression.datatype }?,
      attribute _context-item { avt.datatype }?,
      attribute namespace-context { expression.datatype }?,
      attribute _namespace-context { avt.datatype }?,
      attribute schema-aware { boolean.datatype | avt.datatype }?,
      attribute _schema-aware { avt.datatype }?,
      (with-param.element | fallback.element)*
   }
namespace-alias.element =
   element namespace-alias {
      extension.atts,
      global.atts,
      (attribute stylesheet-prefix { prefix.datatype | "#default" }
      | attribute _stylesheet-prefix { avt.datatype })+,
      (attribute result-prefix { prefix.datatype | "#default" }
      | attribute _result-prefix { avt.datatype })+,
      empty
   }
element.element =
   element element {
      extension.atts,
      global.atts,
      (attribute name { qname.datatype | avt.datatype }
      | attribute _name { avt.datatype })+,
      attribute namespace { uri.datatype | avt.datatype }?,
      attribute _namespace { avt.datatype }?,
      attribute inherit-namespaces { boolean.datatype }?,
      attribute _inherit-namespaces { avt.datatype }?,
      attribute use-attribute-sets { eqnames.datatype }?,
      attribute _use-attribute-sets { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      sequence-constructor.model
   }
attribute.element =
   element attribute {
      extension.atts,
      global.atts,
      (attribute name { qname.datatype | avt.datatype }
      | attribute _name { avt.datatype })+,
      attribute namespace { uri.datatype | avt.datatype }?,
      attribute _namespace { avt.datatype }?,
      attribute separator { string.datatype | avt.datatype }?,
      attribute _separator { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      select-or-sequence-constructor.model
   }
text.element =
   element text {
      extension.atts,
      global.atts,
      attribute separator { string.datatype | avt.datatype }?,
      attribute _separator { avt.datatype }?,
      attribute cdata { boolean.datatype | avt.datatype }?,
      attribute _cdata { avt.datatype }?,
      attribute disable-output-escaping { boolean.datatype }?,
      attribute _disable-output-escaping { avt.datatype }?,
      text
   }
value-of.element =
   element value-of {
      extension.atts,
      global.atts,
      attribute separator { string.datatype | avt.datatype }?,
      attribute _separator { avt.datatype }?,
      attribute cdata { boolean.datatype | avt.datatype }?,
      attribute _cdata { avt.datatype }?,
      attribute disable-output-escaping { boolean.datatype }?,
      attribute _disable-output-escaping { avt.datatype }?,
      select-or-sequence-constructor.model
   }
document.element =
   element document {
      extension.atts,
      global.atts,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      sequence-constructor.model
   }
processing-instruction.element =
   element processing-instruction {
      extension.atts,
      global.atts,
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype }),
      select-or-sequence-constructor.model
   }
record.element = 
   element record {
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute duplicates { expression.datatype }?
      | attribute _duplicates { avt.datatype }?),
      sequence-constructor.model
  }
record-type.element = 
   element record-type {
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype }),
      (attribute extensible { boolean.datatype }?
      | attribute _extensible { avt.datatype }?),
      (attribute visibility { "public" | "private" | "final" | "abstract" | "hidden" }?
      | attribute _visibility { avt.datatype }?),
      field.element*
  }
field.element = 
   element field {
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype }),
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (attribute required { boolean.datatype }?
      | attribute _required { avt.datatype }?),
      (attribute \default { expression.datatype }?
      |attribute _default { expression.datatype }?),
      empty
  }

select.element = 
   element select {
      (attribute as { sequence-type.datatype }?
      | attribute _as { avt.datatype }?),
      (fallback.element | text)*
  }
namespace.element =
   element namespace {
      extension.atts,
      global.atts,
      (attribute name { ncname.datatype | avt.datatype }
      | attribute _name { avt.datatype })+,
      select-or-sequence-constructor.model
   }
comment.element =
   element comment {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
copy.element =
   element copy {
      extension.atts,
      global.atts,
      attribute copy-namespaces { boolean.datatype }?,
      attribute _copy-namespaces { avt.datatype }?,
      attribute inherit-namespaces { boolean.datatype }?,
      attribute _inherit-namespaces { avt.datatype }?,
      attribute use-attribute-sets { eqnames.datatype }?,
      attribute _use-attribute-sets { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      sequence-constructor.model
   }
copy-of.element =
   element copy-of {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      attribute copy-accumulators { boolean.datatype }?,
      attribute _copy-accumulators { avt.datatype }?,
      attribute copy-namespaces { boolean.datatype }?,
      attribute _copy-namespaces { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      empty
   }
sequence.element =
   element sequence {
      extension.atts,
      global.atts,
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      select-or-sequence-constructor.model
   }
where-populated.element =
   element where-populated {
      extension.atts,
      global.atts,
      sequence-constructor.model
   }
on-empty.element =
   element on-empty {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
on-non-empty.element =
   element on-non-empty {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
number.element =
   element number {
      extension.atts,
      global.atts,
      attribute value { expression.datatype }?,
      attribute _value { avt.datatype }?,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute level { "single" | "multiple" | "any" }?,
      attribute _level { avt.datatype }?,
      attribute count { pattern.datatype }?,
      attribute _count { avt.datatype }?,
      attribute from { pattern.datatype }?,
      attribute _from { avt.datatype }?,
      attribute format { string.datatype | avt.datatype }?,
      attribute _format { avt.datatype }?,
      attribute lang { language.datatype | avt.datatype }?,
      attribute _lang { avt.datatype }?,
      attribute letter-value { "alphabetic" | "traditional" | avt.datatype }?,
      attribute _letter-value { avt.datatype }?,
      attribute ordinal { string.datatype | avt.datatype }?,
      attribute _ordinal { avt.datatype }?,
      attribute start-at { integer.datatype | avt.datatype }?,
      attribute _start-at { avt.datatype }?,
      attribute grouping-separator { char.datatype | avt.datatype }?,
      attribute _grouping-separator { avt.datatype }?,
      attribute grouping-size { integer.datatype | avt.datatype }?,
      attribute _grouping-size { avt.datatype }?,
      empty
   }
sort.element =
   element sort {
      extension.atts,
      global.atts,
      attribute lang { language.datatype | avt.datatype }?,
      attribute _lang { avt.datatype }?,
      attribute order { "ascending" | "descending" | avt.datatype }?,
      attribute _order { avt.datatype }?,
      attribute collation { uri.datatype | avt.datatype }?,
      attribute _collation { avt.datatype }?,
      attribute stable { boolean.datatype | avt.datatype }?,
      attribute _stable { avt.datatype }?,
      attribute case-order { "upper-first" | "lower-first" | avt.datatype }?,
      attribute _case-order { avt.datatype }?,
      attribute data-type { "text" | "number" | eqname.datatype | avt.datatype }?,
      attribute _data-type { avt.datatype }?,
      select-or-sequence-constructor.model
   }
perform-sort.element =
   element perform-sort {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      (sort.element+, sequence-constructor.model)
   }
for-each-group.element =
   element for-each-group {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      ((attribute group-by { expression.datatype }?,
      attribute _group-by { avt.datatype }?) |
      (attribute group-adjacent { expression.datatype }?,
      attribute _group-adjacent { avt.datatype }?) |
      (attribute group-starting-with { pattern.datatype }?,
      attribute _group-starting-with { avt.datatype }?) |
      (attribute group-ending-with { pattern.datatype }?,
      attribute _group-ending-with { avt.datatype }?)),
      attribute composite { boolean.datatype }?,
      attribute _composite { avt.datatype }?,
      attribute collation { uri.datatype | avt.datatype }?,
      attribute _collation { avt.datatype }?,
      (sort.element*, sequence-constructor.model)
   }
merge.element =
   element merge {
      extension.atts,
      global.atts,
      (merge-source.element+, merge-action.element, fallback.element*)
   }
merge-source.element =
   element merge-source {
      extension.atts,
      global.atts,
      attribute name { ncname.datatype }?,
      attribute _name { avt.datatype }?,
      attribute for-each-item { expression.datatype }?,
      attribute _for-each-item { avt.datatype }?,
      attribute for-each-stream { expression.datatype }?,
      attribute _for-each-stream { avt.datatype }?,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      attribute use-accumulators { tokens.datatype }?,
      attribute _use-accumulators { avt.datatype }?,
      attribute sort-before-merge { boolean.datatype }?,
      attribute _sort-before-merge { avt.datatype }?,
      attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }?,
      attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?,
      attribute for-each-source { expression.datatype }?,
      attribute _for-each-source { avt.datatype }?,
      merge-key.element+
   }
merge-key.element =
   element merge-key {
      extension.atts,
      global.atts,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute lang { language.datatype | avt.datatype }?,
      attribute _lang { avt.datatype }?,
      attribute order { "ascending" | "descending" | avt.datatype }?,
      attribute _order { avt.datatype }?,
      attribute collation { uri.datatype | avt.datatype }?,
      attribute _collation { avt.datatype }?,
      attribute case-order { "upper-first" | "lower-first" | avt.datatype }?,
      attribute _case-order { avt.datatype }?,
      attribute data-type { "text" | "number" | eqname.datatype | avt.datatype }?,
      attribute _data-type { avt.datatype }?,
      sequence-constructor.model
   }
merge-action.element =
   element merge-action {
      extension.atts,
      global.atts,
      sequence-constructor.model
   }
fork.element =
   element fork {
      extension.atts,
      global.atts,
      (fallback.element*, ((sequence.element, fallback.element*)* | (for-each-group.element, fallback.element*)))
   }
analyze-string.element =
   element analyze-string {
      extension.atts,
      global.atts,
      (attribute select { expression.datatype }
      | attribute _select { avt.datatype })+,
      (attribute regex { string.datatype | avt.datatype }
      | attribute _regex { avt.datatype })+,
      attribute flags { string.datatype | avt.datatype }?,
      attribute _flags { avt.datatype }?,
      (matching-substring.element?, non-matching-substring.element?, fallback.element*)
   }
matching-substring.element =
   element matching-substring {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
non-matching-substring.element =
   element non-matching-substring {
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }
source-document.element =
   element source-document {
      extension.atts,
      global.atts,
      (attribute href { uri.datatype | avt.datatype }
      | attribute _href { avt.datatype })+,
      attribute use-accumulators { tokens.datatype }?,
      attribute _use-accumulators { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      sequence-constructor.model
   }
accumulator.element =
   element accumulator {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype }),
      (attribute initial-value { expression.datatype }
      | attribute _initial-value { avt.datatype }),
      attribute as { sequence-type.datatype }?,
      attribute _as { avt.datatype }?,
      attribute streamable { boolean.datatype }?,
      attribute _streamable { avt.datatype }?,
      accumulator-rule.element+
   }
accumulator-rule.element =
   element accumulator-rule {
      extension.atts,
      global.atts,
      (attribute match { pattern.datatype } |
      attribute _match { avt.datatype })+,
      attribute phase { "start" | "end" }?,
      attribute _phase { avt.datatype }?,
      select-or-sequence-constructor.model
   }
key.element =
   element key {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      (attribute match { pattern.datatype }
      | attribute _match { avt.datatype })+,
      attribute use { expression.datatype }?,
      attribute _use { avt.datatype }?,
      attribute composite { boolean.datatype }?,
      attribute _composite { avt.datatype }?,
      attribute collation { uri.datatype }?,
      attribute _collation { avt.datatype }?,
      sequence-constructor.model
   }
map.element =
   element map {
      (attribute duplicates { expression.datatype }?
      | attribute _duplicates { avt.datatype }?),
      extension.atts,
      global.atts,
      select-or-sequence-constructor.model
   }

map-entry.element =
   element map-entry {
      extension.atts,
      global.atts,
      (attribute key { expression.datatype }
      | attribute _key { avt.datatype }),
      select-or-sequence-constructor.model
   }

array.element =
  element array {
    (attribute for-each { expression.datatype }
     | attribute _for-each { expression.datatype }),
    extension.atts,
    global.atts,
    select-or-sequence-constructor.model
  }

array-member.element =
  element array-member {
    extension.atts,
    global.atts,
    select-or-sequence-constructor.model
  }

message.element =
   element message {
      extension.atts,
      global.atts,
      attribute terminate { boolean.datatype | avt.datatype }?,
      attribute _terminate { avt.datatype }?,
      attribute error-code { eqname.datatype | avt.datatype }?,
      attribute _error-code { avt.datatype }?,
      select-or-sequence-constructor.model
   }
assert.element =
   element assert {
      extension.atts,
      global.atts,
      (attribute test { expression.datatype }
      | attribute _test { avt.datatype })+,
      attribute select { expression.datatype }?,
      attribute _select { avt.datatype }?,
      attribute error-code { eqname.datatype | avt.datatype }?,
      attribute _error-code { avt.datatype }?,
      sequence-constructor.model
   }
fallback.element =
   element fallback {
      extension.atts,
      global.atts,
      sequence-constructor.model
   }
result-document.element =
   element result-document {
      extension.atts,
      global.atts,
      attribute format { eqname.datatype | avt.datatype }?,
      attribute _format { avt.datatype }?,
      attribute href { uri.datatype | avt.datatype }?,
      attribute _href { avt.datatype }?,
      ((attribute type { eqname.datatype }?,
      attribute _type { avt.datatype }?) |
      (attribute validation { "strict" | "lax" | "preserve" | "strip" }?,
      attribute _validation { avt.datatype }? )), # type and validation are mutually exclusive      
      attribute method { "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname.datatype | avt.datatype }?,
      attribute _method { avt.datatype }?,
      attribute allow-duplicate-names { boolean.datatype | avt.datatype }?,
      attribute _allow-duplicate-names { avt.datatype }?,
      attribute build-tree { boolean.datatype | avt.datatype }?,
      attribute _build-tree { avt.datatype }?,
      attribute byte-order-mark { boolean.datatype | avt.datatype }?,
      attribute _byte-order-mark { avt.datatype }?,
      attribute cdata-section-elements { eqnames.datatype | avt.datatype }?,
      attribute _cdata-section-elements { avt.datatype }?,
      attribute doctype-public { string.datatype | avt.datatype }?,
      attribute _doctype-public { avt.datatype }?,
      attribute doctype-system { string.datatype | avt.datatype }?,
      attribute _doctype-system { avt.datatype }?,
      attribute encoding { string.datatype | avt.datatype }?,
      attribute _encoding { avt.datatype }?,
      attribute escape-uri-attributes { boolean.datatype | avt.datatype }?,
      attribute _escape-uri-attributes { avt.datatype }?,
      attribute html-version { decimal.datatype | avt.datatype }?,
      attribute _html-version { avt.datatype }?,
      attribute include-content-type { boolean.datatype | avt.datatype }?,
      attribute _include-content-type { avt.datatype }?,
      attribute indent { boolean.datatype | avt.datatype }?,
      attribute _indent { avt.datatype }?,
      attribute item-separator { string.datatype | avt.datatype }?,
      attribute _item-separator { avt.datatype }?,
      attribute json-node-output-method { "xml" | "html" | "xhtml" | "text" | eqname.datatype | avt.datatype }?,
      attribute _json-node-output-method { avt.datatype }?,
      attribute media-type { string.datatype | avt.datatype }?,
      attribute _media-type { avt.datatype }?,
      attribute normalization-form { "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken.datatype | avt.datatype }?,
      attribute _normalization-form { avt.datatype }?,
      attribute omit-xml-declaration { boolean.datatype | avt.datatype }?,
      attribute _omit-xml-declaration { avt.datatype }?,
      attribute parameter-document { uri.datatype | avt.datatype }?,
      attribute _parameter-document { avt.datatype }?,
      attribute standalone { boolean.datatype | "omit" | avt.datatype }?,
      attribute _standalone { avt.datatype }?,
      attribute suppress-indentation { eqnames.datatype | avt.datatype }?,
      attribute _suppress-indentation { avt.datatype }?,
      attribute undeclare-prefixes { boolean.datatype | avt.datatype }?,
      attribute _undeclare-prefixes { avt.datatype }?,
      attribute use-character-maps { eqnames.datatype }?,
      attribute _use-character-maps { avt.datatype }?,
      attribute output-version { nmtoken.datatype | avt.datatype }?,
      attribute _output-version { avt.datatype }?,
      sequence-constructor.model
   }
output.element =
   element output {
      extension.atts,
      global.atts.except.version,
      attribute name { eqname.datatype }?,
      attribute _name { avt.datatype }?,
      attribute method { "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname.datatype }?,
      attribute _method { avt.datatype }?,
      attribute allow-duplicate-names { boolean.datatype }?,
      attribute _allow-duplicate-names { avt.datatype }?,
      attribute build-tree { boolean.datatype }?,
      attribute _build-tree { avt.datatype }?,
      attribute byte-order-mark { boolean.datatype }?,
      attribute _byte-order-mark { avt.datatype }?,
      attribute cdata-section-elements { eqnames.datatype }?,
      attribute _cdata-section-elements { avt.datatype }?,
      attribute doctype-public { string.datatype }?,
      attribute _doctype-public { avt.datatype }?,
      attribute doctype-system { string.datatype }?,
      attribute _doctype-system { avt.datatype }?,
      attribute encoding { string.datatype }?,
      attribute _encoding { avt.datatype }?,
      attribute escape-uri-attributes { boolean.datatype }?,
      attribute _escape-uri-attributes { avt.datatype }?,
      attribute html-version { decimal.datatype }?,
      attribute _html-version { avt.datatype }?,
      attribute include-content-type { boolean.datatype }?,
      attribute _include-content-type { avt.datatype }?,
      attribute indent { boolean.datatype }?,
      attribute _indent { avt.datatype }?,
      attribute item-separator { string.datatype }?,
      attribute _item-separator { avt.datatype }?,
      attribute json-node-output-method { "xml" | "html" | "xhtml" | "text" | eqname.datatype }?,
      attribute _json-node-output-method { avt.datatype }?,
      attribute media-type { string.datatype }?,
      attribute _media-type { avt.datatype }?,
      attribute normalization-form { "NFC" | "NFD" | "NFKC" | "NFKD" | "fully-normalized" | "none" | nmtoken.datatype }?,
      attribute _normalization-form { avt.datatype }?,
      attribute omit-xml-declaration { boolean.datatype }?,
      attribute _omit-xml-declaration { avt.datatype }?,
      attribute parameter-document { uri.datatype }?,
      attribute _parameter-document { avt.datatype }?,
      attribute standalone { boolean.datatype | "omit" }?,
      attribute _standalone { avt.datatype }?,
      attribute suppress-indentation { eqnames.datatype }?,
      attribute _suppress-indentation { avt.datatype }?,
      attribute undeclare-prefixes { boolean.datatype }?,
      attribute _undeclare-prefixes { avt.datatype }?,
      attribute use-character-maps { eqnames.datatype }?,
      attribute _use-character-maps { avt.datatype }?,
      attribute version { nmtoken.datatype }?,
      attribute _version { avt.datatype }?,
      empty
   }
character-map.element =
   element character-map {
      extension.atts,
      global.atts,
      (attribute name { eqname.datatype }
      | attribute _name { avt.datatype })+,
      attribute use-character-maps { eqnames.datatype }?,
      attribute _use-character-maps { avt.datatype }?,
      (output-character.element*)
   }
output-character.element =
   element output-character {
      extension.atts,
      global.atts,
      (attribute character { char.datatype }
      | attribute _character { avt.datatype })+,
      (attribute string { string.datatype }
      | attribute _string { avt.datatype })+,
      empty
   }
avt.datatype =
  xsd:string
# {
#    pattern =
#      """([^\{\}]|\{\{|\}\}|\{([^"'\{\}]|"[^"]*"|'[^']*')+\})*""" # this regexp will not work in all the case.
#      }