New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with abstract classes and @XMLValue #620
Comments
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented
|
@glassfishrobot Commented
|
@glassfishrobot Commented |
@glassfishrobot Commented still not foolproof, but it definitely should work for this kind of usages. |
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented |
@glassfishrobot Commented |
|
Problems with abstract classes and @XMLValue
JAXB 2.1.10
According to the following schema unmarshalling a valid XML results in an
java.lang.InstantiationException, caused by instancing the abstract class
TypeEnumeration.
<xsd:schema xmlns:mime="http://www.w3.org/2005/05/xmlmime"
xmlns="http://namespace" attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="http://namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="TypeEnumeration" abstract="true">
xsd:simpleContent
<xsd:extension base="xsd:string" />
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="TypeEnumerationBase">
xsd:simpleContent
<xsd:restriction base="TypeEnumeration">
<xsd:enumeration value="00">
xsd:annotation
xsd:documentationNone</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="01">
xsd:annotation
xsd:documentationFirst Element</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
<xsd:element name="SomeElement">
xsd:complexType
xsd:sequence
<xsd:element name="Type" type="TypeEnumeration" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Example XML:
<tns:SomeElement xmlns:tns="http://namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tns:Type xsi:type="tns:TypeEnumerationBase">01</tns:Type>
</tns:SomeElement>
Vice versa marshalling an Java object results in an invalid XML due to the given
01schema TypeEnumeration.xsd:
The abstract element Type is used, but I expected something like
01</ Type>.
I need to preserve the structure of inherence, due to be compatible to other
projects and data exchange.
Changing the @XMLValue Annotation to @XMLAttribute leads to the expected
behaviour. I get an element.
So inherence with @XMLValue fails …
Environment
Operating System: All
Platform: All
Affected Versions
[2.1.9]
The text was updated successfully, but these errors were encountered: