jaxb-ri icon indicating copy to clipboard operation
jaxb-ri copied to clipboard

JXC ignores mixed=true, fails to generate XmlMixed/getContents

Open Tomas-Kraus opened this issue 14 years ago • 9 comments

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:

Title

I will attach a zip file containing the schema, xml, and the generated classes.

Environment

Operating System: All Platform: All

Affected Versions

[2.2]

Tomas-Kraus avatar Nov 04 '10 13:11 Tomas-Kraus

  • Issue Imported From: https://github.com/javaee/jaxb-v2/issues/792
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @glassfishrobot

Tomas-Kraus avatar Sep 21 '18 16:09 Tomas-Kraus

@glassfishrobot Commented Reported by kibab

Tomas-Kraus avatar Nov 04 '10 13:11 Tomas-Kraus

@glassfishrobot Commented kibab said: Created an attachment (id=373) Zip containing schema, xml, and XJC generated files

Tomas-Kraus avatar Nov 04 '10 13:11 Tomas-Kraus

@glassfishrobot Commented @pavelbucek said: metro2.1-waived

Tomas-Kraus avatar Nov 19 '10 09:11 Tomas-Kraus

@glassfishrobot Commented File: so2.zip Attached By: kibab

Tomas-Kraus avatar Nov 04 '10 13:11 Tomas-Kraus

@glassfishrobot Commented Was assigned to snajper

Tomas-Kraus avatar Nov 04 '10 13:11 Tomas-Kraus

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-792

Tomas-Kraus avatar Apr 24 '17 12:04 Tomas-Kraus

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.

anitakurz avatar Aug 19 '21 08:08 anitakurz

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.

subigre avatar Apr 12 '23 07:04 subigre