Hi Archie,
It looks like you are talking about the following property
# Selects use of Object Wrappers instead of primitives (e.g java.lang.Float
# instead of float).
# False by default.
#
#org.exolab.castor.builder.primitivetowrapper=false
as defined in the default *castorbuilder.properties* file packaged with
the codegen JAR. As such I wonder whether you are using a mapping file
based approach for XML data binding, or whether you are starting with an
XML schema and generate Java code from it.
Having said that, let's look at this in a more general context. When an
XML schema defines an element (definition) as optional, the idea is that
it's use is optional; so it either will be present or it won't. Once it
is present in the corresponding XML document, it is assumed as present,
and a value will be 'deduced' during unmarshalling. If there's no value
(which obviously does *not* match your XML schema), a default value will
be 'injected' in the Java property that corresponds to your element
definition. For a primitive type (int, long, ....), this means that a
value of '0' will be set. For primitive wrappers I am not sure, but I
think that the same will happen, as your XML document instance actually
comes with the element being defined (though empty).
What does the element definition precisely look like ?
Werner
azimo wrote:
> Hi all,
>
> I have a schema which defines an element as optional. Sometimes this element
> is not present in the XML that I receive in which case Castor works just
> fine and the object generated in my Java code contains NULL for the given
> element. Sometimes however, the XML contains an empty start-end tag which
> (since my element is numeric) generates the default value of 0. Castor
> properties has the setting primitivestowrapper set to true so I would like
> NULL for this as well. Is there any way to make sure that Castor sees an
> empty start-end tag the same way as if it wasn't present at all??
>
> I've read the documentation and can't find it myself if there is.
>
> Thanks in advance,
>
> Archie
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email