Very few data binding technologies will handle both minOccurs=0 and nillable="true" properly. Here is relevant comment form JAXB spec:
"A Java application does not need to distinguish between the absence of a element from the infoset and when the element occurred with nil content. Thus, in the interest of simplifying the generated API, methods were not provided to distinguish between the two."
I find this very unfortunate. Even if you use some cool xml-object binding technology that distinguishes these states, use of such scemas creates interopariblity problems. Majority of your clients (.NET or Java) out of the box will be unable to interpret your data properly.
Thanks
-gia
_____
From: Andreas.Ebbert_at_nokia.com [mailto:Andreas.Ebbert_at_nokia.com]
Sent: Wednesday, June 30, 2004 9:58 AM
To: users_at_jaxb.dev.java.net
Subject: optional and nillable elemens
Hi,
I asked this question also in todays BOF at JavaOne, but since I was in the back of the audience, my questions was probably not understood, or I have not understood the answer properly.
Anyways, this is the issue, what is the approach, how JAXB will (does?) handle elements in XML documents, that the XML Schema defines as minOccurs=0 and nillable=true. Examples of these schemas can be found in the OSS through Java Initiative:
http://java.sun.com/products/oss/xml/xml_schema_table.html
For an example of a complexType, which contains elements, which are optional and nillable, look in the Service Activation Schema (
http://java.sun.com/products/oss/xml/ServiceActivation/XmlServiceActivationSchema.xsd) for the complex type 'OrderValue'.
The business reason behind this is, that we have the use case of possibly transferring massives amount of data to the client. So the client can request which elements it would like to be returned, while these elements then still can be null.
My question is, if there is
* any understanding of this issue in the JAXB EG
* any idea how to make this information available in the Java Interface (we have the javax.oss.AttributeAccess interface defined in the OSS Common API (JSR 144) defined for that purpose)
* any guess, how difficult it would be to enhance the JAXB RI to generate code that matches this requirement
Thanks for your attention!
Andreas Ebbert
Software Design Engineer - Nokia Networks OSS
phone: +49-211-94123928, fax: +49-211-94123838
Heltorfer Straße 1, 40472 Düsseldorf, Germany
_____
This message is confidential. If you have received this message in error, please delete it from your system. You should not copy it for any purpose, or disclose its contents to any other person. Internet communications are not secure and therefore Nokia GmbH does not accept legal responsibility for the contents of this message as it has been transmitted over a public network. Thank you.
Nokia GmbH, Nokia Networks is a German Company. Further information about the Company is available from its principal offices at Heltorferstrasse 1, D-40472, Düsseldorf, Germany and from the website at
http://www.nokia.com/
_____