如何创建一个对Swift XSD有效的XML文件?

时间:2016-09-02 09:12:35

标签: xml xsd xsd-validation xml-validation

我有一个XSD文件,我必须针对生成的XML文件验证该文件。我试图创建大量的XML文件,但没有文件与给定的XSD匹配。任何人都可以建议与给定的XSD文件匹配的正确XML文件吗?

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:info="urn:swift:xsd:appInfo" xmlns="urn:swift:xsd:fin.760.2016" targetNamespace="urn:swift:xsd:fin.760.2016" elementFormDefault="qualified">
    <xs:element name="Document" type="Document"/>
    <xs:complexType name="MTMessage" abstract="true"/>
    <xs:complexType name="ISO15022Message" abstract="true"/>
    <xs:complexType name="SystemMessage" abstract="true"/>
    <xs:complexType name="Sequence" abstract="true"/>
    <xs:complexType name="Choice" abstract="true"/>
    <xs:complexType name="MTField" abstract="true"/>
    <xs:complexType name="ISO15022Field" abstract="true"/>
    <xs:complexType name="QualifierGroup" abstract="true"/>
    <xs:complexType name="Qualifier" abstract="true"/>
    <xs:complexType name="FieldOption" abstract="true"/>
    <xs:complexType name="ComplexDataType" abstract="true"/>
    <xs:complexType name="ChoiceDataType" abstract="true"/>
    <xs:complexType name="Document">
        <xs:sequence>
            <xs:element name="MT760" type="MT760_Type">
                <xs:annotation>
                    <xs:documentation source="Name" xml:lang="EN">Guarantee/Standby Letter of Credit</xs:documentation>
                    <xs:documentation source="Definition" xml:lang="EN">Scope
This message is sent between banks involved in the issuance of a guarantee.It is used to issue a guarantee or to request the Receiver to issue a guarantee.This message may also be used for Standby Letters of Credit.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="MT760_Type">
        <xs:complexContent>
            <xs:extension base="MTMessage">
                <xs:sequence>
                    <xs:element name="F27a" type="MT760_F27a_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Sequence of Total</xs:documentation>
                            <xs:documentation source="Definition" xml:lang="EN">This field specifies the number of this message in the series of messages sent for a guarantee, and the total number of messages in the series.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="F20a" type="MT760_F20a_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Transaction Reference Number</xs:documentation>
                            <xs:documentation source="Definition" xml:lang="EN">When the message is sent to issue a guarantee, this field must specify the guarantee number.When the message is sent to request the Receiver to issue a guarantee, this field must contain the reference of the request, as assigned by the Sender.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="F23a" type="MT760_F23a_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Further Identification</xs:documentation>
                            <xs:documentation source="Definition" xml:lang="EN">This field further identifies the purpose of the message.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="F30a" type="MT760_F30a_Type" minOccurs="0">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Date</xs:documentation>
                            <xs:documentation source="Definition" xml:lang="EN">When the message is sent to issue a guarantee, this field specifies the issue date of the guarantee.When the message is sent to request the Receiver to issue a guarantee, this field specifies the date of the request.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="F40a" type="MT760_F40a_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Applicable Rules</xs:documentation>
                            <xs:documentation source="Definition" xml:lang="EN">This field specifies the rules the guarantee is subject to. Unless otherwise specified in field 77C, it is also the rules the counter-guarantee is subject to.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="F77a" type="MT760_F77a_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Details of Guarantee</xs:documentation>
                            <xs:documentation source="Definition" xml:lang="EN">This field contains all terms, conditions and details of the guarantee.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="F72a" type="MT760_F72a_Type" minOccurs="0">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Sender to Receiver Information</xs:documentation>
                            <xs:documentation source="Definition" xml:lang="EN">This field contains additional information for the Receiver.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MT760_F27a_Type">
        <xs:complexContent>
            <xs:extension base="MTField">
                <xs:choice>
                    <xs:element name="F27" type="F27_1_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="27"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Number - Total</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MT760_F20a_Type">
        <xs:complexContent>
            <xs:extension base="MTField">
                <xs:choice>
                    <xs:element name="F20" type="F20_2_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="20"/>
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MT760_F23a_Type">
        <xs:complexContent>
            <xs:extension base="MTField">
                <xs:choice>
                    <xs:element name="F23" type="F23_50_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="23"/>
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MT760_F30a_Type">
        <xs:complexContent>
            <xs:extension base="MTField">
                <xs:choice>
                    <xs:element name="F30" type="F30_1_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="30"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Date</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MT760_F40a_Type">
        <xs:complexContent>
            <xs:extension base="MTField">
                <xs:choice>
                    <xs:element name="F40C" type="F40C_2_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="40C"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Type - Narrative</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MT760_F77a_Type">
        <xs:complexContent>
            <xs:extension base="MTField">
                <xs:choice>
                    <xs:element name="F77C" type="F77C_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="77C"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Narrative</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MT760_F72a_Type">
        <xs:complexContent>
            <xs:extension base="MTField">
                <xs:choice>
                    <xs:element name="F72" type="F72_162_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:Tag value="72"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Narrative</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:choice>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="F27_1_Type">
        <xs:complexContent>
            <xs:extension base="FieldOption">
                <xs:sequence>
                    <xs:element name="Number" type="Quantity_FIN_1En_Type">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:SepSuffix value="/"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Number</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="Total" type="Quantity_FIN_1En_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Total</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:simpleType name="F20_2_Type">
        <xs:restriction base="Text_FIN_16x_Type"/>
    </xs:simpleType>
    <xs:simpleType name="F23_50_Type">
        <xs:restriction base="Text_FIN_16x_Type"/>
    </xs:simpleType>
    <xs:simpleType name="F30_1_Type">
        <xs:annotation>
            <xs:documentation source="Name" xml:lang="EN">Date</xs:documentation>
        </xs:annotation>
        <xs:restriction base="DateTime_YYMMDD_Type"/>
    </xs:simpleType>
    <xs:complexType name="F40C_2_Type">
        <xs:complexContent>
            <xs:extension base="FieldOption">
                <xs:sequence>
                    <xs:element name="Type" type="Code_4Ea_14_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Type</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="Narrative" type="Text_FIN_35x_Type" minOccurs="0">
                        <xs:annotation>
                            <xs:appinfo>
                                <info:SepPrefix value="/"/>
                            </xs:appinfo>
                            <xs:documentation source="Name" xml:lang="EN">Narrative</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="F77C_Type">
        <xs:complexContent>
            <xs:extension base="FieldOption">
                <xs:sequence>
                    <xs:element name="Narrative" type="Text_FIN_150M65x_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Narrative</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="F72_162_Type">
        <xs:complexContent>
            <xs:extension base="FieldOption">
                <xs:sequence>
                    <xs:element name="Narrative" type="Text_FIN_6M35x_1_Type">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Narrative</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:simpleType name="Quantity_FIN_1En_Type">
        <xs:annotation>
            <xs:appinfo>
                <info:MetaType value="Quantity"/>
                <info:FinFormat value="1!n"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="1"/>
            <xs:pattern value="[0-9]"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Text_FIN_16x_Type">
        <xs:annotation>
            <xs:appinfo>
                <info:MetaType value="Text"/>
                <info:FinFormat value="16x"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="16"/>
            <xs:pattern value="[0-9a-zA-Z/\-\?:\(\)\.,&apos;\+ ]{1,16}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="DateTime_YYMMDD_Type">
        <xs:annotation>
            <xs:appinfo>
                <info:MetaType value="DateTime"/>
                <info:FinFormat value="YYMMDD"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="6"/>
            <xs:maxLength value="6"/>
            <xs:pattern value="[0-9]{6}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Code_4Ea_14_Type">
        <xs:restriction base="Text_4Ea_Type">
            <xs:enumeration value="ISPR">
                <xs:annotation>
                    <xs:documentation source="Definition" xml:lang="EN">The guarantee is subject to International Standby Practices</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="NONE">
                <xs:annotation>
                    <xs:documentation source="Definition" xml:lang="EN">The guarantee is not subject to any rules</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="OTHR">
                <xs:annotation>
                    <xs:documentation source="Definition" xml:lang="EN">The guarantee is subject to another set of rules, which must be specified in Narrative (2nd subfield)</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="URDG">
                <xs:annotation>
                    <xs:documentation source="Definition" xml:lang="EN">The guarantee is subject to the ICC Uniform Rules for Demand Guarantees</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Text_FIN_35x_Type">
        <xs:annotation>
            <xs:appinfo>
                <info:MetaType value="Text"/>
                <info:FinFormat value="35x"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="35"/>
            <xs:pattern value="[0-9a-zA-Z/\-\?:\(\)\.,&apos;\+ ]{1,35}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="Text_FIN_150M65x_Type">
        <xs:complexContent>
            <xs:extension base="ComplexDataType">
                <xs:sequence>
                    <xs:annotation>
                        <xs:appinfo>
                            <info:Separator value="&#x0d;&#x0a;"/>
                        </xs:appinfo>
                        <xs:documentation source="Name" xml:lang="EN">Line</xs:documentation>
                    </xs:annotation>
                    <xs:element name="Line" type="Text_FIN_65x_Type" maxOccurs="150">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Line</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="Text_FIN_6M35x_1_Type">
        <xs:complexContent>
            <xs:extension base="ComplexDataType">
                <xs:sequence>
                    <xs:annotation>
                        <xs:appinfo>
                            <info:Separator value="&#x0d;&#x0a;"/>
                        </xs:appinfo>
                        <xs:documentation source="Name" xml:lang="EN">Line</xs:documentation>
                    </xs:annotation>
                    <xs:element name="Line" type="Text_FIN_35x_Type" maxOccurs="6">
                        <xs:annotation>
                            <xs:documentation source="Name" xml:lang="EN">Line</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:simpleType name="Text_4Ea_Type">
        <xs:annotation>
            <xs:appinfo>
                <info:MetaType value="Code"/>
                <info:FinFormat value="4!a"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="4"/>
            <xs:maxLength value="4"/>
            <xs:pattern value="[A-Z]{4}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="Text_FIN_65x_Type">
        <xs:annotation>
            <xs:appinfo>
                <info:MetaType value="Text"/>
                <info:FinFormat value="65x"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:minLength value="1"/>
            <xs:maxLength value="65"/>
            <xs:pattern value="[0-9a-zA-Z/\-\?:\(\)\.,&apos;\+ ]{1,65}"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

2 个答案:

答案 0 :(得分:1)

以下是oXygen XML Editor为您发布的Swift XSD生成的有效XML实例:

config.action_cable.url = 'ws://server_name.com/cable'

开发人员可能会使用这样一个合成生成的XML文档来启动更有意识的手动创建XML,以满足更具体的目的。

答案 1 :(得分:0)

通过此http://xsd2xml.com/运行您的XSD并获得

 <?xml version="1.0" encoding="utf-8"?>
    <Document>
      <MT760>
        <F27a />
        <F20a />
        <F23a />
        <F30a />
        <F40a />
        <F77a />
        <F72a />
      </MT760>
    </Document>