xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Krouse" <kkro...@bea.com>
Subject RE: XmlValueNotNillableException
Date Tue, 27 Jul 2004 19:03:42 GMT
Yes, you should check for null before setting it.  Setting a value of
null is equivalent to having xsi:nil="true" on the element.

________________________________

From: MIDON ALEXIS [mailto:ALEXIS.MIDON@sgam.com] 
Sent: Tuesday, July 27, 2004 9:53 AM
To: 'xmlbeans-user@xml.apache.org'
Subject: 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

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message