• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

null values in castor unmarshalling

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm using castor to unmarshall xml to java objects. The only problem is that I'm not able to get null values...
In the xsd the element is nillable
<xs:element name="OC" type="xs ouble" nillable="true"/>
and in the castor mapping file I defined the type as object, not a primitive
<field name="OC" type="java.lang.Double" required="false" direct="false" transient="false">
<bind-xml name="OC" node="element" reference="false"/>
</field>
In addition, I validate using the schema to unmarshal.setValidation("true");

If my xml does not have a tag, then this is field is null. But if the tag is empty (<OC></OC> then I get a Double with value 0.
Any idea how I can get null if the tag is sent?
Thanks
 
I found some pretty shells, some sea glass and this lovely tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic