cvc-complex-type.2.4.a: Invalid content was found starting with element

雨燕双飞 提交于 2020-01-07 06:24:48

问题


Got [Invalid content] error:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'AGMT_NUMBER'
One of '{'http://www.mycompany.com/xmlns/commonDefintions":AGMT_NUMBER}' is expected.

I have two xsd files which are suppose to validate following xml file

myFile.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TEST_FILE>
    <ROW>
         <AGMT_NUMBER>1234</AGMT_NUMBER>
    </ROW>
</TEST_FILE>

This is my first xsd Main.XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"   
  xmlns:common="http://www.mycompany.com/xmlns/commonDefintions"  
  elementFormDefault="qualified">
    <xs:import schemaLocation="common.xsd" 
      namespace="http://www.mycompany.com/xmlns/commonDefintions"/>
    <xs:element name="TEST_FILE">
        <xs:complexType>
            <xs:choice>
                <xs:element ref="common:A"></xs:element>
            </xs:choice>
        </xs:complexType>
    </xs:element>
</xs:schema>

This is the xsd I am referring from common.xsd

    <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   targetNamespace="http://www.mycompany.com/xmlns/commonDefintions" 
   xmlns="http://www.mycompany.com/xmlns/commonDefintions" 
   elementFormDefault="qualified">


    <xs:element name="A" type="AgmtInfo"></xs:element>
    <xs:complexType name="AgmtInfo">
        <xs:sequence>
            <xs:element name="AGMT_NUMBER" type="xs:string"></xs:element>
        </xs:sequence>
    </xs:complexType>

</xs:schema>

来源:https://stackoverflow.com/questions/25532389/cvc-complex-type-2-4-a-invalid-content-was-found-starting-with-element

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!