问题
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