You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-user@xml.apache.org by MIDON ALEXIS <AL...@sgam.com> on 2004/07/27 18:53:08 UTC

XmlValueNotNillableException

 
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