You need to decide whether you think of XML as XML or whether you think of XML as a way to pass a Java (or other) object from here to it.
In XML, nillable enables the <myelement xsi:nil='true'/> construct as an indicator of an explicitly missing value, such as SQL NULL. This is semantically different from just <myelement/> . And both are different from nothing. Therefore, looking at XML, you should distinguish four cases:
<myElement attr1='true'>some content</myElement> <myElement/> <myElement xsi:nil='true'/>
If, on the other hand, you are primarily involved in Java - perhaps because you use SOAP, then you need to think about how the Java object moves back and forth.
For any Java element that inherits from Object, JAXB and other matching technologies need a way to handle null values. Nillable is a way to do this. If you refuse anything that might be an object, the tools will annoyingly use an array to find a way to represent the absence.
On the other hand, if you have an array, keep in mind that the array itself is an object and may be null. Thus, each toolkit should distinguish an array of zero elements from zero.
On the other hand, if you have a primitive type (e.g. int ), nillable will lead to problems because there is no mapping from xsi: nil to the primitive.
bmargulies Dec 14 '09 at 19:59 2009-12-14 19:59
source share