I am experiencing a problem when unmarshalling a document with an optional
field that is handled using a custom unmarshaller. The custom code is
unmarshalling a Calendar object. I have looked at using a Deserializer, but
need to write out the time in millis and a formatted string (used in xslt).
JiBX has no problems when the field is not present, but when it is found in the
xml I am getting the following exception:
Exception in thread "main" org.jibx.runtime.JiBXException: Expected "values"
end tag, found "optionalCal" start tag
My unmarshaller isn't doing anything special, it only uses the millis attribute
to set a Calendar object, and I am not having any problems when marshalling the
document whether the field is null or not.
My bind file is:
<binding>
<mapping name="root" class="TestRoot">
<collection factory="org.jibx.runtime.Utility.arrayListFactory"
field="values" item-type="OptionalField"/>
</mapping>
<mapping name="values" class="OptionalField">
<structure name="cal" field="cal"
marshaller="CalendarMapper" unmarshaller="CalendarMapper"/>
<structure name="optionalCal" usage="optional" field="optionalCal"
marshaller="CalendarMapper" unmarshaller="CalendarMapper"/>
</mapping>
<mapping class="java.util.Calendar" marshaller="CalendarMapper"
unmarshaller=CalendarMapper" />
</binding>
My input xml file is:
<root>
<values>
<cal millis="1128021806000">09/29/2005 15:23:26</cal>
</values>
<values>
<cal millis="1128021806000">09/29/2005 15:23:26</cal>
<optionalCal millis="1128021806000">09/29/2005 15:23:26</optionalCal>
</values>
</root>
I have tried both the RC1 and RC2 releases but found the same result each time.
Any suggestions would be much appreciated.
Thanks,
Eric
The information contained in this email message is intended only for the use of
the individuals to whom it is addressed and may contain information that is
privileged and sensitive. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have received this
communication in error, please notify the sender immediately by email at the
above referenced address. Thank you.