Your XML as posted has two preliminary problems ahead of the error message you've posted:
Change
xmlns:xsi = "https://www.w3.org/2001/XMLSchema-instance"
to
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
Change
xsi:schemaLocation = "main.xsd"
to
xsi:schemaLocation = "http://www.example.com main.xsd"
Now, your posted XML and XSD actually will be in a state to exhibit your posted problem:
[Error] main.xml:4:13: cvc-complex-type.2.4.a: Invalid content was
found starting with element 'personal'. One of '{personal}' is
expected.
Explanation: This error is telling you that personal
is expected to be in no namespace according to your XSD; the {
and }
in One of '{personal}' is expected
indicates this.
You might think that since your XSD declares targetNamespace="http://www.example.com"
that all of its components are thus placed into the http://www.example.com
namespace. This is not true of locally declared components, however unless you set elementFormDefault="qualified"
-- the default is unqualified
.
Locally declared elements are in no namespace by default
Therefore, make one last change: Add
elementFormDefault="qualified"
to the xsd:schema
element, and then your XML valid against your XSD.
See also this answer about what elementFormDefault means.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…