jaxb-ri
jaxb-ri copied to clipboard
JXC ignores mixed=true, fails to generate XmlMixed/getContents
I'm aware of issue eclipse-ee4j/jaxb-api#244 and believe this is a distinct issue.
I have a schema that I cannot change that uses inheritance and mixed="true" as a way to accept character content. XJC (in 2.1 and 2.2) fails to generate an accessor that makes the character data available. I expect to see an XmlMixed annotation or a getContents() accessor, but neither are present.
Consider the following schema (a minimized test case):
<xs:schema targetNamespace="urn:org:test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:org:test" elementFormDefault="qualified">
<xs:complexType name="ST" mixed="true"> xs:complexContent <xs:restriction base="ED"> xs:sequence <xs:element name="reference" type="xs:string" minOccurs="0" maxOccurs="0"/> <xs:element name="thumbnail" type="xs:string" minOccurs="0" maxOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType>
<xs:complexType name="ED" mixed="true"> xs:complexContent <xs:extension base="BIN"> xs:sequence <xs:element name="reference" type="xs:string" minOccurs="0" maxOccurs="1" /> <xs:element name="thumbnail" minOccurs="0" maxOccurs="1" type="xs:string" /> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType>
<xs:complexType name="BIN" abstract="true" mixed="true"> xs:complexContent <xs:extension base="ANY"/> </xs:complexContent> </xs:complexType>
<xs:complexType name="ANY" abstract="true"> <xs:attribute name="nullFlavor" type="xs:string" use="optional" /> </xs:complexType>
<xs:element name="title" type="ST" /> </xs:schema>
With the above schema it is impossible to access the character data "Title" in the following XML:
I will attach a zip file containing the schema, xml, and the generated classes.
Environment
Operating System: All Platform: All
Affected Versions
[2.2]
- Issue Imported From: https://github.com/javaee/jaxb-v2/issues/792
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @glassfishrobot
@glassfishrobot Commented Reported by kibab
@glassfishrobot Commented kibab said: Created an attachment (id=373) Zip containing schema, xml, and XJC generated files
@glassfishrobot Commented @pavelbucek said: metro2.1-waived
@glassfishrobot Commented File: so2.zip Attached By: kibab
@glassfishrobot Commented Was assigned to snajper
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-792
If someone has still problems with this: A workaround for me was to create a type ANYMixed
that is a copy of ANY
just with mixed="true"
and change BIN
to extend ANYMixed
instead of ANY
.
Thanks for the tip @anitakurz 👍
I was trying to migrate an old application that still used an old version of JAXB and custom XJC binding with generateMixedExtensions="true"
to the latest version.
It is unfortunate that we have to modify the HL7 schemas even though there are not changing since a wild.