I have a schema with targetNamespace and unqualified element form default:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://shiporder.hu/Shiporder"
xmlns="http://shiporder.hu/Shiporder"
elementFormDefault="unqualified">
<xs:complexType name="shipordertype">
<xs:sequence>
<xs:element name="orderid" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="shiporder" type="shipordertype" />
</xs:schema>
I do not understand why the following instance is invalid:
<?xml version="1.0" encoding="UTF-8"?>
<shiporder
xmlns="http://shiporder.hu/Shiporder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://shiporder.hu/Shiporder shiporder_unqualified.xsd">
<orderid>123456</orderid>
</shiporder>
Jaxb validation says that "Invalid content was found starting with element 'orderid'. One of '{orderid}' is expected." I am particularly puzzled by this message, if "orderid" is expected, then what's the problem with "orderid"?
This is the validation error:
org.xml.sax.SAXParseException; systemId: file:/home/riskop/git/xml_schema_elementformdefault_question/src/main/resources/order_unqualified_with_default_ns.xml; lineNumber: 6; columnNumber: 12; cvc-complex-type.2.4.a: Invalid content was found starting with element 'orderid'. One of '{orderid}' is expected. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) at ...
I have a little demo on github:
https://github.com/riskop/xml_schema_elementformdefault_question.git