problem with usage=optional and a specified format --------------------------------------------------
Key: JIBX-308 URL: http://jira.codehaus.org/browse/JIBX-308 Project: JiBX Issue Type: Bug Components: core Affects Versions: JiBX 1.2.1 Environment: Redhat, JBoss 4.2.2 Reporter: Todd Gould 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" serializer="ConversionUtils.serializeYesNoBoolean" deserializer="ConversionUtils.deserializeYesNoBoolean"/> I then reference the format in my mapping as follows: <value style="element" name="isGateway" get-method="isGateway" set-method="setGateway" format="yesNoBoolean" usage="optional"/> 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. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ _______________________________________________ jibx-devs mailing list jibx-devs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-devs