JAXB xjc expected element of type …


If you have trouble loading Xml using classes generated by xjc tool (included in JAXB distribution), be carefull and do not define XSD main element like this:

<!-- MAIN element -->
<xs:element name="main" type="Main">
<xs:complexType name="Main">
...

The problem here is that the main element and main element type names are identical (except the first letter that is uppercased). Xjc creates a class for for both root Xml element and all complex types defined in Xsd. In this case a java class that derives from class for xsd complexType would be empty. If you still insist on having java class for xml root element then declare it as a extension without any additions.

Solutions (2):

  • declare xml root element as complexType extension (complexContent/complextType/extension) of the xsd complexType
  • do not define type for root element and define the structure directly in xs:element
pošli na vybrali.sme.sk

, , , , , , ,

  1. No comments yet.
(will not be published)

Blue Captcha Image
Refresh

*