users@jaxb.java.net

Re: Marshalled XML from type extensions

From: Franklin, Brian <brian.franklin_at_ciraden.com>
Date: Tue, 06 May 2003 13:44:35 -0400

Unfortunately, the reference implementation does not yet support type or
element substitution (see section E.2.2 in the JAXB Spec).

This topic has been discussed on this list in the past, I believe, but the
most recent information relating to it comes from a community chat not too
long ago, which you can find at
http://developer.java.sun.com/developer/community/chat/JavaLive/2003/jl0422.
html .

Here is an excerpt from that chat:
-----
CyberCerberus: What are the plans, if any, for adding type substitution to
JAXB? This is a very important feature that would enable much more advanced
applications of JAXB.

Sekhar Vajjhala: We will be addressing support for type and element
substitution in the next version of the specification. We are very aware
that these are important features. The only reason JAXB 1.0 did not require
support for them was to enable the specification to be completed in a timely
fashion.
-----

As far as I know, there are no easy workarounds, other than to use <any> in
your schema, which of course loses type safety, and then handle type
checking and conversion in your application.

Hope that helps.

Brian Franklin

-----Original Message-----
From: Allister Bertram [mailto:abertram_at_CHECKFREE.COM]
Sent: Tuesday, May 06, 2003 1:15 PM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Marshalled XML from type extensions


Has anyone implemented JAXB against a schema which uses type extensions,
where the instance document marshalled under JAXB includes the required type
attribute, indicating the appropriate extension type for the element?

I have in my Schema a type "BusinessContactType" which is an extension of
"ContactType". When I marshal to Xml, I expect to see in my instance
document

<ContactElement type="ns1:BusinessContactType">

but all I see is

<ContactElement>

with all of the sub-elements of BusinessContactType marshalled within the
ContactElement.

The instance document isn't valid unless the type is specified. Has anyone
managed to develop a working implementation of such a schema?