<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.company.com/09/08/2004/PaymentAuthorization/xsd"
           xmlns="http://www.company.com/09/08/2004/PaymentAuthorization/xsd">
    <xs:element name="PaymentAuthorizationRS">
        <xs:annotation>
            <xs:documentation>Response to a payment authorization request</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Authorization" minOccurs="1" maxOccurs="1">
                    <xs:complexType>
                        <xs:attribute name="AuthorizationSourceCode" use="optional">
                            <xs:simpleType>
                                <xs:restriction base="xs:string">
                                    <xs:length value="1"/>
                                </xs:restriction>
                            </xs:simpleType>
                        </xs:attribute>
                        <xs:attribute name="AuthorizationCode" use="optional">
                            <xs:simpleType>
                                <xs:restriction base="xs:string">
                                    <xs:minLength value="2"/>
                                    <xs:maxLength value="6"/>
                                </xs:restriction>
                            </xs:simpleType>
                        </xs:attribute>
                        <xs:attribute name="CardCode" type="PaymentCardCodeType" use="optional"/>
                        <xs:attribute name="CardNumber" type="NumericStringLength1to19" use="optional"/>
                        <xs:attribute name="PSIRFPaymentIndicator" use="optional">
                            <xs:simpleType>
                                <xs:restriction base="xs:string">
                                    <xs:length value="1"/>
                                </xs:restriction>
                            </xs:simpleType>
                        </xs:attribute>
                        <xs:attribute name="PSIRFTrackingNumber" use="optional">
                            <xs:simpleType>
                                <xs:restriction base="xs:string">
                                    <xs:length value="15"/>
                                </xs:restriction>
                            </xs:simpleType>
                        </xs:attribute>
                        <xs:attribute name="PSIRFValidationCode" use="optional">
                            <xs:simpleType>
                                <xs:restriction base="xs:string">
                                    <xs:length value="4"/>
                                </xs:restriction>
                            </xs:simpleType>
                        </xs:attribute>
                    </xs:complexType>
                </xs:element>
                <xs:element name="Rejection" minOccurs="1" maxOccurs="1">
                    <xs:complexType>
                        <xs:attribute name="CardCode" type="PaymentCardCodeType" use="optional"/>
                        <xs:attribute name="RejectCode">
                            <xs:simpleType>
                                <xs:restriction base="xs:string">
                                    <xs:minLength value="2"/>
                                    <xs:maxLength value="3"/>
                                </xs:restriction>
                            </xs:simpleType>
                        </xs:attribute>
                        <xs:attribute name="Message" type="StringLength1to64" use="optional"/>
                    </xs:complexType>
                </xs:element>
                <xs:element name="Error" type="ErrorType"  minOccurs="1" maxOccurs="1"/>
            </xs:sequence>
            <xs:attributeGroup ref="OTA_PayloadStdAttributes"/>
            <xs:attribute name="ApprovalStatusIndicator">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:length value="1"/>
                        <xs:pattern value="[YNE]"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>


    <!-- OTA_CommonTypes.xsd -->
    <xs:attributeGroup name="OTA_PayloadStdAttributes">
        <xs:annotation>
            <xs:documentation xml:lang="en">The OTA_PayloadStdAttributes defines the standard attributes that appear on the root element for all OTA payloads.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="EchoToken" type="StringLength1to64" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">A reference for additional message identification, assigned by the requesting host system. When a request message includes an echo token the corresponding response message MUST include an echo token with an identical value.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="TimeStamp" type="xs:dateTime" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">Indicates the creation date and time of the message in UTC using the following format specified by ISO 8601; YYYY-MM-DDThh:mm:ssZ with time values using the 24 hour clock (e.g. 20 November 2003, 1:59:38 pm UTC becomes 2003-11-20T13:59:38Z).</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="Target" use="optional" default="Production">
            <xs:annotation>
                <xs:documentation xml:lang="en">Used to indicate whether the request is for the Test or Production system.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:restriction base="xs:NMTOKEN">
                    <xs:enumeration value="Test"/>
                    <xs:enumeration value="Production"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="Version" type="xs:decimal" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">For all OTA versioned messages, the version of the message is indicated by a decimal value.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="TransactionIdentifier" type="StringLength1to32" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">A unique identifier to relate all messages within a transaction (e.g. this would be sent in all request and response messages that are part of an on-going transaction).</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="SequenceNmbr" type="xs:nonNegativeInteger" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">Used to identify the sequence number of the transaction as assigned by the sending system; allows for an application to process messages in a certain order or to request a resynchronization of messages in the event that a system has been off-line and needs to retrieve messages that were missed.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="TransactionStatusCode" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">This indicates where this message falls within a sequence of messages.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:restriction base="xs:NMTOKEN">
                    <xs:enumeration value="Start">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">This is the first message within a transaction.</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="End">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">This is the last message within a transaction.</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="Rollback">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">This indicates that all messages within the current transaction must be ignored.</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="InSeries">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">This is any message that is not the first or last message within a transaction.</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
        <xs:attributeGroup ref="PrimaryLangID_Group"/>
        <xs:attributeGroup ref="AltLangID_Group"/>
    </xs:attributeGroup>
    <xs:complexType name="FreeTextType">
        <xs:annotation>
            <xs:documentation xml:lang="en">Textual information to provide descriptions and/or additional information.</xs:documentation>
        </xs:annotation>
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attributeGroup ref="LanguageGroup"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:complexType name="ErrorType">
        <xs:annotation>
            <xs:documentation xml:lang="en">Standard way to indicate that an error occurred during the processing of an OTA message</xs:documentation>
        </xs:annotation>
        <xs:simpleContent>
            <xs:extension base="FreeTextType">
                <xs:attribute name="Type" type="OTA_CodeType" use="optional">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">The Error element MUST contain the Type attribute that uses a recommended set of values to indicate the error type. The validating XSD can expect to accept values that it has NOT been explicitly coded for and process them by using Type ="Unknown".  Refer to OTA Code List Error Warning Type (EWT).</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attributeGroup ref="ErrorWarningAttributeGroup"/>
                <xs:attribute name="NodeList" type="xs:string">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">An XPath expression that selects all the nodes whose data caused this error.  Further, this expression should have an   additional contraint which contains the data of the node.  This will provide the offending data back to systems that cannot maintain the original message.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:attributeGroup name="PrimaryLangID_Group">
        <xs:annotation>
            <xs:documentation>Identifes the primary language preference for the message.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="PrimaryLangID" type="xs:language" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">Identifes the primary language preference for the message.  The human language is identified by ISO 639 codes.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    <xs:attributeGroup name="AltLangID_Group">
        <xs:annotation>
            <xs:documentation xml:lang="en">Identifies the alternate language for a customer or message. The human language is identified by ISO 639 codes.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="AltLangID" type="xs:language" use="optional"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="LanguageGroup">
        <xs:annotation>
            <xs:documentation>Identifies language.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="Language" type="xs:language" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">Language identification.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    <xs:attributeGroup name="ErrorWarningAttributeGroup">
        <xs:annotation>
            <xs:documentation xml:lang="en">Used to identify an application error by either text, code, or by an online description and also to give the status, tag, and/or identification of the record that may have caused the error.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="ShortText" type="StringLength1to64" use="optional"/>
        <xs:attribute name="Code" type="OTA_CodeType" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">If present, this refers to a table of coded values exchanged between applications to identify errors or warnings. Refer to OTA Code List Error Codes (ERR).</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="DocURL" type="xs:anyURI" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">If present, this URL refers to an online description of the error that occurred.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="Status" type="StringLength1to64" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">If present, recommended values are those enumerated in the OTA_ErrorRS, (NotProcessed | Incomplete | Complete | Unknown) however, the data type is designated as string data, recognizing that trading partners may identify additional status conditions not included in the enumeration.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="Tag" type="xs:string" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">If present, this attribute may identify an unknown or misspelled tag that caused an error in processing. It is recommended that the Tag attribute use XPath notation to identify the location of a tag in the event that more than one tag of the same name is present in the document. Alternatively, the tag name alone can be used to identify missing data [Type=ReqFieldMissing].</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="RecordID" type="StringLength1to32" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">If present, this attribute allows for batch processing and the identification of the record that failed amongst a group of records.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>


    <!-- OTA_SimpleTypes.xsd -->
    <xs:simpleType name="PaymentCardCodeType">
        <xs:annotation>
            <xs:documentation xml:lang="en">The 2 digit code used that references the credit card used.</xs:documentation>
        </xs:annotation>
        <xs:union>
            <xs:simpleType>
                <xs:restriction base="UpperCaseAlphaLength1to2">
                    <xs:enumeration value="AX">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">American Express</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="BC">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Bank Card</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="BL">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Carte Bleu</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="CB">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Carte Blanche</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="DN">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Diners Club</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="DS">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Discover Card</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="EC">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Eurocard</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="JC">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">JCB Credit Card</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="MC">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Master Card</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="TP">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Universal Air Travel Card</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="VI">
                        <xs:annotation>
                            <xs:documentation xml:lang="en">Visa</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
            <xs:simpleType>
                <xs:annotation>
                    <xs:documentation xml:lang="en">This is intended to be used when the above enumeration list does not meet your needs.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="UpperCaseAlphaLength1to2"/>
            </xs:simpleType>
        </xs:union>
    </xs:simpleType>
    <xs:simpleType name="NumericStringLength1to19">
        <xs:annotation>
            <xs:documentation xml:lang="en">Used for Numeric Strings, length 1 to 19.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9]{1,19}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="StringLength1to64">
        <xs:annotation>
            <xs:documentation xml:lang="en">Used for Character Strings, length 1 to 64</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="64"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="UpperCaseAlphaLength1to2">
        <xs:annotation>
            <xs:documentation xml:lang="en">Used for an Alpha String, length 2 (for letter codes)</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-Z]{1,2}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="StringLength1to32">
        <xs:annotation>
            <xs:documentation xml:lang="en">Used for Character Strings, length 1 to 32</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="32"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="OTA_CodeType">
        <xs:annotation>
            <xs:documentation xml:lang="en">Used for codes in the OTA code tables. Possible values of this pattern are 1, 101, 101.EQP, or 101.EQP.X.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9A-Z]{1,3}(\.[A-Z]{3}(\.X){0,1}){0,1}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="NumericStringLength1to8">
        <xs:annotation>
            <xs:documentation xml:lang="en">Used for Numeric Strings, length 1 to 8.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9]{1,8}"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>