-
Notifications
You must be signed in to change notification settings - Fork 119
Description
I currently hit a "bug" that really gives me a hard time to figure out:
If one reads a document and an element has xsi:nil
set, this results in this element never changing its value.
This is because jakarta.xml.bind.JAXBElement.isNil()
returns true
whenever value is null
or nil
is true.
Now assume you de-serialize a document with something like:
<S xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
then call JAXBElement.setValue("balbla")
with a non null
value then isNil
will return still true
but the serializer writes it out as <S>balbla</S>
(what is of course desired!)
I have no good idea how to really mitigate this, but it makes the method JAXBElement.isNil()
almost useless to be used in client code, because:
- either
nil
isfalse
in which case it returntrue
if the value isnull
- if
nil
istrue
it always returntrue
regardless of what thevalue
is
So from a code point of view I can of course write the value but the result is actually dependent on if the value is non null when serialize it. Reading the value on the other hand gives me nothing, as it reflects not the value of the attribute, so actually everywhere i would need to use JAXBElement#getValue
anyways to be really sure what the outcome will be.