Resolution: Not A Bug
Affects Version/s: JiBX 1.2.1
Fix Version/s: None
Environment:Redhat, JBoss 4.2.2
Number of attachments :
I have a document that requires serialization of boolean values
in a 'yes' and 'no' format. I have defined a format in my
binding.xml as follows to accomplish this trivial conversion:
<format type="boolean" label="yesNoBoolean"
I then reference the format in my mapping as follows:
<value style="element" name="isGateway"
When I test a test-case input document via the JiBX roundtrip or
my own JUnit test case this works just fine if (and only if) the
underlying boolean is true. As soon as I test with a false
value, the serialization process no longer creates the associated
element. I presume that this may be some sort of optimization on
part of the usage="optional" attribute attempting to optimize the
output or something? However, this causes the roundtrip to fail
as well as my JUnit test case which are both expecting to see the
attribute with a specified value.
I have debuged the yesNoBoolean serializer and deserializers and
have therefore verified that the serializers are never called
when the underlying value is false (only when true) and that they
are performing as would be expected otherwise and without failure.
I also tried specifying a default="no" on the format. While this
did not produce any errors in and of itself, it also did not fix
the roundtrip or JUnit test case failures.
Finally, and most telling, if I remove the usage="optional" from
the value statement in the mapping, all works fine and as
expected. However, this is not what I need, as this element
value is truly optional.
Is this a known feature/bug relative to the combination of format
and optional values? Am I missing something else? Is there a
way to achieve the truly optional behavior for the value, while
using the yeNoBoolean format.