xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MIDON ALEXIS <ALEXIS.MI...@sgam.com>
Subject XmlValueNotNillableException
Date Tue, 27 Jul 2004 16:53:08 GMT
 
Hello,
 
my schema defines an AddressInfo element. All the sub elements (streetname,
cityname, etc.) are optional.
 
I map this element with an AddressDTO as shown in the following code :
 
 
public static AddressInfo createAddress(AddressDTO dto) {
      AddressInfo address = AddressInfo.Factory.newInstance();

 
      address.setStreetName(dto.getAddress());
      address.setCityName(dto.getCity());
      address.setPostalCode(dto.getZipCode());

      return address;
 }
 
To that point I make no assumptions on the dto field value, ie the getters
could return null (this is the reason why tags are optional)
 
Unfortunately this code throws an unknown (i didn't find out any javadocs)
and unchecked exception :
org.apache.xmlbeans.impl.values.XmlValueNotNillableException
 
My biz fails due to this exception. :(
 
Is it a bug? a bad practice? Did I miss something?
 
Should I test every nullable value before setting the XMLObject ?
 
ex :
      if(dto.getAddress()!=null)
            address.setStreetName(dto.getAddress());
      if(dto.getCityName()!=null)
          address.setCityName(dto.getCity());
      if(dto.getPostalCode()!=null)
          address.setPostalCode(dto.getZipCode());
 
 
 
Thx for your help.
 
 
Alexis

Mime
View raw message