We use Dozer with XML Beans for converting XML documents (in a format of which we do not control the schema) to the DTO's required by our system.
This, for the most part, has worked out very well. We came across an issue (and it is an XmlBean'ism) with certain base xs:types.
Types such as xs:int and xs:boolean are generated by XML Beans as java primitives. See http://xmlbeans.apache.org/docs/2.0.0/guide/conXMLBeansSupportBuiltInSchemaTypes.html for some more info.
This means that when we map from the XML Beans, Dozer cannot tell the difference between the case that the value happens to be the default for the primitive (eg 0 for an int) or the element is not actually present.
XML Beans does generate an isSetXxxx method for every field.
Would it be possible to have Dozer check this method where it is provided and return null rather than the int value?
I've included some sample code and testcases below that seems to do the trick.
Note the use of XmlBeanPropertyDescriptor
Log in to post a comment.