<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.w3.org/2010/xslt-xquery-serialization"
      xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization"
      elementFormDefault="qualified">

  <xs:annotation>
    <xs:documentation>
      This is a schema for serialization parameters for
      XSLT and XQuery Serialization 3.0.

      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

      It defines a schema for XML Infoset instances with which a user of
      a host language MAY specify serialization parameters for use in
      serializing an instance of the XQuery and XPath Data Model.  It
      also provides hooks that allow the inclusion of implementation-
      defined serialization parameters and implementation-defined
      modifiers to serialization parameters.
    </xs:documentation>
  </xs:annotation>

  <xs:simpleType name="QNames-type">
    <xs:list itemType="xs:QName"/>
  </xs:simpleType>

  <xs:simpleType name="yes-no-type">
    <xs:restriction base="xs:token">
      <xs:enumeration value="no"/>
      <xs:enumeration value="yes"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="yes-no-omit-type">
    <xs:restriction base="xs:token">
      <xs:enumeration value="no"/>
      <xs:enumeration value="omit"/>
      <xs:enumeration value="yes"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="char-type">
    <xs:restriction base="xs:string">
      <xs:maxLength value="1"/>
      <xs:minLength value="1"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="encoding-string-type">
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Za-z]([A-Za-z0-9._\-])*"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="method-type">
    <xs:union>
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="html"/>
          <xs:enumeration value="text"/>
          <xs:enumeration value="xml"/>
          <xs:enumeration value="xhtml"/>
          <xs:enumeration value="json"/>
          <xs:enumeration value="json-xml-hybrid"/>          
        </xs:restriction>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="xs:QName">
          <xs:pattern value=".*:.*"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="pubid-char-string-type">
    <xs:restriction base="xs:string">
      <xs:pattern value="([- \r\n\ta-zA-Z0-9'()+,./:=?;!*#@$_%])*"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="system-id-string-type">
    <xs:restriction base="xs:string">
      <xs:pattern value="[^']*|[^&quot;]*"/>
    </xs:restriction>
  </xs:simpleType>

  <!--
     - Base type of all serialization parameter types
    -->
  <xs:complexType name="base-param-type">
    <xs:complexContent>
      <xs:restriction base="xs:anyType">
        <xs:anyAttribute namespace="##other" processContents="lax"/>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Generic string serialization parameters
    -->
  <xs:complexType name="string-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="xs:string" use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter type for "yes", "no" or "omit"
     - serialization parameters
    -->
  <xs:complexType name="yes-no-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="output:yes-no-type" use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter type for list of xs:QName
     - serialization parameters
    -->
  <xs:complexType name="QNames-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="output:QNames-type" use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter type for "yes", "no" or "omit"
     - serialization parameters
    -->
  <xs:complexType name="yes-no-omit-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="output:yes-no-omit-type"
              use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter element for byte-order-mark parameter
    -->
  <xs:element name="serialization-parameter-element"
        abstract="true"
        type="output:base-param-type"/>

  <!--
     - Serialization parameter element for byte-order-mark parameter
    -->
  <xs:element id="byte-order-mark" name="byte-order-mark" type="output:yes-no-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for cdata-section-elements parameter
    -->
  <xs:element id="cdata-section-elements" name="cdata-section-elements" type="output:QNames-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter type for doctype-public parameter
    -->
  <xs:complexType name="doctype-public-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="output:pubid-char-string-type"
              use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter element for doctype-public parameter
    -->
  <xs:element id="doctype-public" name="doctype-public" type="output:doctype-public-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter type for doctype-system parameter
    -->
  <xs:complexType name="doctype-system-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="output:system-id-string-type"
              use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter element for doctype-system parameter
    -->
  <xs:element id="doctype-system" name="doctype-system" type="output:doctype-system-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter type for encoding parameter
    -->
  <xs:complexType name="encoding-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="output:encoding-string-type"
              use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter element for method parameter
    -->
  <xs:element id="encoding" name="encoding" type="output:encoding-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for escape-uri-attributes parameter
    -->
  <xs:element id="escape-uri-attributes" name="escape-uri-attributes" type="output:yes-no-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for include-content-type parameter
    -->
  <xs:element id="include-content-type" name="include-content-type" type="output:yes-no-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for indent parameter
    -->
  <xs:element id="indent" name="indent" type="output:yes-no-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for media-type parameter
    -->
  <xs:element id="media-type" name="media-type" type="output:yes-no-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter type for method parameter
    -->
  <xs:complexType name="method-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:attribute name="value" type="output:method-type"
                use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter element for method parameter
    -->
  <xs:element id="method" name="method" type="output:method-param-type"
        substitutionGroup="output:serialization-parameter-element"/>
  <!--
     - Serialization parameter element for normalization-form parameter
    -->
  <xs:element id="normalization-form" name="normalization-form" type="output:string-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for omit-xml-declaration parameter
    -->
  <xs:element id="omit-xml-declaration" name="omit-xml-declaration" type="output:yes-no-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for standalone parameter
    -->
  <xs:element id="standalone" name="standalone" type="output:yes-no-omit-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for suppress-indentation parameter
    -->
  <xs:element id="suppress-indentation" name="suppress-indentation" type="output:QNames-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for undeclare-prefixes parameter
    -->
  <xs:element id="undeclare-prefixes" name="undeclare-prefixes" type="output:yes-no-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter type for use-character-maps
     - parameter
    -->
  <xs:complexType name="use-character-maps-param-type">
    <xs:complexContent>
      <xs:extension base="output:base-param-type">
        <xs:sequence>
          <xs:element name="character-map" minOccurs="0"
                  maxOccurs="unbounded">
            <xs:complexType>
              <xs:attribute name="character" type="output:char-type"/>
              <xs:attribute name="map-string" type="xs:string"/>
              <xs:anyAttribute namespace="##other"
                     processContents="lax"/>
            </xs:complexType>
          </xs:element>
          <xs:any minOccurs="0" namespace="##other"
                     processContents="lax"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!--
     - Serialization parameter element for use-character-maps parameter
    -->
  <xs:element id="use-character-maps" name="use-character-maps"
        type="output:use-character-maps-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <!--
     - Serialization parameter element for version parameter
    -->
  <xs:element id="version" name="version"
        type="output:string-param-type"
        substitutionGroup="output:serialization-parameter-element"/>

  <xs:element name="serialization-parameters">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="output:serialization-parameter-element"
              minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
