<?xml version="1.0" encoding="UTF-8"?>

<!--

   OASIS ebXML Messaging Services Version 3.0: Part 2, Advanced Features
   Committee Specification Draft 03
   16 February 2011
   Source: http://docs.oasis-open.org/ebxml-msg/ebms/v3.0/part2/201004/csd03/
-->

<xsd:schema 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:S11="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:S12="http://www.w3.org/2003/05/soap-envelope"
    xmlns:mf="http://docs.oasis-open.org/ebxml-msg/ns/v3.0/mf/2010/04/"
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified"
    targetNamespace="http://docs.oasis-open.org/ebxml-msg/ns/v3.0/mf/2010/04/"
    >

    <xsd:import namespace="http://www.w3.org/2003/05/soap-envelope"
        schemaLocation="http://www.w3.org/2003/05/soap-envelope"/>

    <xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/"
        schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"/>

    <xsd:element name="MessageFragment" type="mf:MessageFragmentType"/>

    <xsd:complexType name="MessageFragmentType">
        <xsd:sequence>
            <xsd:element name="GroupId" type="mf:non-empty-string">
                <xsd:annotation>
                    <xsd:documentation>The identifier of the group of fragments that a message is
                        split into. </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="MessageSize" type="xsd:positiveInteger" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>The size of the message as the sum of the size of all
                        fragments (excluding headers), i.e. before splitting or after reassembly.
                        This needs to be specified exactly once for a group. </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="FragmentCount" type="xsd:positiveInteger" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>The number of items that are part of the group. This needs to
                        be specified exactly once for a group. </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="FragmentNum" type="xsd:positiveInteger">
                <xsd:annotation>
                    <xsd:documentation>The identifier of an individual message in a sequence. 1 &lt;
                        FragmentCount &lt; </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="MessageHeader" type="mf:MessageHeaderType" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>The header fields and parameters of the fragmented message.
                        This needs to be specified exactly once for a group. </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Action" type="xsd:string" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation> This needs to be specified exactly once for a group. When
                        using SOAP 1.1, this value corresponds to the SOAPAction header. When using
                        SOAP 1.2, this value corresponds to the action parameter. When not set, this
                        value of the SOAPaction header or action parameter is assumed to be the
                        empty string. </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:sequence minOccurs="0" maxOccurs="1">
                <xsd:element name="CompressionAlgorithm" type="mf:CompressionAlgorithmType"/>
                <xsd:element name="CompressedMessageSize" type="xsd:positiveInteger"/>
            </xsd:sequence>
            <xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="href" type="xsd:anyURI"/>
        <xsd:attributeGroup ref="mf:S12atts"/>
        <xsd:attributeGroup ref="mf:S11atts"/>
        <xsd:anyAttribute namespace="##other" processContents="lax"/>
    </xsd:complexType>

    <xsd:complexType name="MessageHeaderType">
        <xsd:sequence>
            <xsd:element name="Content-Type" type="mf:non-empty-string" fixed="Multipart/Related"/>
            <xsd:element name="Boundary" type="mf:non-empty-string">
                <xsd:annotation>
                    <xsd:documentation>The MIME boundary separating the MIME parts in the MIME
                        envelop. </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Type" type="mf:TypeType"/>
            <xsd:element name="Start" type="mf:non-empty-string"/>
            <xsd:element name="StartInfo" type="mf:non-empty-string" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>For MTOM XOP </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Content-Description" type="xsd:string" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:simpleType name="non-empty-string">
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="1"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="TypeType">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="application/xop+xml">
                <xsd:annotation>
                    <xsd:documentation>XOP Package as defined in
                        http://www.w3.org/TR/2005/REC-xop10-20050125/ </xsd:documentation>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="text/xml">
                <xsd:annotation>
                    <xsd:documentation>SOAP with attachments </xsd:documentation>
                </xsd:annotation>
            </xsd:enumeration>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="HTTPCompressionAlgorithmType">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="gzip"/>
            <xsd:enumeration value="compress"/>
            <xsd:enumeration value="deflate"/>
            <xsd:enumeration value="identity"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="CompressionAlgorithmType">
        <xsd:union  memberTypes="mf:non-empty-string mf:HTTPCompressionAlgorithmType"/> 
    </xsd:simpleType>

    <xsd:attributeGroup name="S12atts">
        <xsd:attribute ref="S12:mustUnderstand" use="optional">
            <xsd:annotation>
                <xsd:documentation> if SOAP 1.2 is being used, this attribute is required, other
                    attributes in the S12atts group are allowed and attributes in the S11atts group
                    are prohibited.</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute ref="S12:encodingStyle"/>
        <xsd:attribute ref="S12:relay"/>
        <xsd:attribute ref="S12:role"/>
    </xsd:attributeGroup>

    <xsd:attributeGroup name="S11atts">
        <xsd:attribute ref="S11:mustUnderstand" use="optional">
            <xsd:annotation>
                <xsd:documentation> if SOAP 1.1 is being used, this attribute is required, other
                    attributes in the S11atts group are allowed and attributes in the S12atts group
                    are prohibited.</xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute ref="S11:encodingStyle"/>
        <xsd:attribute ref="S11:actor"/>
    </xsd:attributeGroup>

</xsd:schema>
