验证xml.violate“独特粒子归因”

时间:2014-11-05 10:24:40

标签: xml validation xslt xsd

我的验证有问题。

我有简单的xml:

<AppData xmlns="http://smev.gosuslugi.ru/rev120315">
    <Data>
        <RelocationType>1</RelocationType>
        <DocNumber>RU/2013/2-68</DocNumber>
        <IssueDate>2013-01-31T00:00:00</IssueDate>
        <Format>1</Format>
    </Data>
</AppData>

我有XSD计划:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ns1="http://smev.gosuslugi.ru/rev120315" xmlns:ns2="http://www.w3.org/2004/08/xop/include"
    targetNamespace="http://smev.gosuslugi.ru/rev120315" elementFormDefault="qualified">
    <xsd:group name="group1">
        <xsd:sequence>
            <xsd:sequence>
                <xsd:element name="RelocationType" type="xsd:int" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="DocNumber" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                <xsd:element name="IssueDate" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
                <xsd:element name="Format" type="xsd:int" minOccurs="1" maxOccurs="1"/>
            </xsd:sequence>
        </xsd:sequence>
    </xsd:group>
    <xsd:group name="group2">
        <xsd:sequence>
            <xsd:element name="Certificate" type="ns1:Certificate" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:group>
    <xsd:group name="group3">
        <xsd:sequence>
            <xsd:element name="RelocationType" type="xsd:int" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="Category" type="xsd:int" nillable="true" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="LastUpdate" type="xsd:dateTime" nillable="true" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:group>
    <xsd:group name="group4">
        <xsd:sequence>
            <xsd:element name="Certificates" type="ns1:ArrayOfCertificate" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:group>
    <xsd:group name="group5">
        <xsd:sequence> </xsd:sequence>
    </xsd:group>
    <xsd:group name="group6">
        <xsd:sequence>
            <xsd:element name="Items" type="ns1:ArrayOfCategoryItem" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:group>
    <xsd:element name="AppData" type="ns1:AppDataType"/>
    <xsd:complexType name="AppDataType">
        <xsd:sequence>
            <xsd:element name="Data" type="ns1:DataType"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="DataType">
            <xsd:choice maxOccurs="unbounded" minOccurs="0">
                <xsd:group ref="ns1:group1"/>
                <xsd:group ref="ns1:group2"/>
                <xsd:group ref="ns1:group3"/>
                <xsd:group ref="ns1:group4"/>
                <xsd:group ref="ns1:group5"/>
                <xsd:group ref="ns1:group6"/>
            </xsd:choice>
    </xsd:complexType>
    <xsd:complexType name="Certificate">
        <xsd:sequence>
            <xsd:element name="RelocationType" type="xsd:int" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="DocNumber" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="IssueDate" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="IssuedByOrg" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="IssuedByPerson" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="IsTemporary" type="xsd:boolean" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="Period" type="ns1:Period" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Items" type="ns1:ArrayOfItem" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ExportData" type="ns1:ExportData" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ImportData" type="ns1:ImportData" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Country" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="HasImage" type="xsd:boolean" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="LastUpdate" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Period">
        <xsd:sequence>
            <xsd:element name="From" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="To" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ArrayOfItem">
        <xsd:sequence>
            <xsd:element name="Item" type="ns1:Item" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ExportData">
        <xsd:sequence>
            <xsd:element name="DocOwnerName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="DocOwnerAddress" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Purpose" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Reason" type="xsd:string" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ImportData">
        <xsd:sequence>
            <xsd:element name="DocOwnerName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="DocOwnerAddress" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="DocOwnerInn" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ReceiverName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ReceiverAddress" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ReceiverInn" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ContractNumber" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ContractDate" type="xsd:dateTime" nillable="true" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="AgreementSection" type="xsd:string" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Item">
        <xsd:sequence>
            <xsd:element name="Category" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Quantity" type="xsd:float" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="MeasureUnitId" type="xsd:int" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ArrayOfCertificate">
        <xsd:sequence>
            <xsd:element name="Certificate" type="ns1:Certificate" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="GetCategoriesRequestAppData"/>
    <xsd:complexType name="ArrayOfCategoryItem">
        <xsd:sequence>
            <xsd:element name="CategoryItem" type="ns1:CategoryItem" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="CategoryItem">
        <xsd:sequence>
            <xsd:element name="CategoryId" type="xsd:int" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="Name" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ParentId" type="xsd:int" nillable="true" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

但在验证后我有错误:

  

E [Xerces] cos-nonambig:   &#34; http://smev.gosuslugi.ru/rev120315&#34;:重定位类型和   &#34; http://smev.gosuslugi.ru/rev120315&#34;:重定位类型(或来自的元素)   他们的替代群体违反了“独特粒子归因”#34;   在针对此模式进行验证期间,将为其创建歧义   那两个粒子。

XML可以在不同的标签集中,但只有一个&#34; group1&#34;或&#34; group2&#34;等

1 个答案:

答案 0 :(得分:1)

我解决了这个问题。稍微重新安排了XSD架构,错误消失了,XML也得到了验证。 感谢在这里写评论然后删除它的人,但它帮助了我。 :)

XSD:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://smev.gosuslugi.ru/rev120315" xmlns:ns2="http://www.w3.org/2004/08/xop/include" targetNamespace="http://smev.gosuslugi.ru/rev120315" elementFormDefault="qualified">
    <xsd:element name="AppData" type="ns1:AppDataType"/>
    <xsd:complexType name="AppDataType">
        <xsd:sequence>
            <xsd:element name="Data" type="ns1:DataType"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="DataType">
        <xsd:choice maxOccurs="1" minOccurs="1">
            <xsd:sequence>
                <xsd:element name="RelocationType" type="xsd:int" minOccurs="1" maxOccurs="1"/>
                <xsd:choice>
                    <xsd:sequence>
                        <xsd:element name="DocNumber" type="xsd:string" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="IssueDate" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
                        <xsd:element name="Format" type="xsd:int" minOccurs="1" maxOccurs="1"/>
                    </xsd:sequence>
                    <xsd:sequence>
                        <xsd:element name="Category" type="xsd:int" nillable="true" minOccurs="1" maxOccurs="1"/>
                        <xsd:element name="LastUpdate" type="xsd:dateTime" nillable="true" minOccurs="1" maxOccurs="1"/>
                    </xsd:sequence>
                </xsd:choice>
            </xsd:sequence>
            <xsd:sequence>
                <xsd:element name="Certificate" type="ns1:Certificate" minOccurs="0" maxOccurs="1"/>
            </xsd:sequence>
            <xsd:sequence>
                <xsd:element name="Certificates" type="ns1:ArrayOfCertificate" minOccurs="0" maxOccurs="1"/>
            </xsd:sequence>
            <xsd:sequence> </xsd:sequence>
            <xsd:sequence>
                <xsd:element name="Items" type="ns1:ArrayOfCategoryItem" minOccurs="0" maxOccurs="1"/>
            </xsd:sequence>
        </xsd:choice>
    </xsd:complexType>
    <xsd:complexType name="Certificate">
        <xsd:sequence>
            <xsd:element name="RelocationType" type="xsd:int" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="DocNumber" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="IssueDate" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="IssuedByOrg" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="IssuedByPerson" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="IsTemporary" type="xsd:boolean" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="Period" type="ns1:Period" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Items" type="ns1:ArrayOfItem" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ExportData" type="ns1:ExportData" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ImportData" type="ns1:ImportData" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Country" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="HasImage" type="xsd:boolean" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="LastUpdate" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Period">
        <xsd:sequence>
            <xsd:element name="From" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="To" type="xsd:dateTime" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ArrayOfItem">
        <xsd:sequence>
            <xsd:element name="Item" type="ns1:Item" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ExportData">
        <xsd:sequence>
            <xsd:element name="DocOwnerName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="DocOwnerAddress" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Purpose" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Reason" type="xsd:string" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ImportData">
        <xsd:sequence>
            <xsd:element name="DocOwnerName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="DocOwnerAddress" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="DocOwnerInn" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ReceiverName" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ReceiverAddress" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ReceiverInn" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ContractNumber" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ContractDate" type="xsd:dateTime" nillable="true" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="AgreementSection" type="xsd:string" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Item">
        <xsd:sequence>
            <xsd:element name="Category" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="Quantity" type="xsd:float" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="MeasureUnitId" type="xsd:int" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ArrayOfCertificate">
        <xsd:sequence>
            <xsd:element name="Certificate" type="ns1:Certificate" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="GetCategoriesRequestAppData"/>
    <xsd:complexType name="ArrayOfCategoryItem">
        <xsd:sequence>
            <xsd:element name="CategoryItem" type="ns1:CategoryItem" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="CategoryItem">
        <xsd:sequence>
            <xsd:element name="CategoryId" type="xsd:int" minOccurs="1" maxOccurs="1"/>
            <xsd:element name="Name" type="xsd:string" minOccurs="0" maxOccurs="1"/>
            <xsd:element name="ParentId" type="xsd:int" nillable="true" minOccurs="1" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>