xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Perham" <Mike.Per...@webifysolutions.com>
Subject RE: XmlValueNotNillableException
Date Thu, 29 Jul 2004 13:52:35 GMT
Another issue which seems to be related.  I have this attribute:

<xs:attribute name="lastPasswordUpdate" type="xs:dateTime"
use="optional"/>

In the related Java bean:

isSetLastPasswordUpdate() always returns true
and
getLastPasswordUpdate() throws XmlValueOutOfRangeException if the value
is unset.

So there is no way for the bean holder to even determine if the value is
set.  Should I be using nil="true" instead?  Can someone write up a Wiki
page on the semantic differences between use="optional", minoccurs="0"
and nil="true"?

-----Original Message-----
From: Kevin Krouse [mailto:kkrouse@bea.com] 
Sent: Tuesday, July 27, 2004 2:04 PM
To: xmlbeans-user@xml.apache.org
Subject: RE: XmlValueNotNillableException

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/



- ---------------------------------------------------------------------
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