I experience difficulties with abstract ComplexType in JAXB 1.0 FCS, in
that the XML instance document was considered wrong by the JAXB
implementation, while other XML tools (XMLSpy e.g.) find it valid XML.
The schema is:
<xsd:complexType name="log-handler" abstract="true">
<xsd:choice minOccurs="0">
<xsd:element name="level-filter" type="buzz:level-filter"/>
<!-- more filters in the future -->
</xsd:choice>
<xsd:attribute name="level" type="buzz:log-level" default="ALL"/>
<xsd:attribute name="encoding" type="xsd:NCName"/>
<xsd:attribute name="formatter" default="simple">
<xsd:simpleType>
<xsd:restriction base="xsd:NCName">
<xsd:enumeration value="simple"/>
<xsd:enumeration value="xml"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
<xsd:simpleType name="log-level">
<xsd:restriction base="xsd:Name">
<xsd:enumeration value="SEVERE"/>
...
<xsd:enumeration value="ALL"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="console-handler">
<xsd:complexContent>
<xsd:extension base="buzz:log-handler"/>
</xsd:complexContent>
</xsd:complexType>
The part of the instance document resulting in an validation exception
is:
<logger level="WARNING">
<console-handler level="INFO"/>
</logger>
If I change this part into, it seems to work again:
<logger level="WARNING">
<console-handler/>
</logger>
The exception is:
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[com.sun.msv.verifier.ValidityViolation: unexpected attribute "level"]
at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalExcept
ion(AbstractUnmarshallerImpl.java:306)
Another issue I find problamatic is that it is most of the time a hell
of a job to locate validation problems based on the message in the
exception, will this be improved in the future, an indication of the
linenumber would be a big help.
Is what I'm experiencing a bug or am I just overlooking something, at
least xjc doesn't complain and in the early access this worked (other
things not with types extending abstract types).
--
Mark Brouwer