Making file_id nillable in the schema does not help since the web service is still going to output <file_id/>, not <file_id xsi:nil="true"/>. (The web service does not follow the schema, the schema is only for generating XMLBeans, if I understood correctly.) I think file_id should not be of type xs:int, since <file_id/> is a possible output; why don't you simply make the type xs:string, and then getFileId will return a String and you can simply test if it is equal to "". I think that would be the simplest solution. - Wing Yew
_____ From: Soumya [mailto:soumya_...@yahoo.co.in] Sent: Wednesday, March 24, 2010 4:05 AM To: user@xmlbeans.apache.org Subject: Re: Xmlbeans errors for empty int tag Hi Jacob, Yes I tried configuring it as nillable="true" today. And I tried to check if(item.xgetFileId()!=null && item.xgetFileId().isNil()) { /// } But once again the isNil() now threw the error org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException at org.apache.xmlbeans.impl.values.JavaIntHolder.set_text(JavaIntHolder.java:42) at org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1085) at org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1224) at org.apache.xmlbeans.impl.values.XmlObjectBase.isNil(XmlObjectBase.java:575) Any more suggestions friends? Regards, SSP _____ From: Jacob Danner <jacob.dan...@gmail.com> To: user@xmlbeans.apache.org Sent: Tue, 23 March, 2010 6:39:42 PM Subject: Re: Xmlbeans errors for empty int tag have you tried adding nillable="true" to the file_id element. I believe this makes the type the Java Wrapper type (Integer in this case). Otherwise to check the existence of the element you could try xpath, or using the xmlcursor apis and seeing if you can navigate to the element. HTH, -jacobd On Tue, Mar 23, 2010 at 10:32 AM, Soumya <HYPERLINK "mailto:soumya_...@yahoo.co.in"soumya_...@yahoo.co.in> wrote: > Hello all, > > I am using xmlbeans 1.0.4 and have a strange issue at hand. > We have an old webservice which was documented in DTD and to use advanced > xmlbeans features we decided to write an xsd for it and use it at another > place to send/get WS calls. Kindly note the xsd is used only at client > side..ie.e where it invokes the WS. The WS is still the old one. > Here is a snippet of teh xsd that is causing the issue - > <xs:complexType name ="itemT"> > <xs:sequence maxOccurs="1"> > <xs:element name="item_id" type="xs:int" minOccurs="1" > maxOccurs="1"/> > <xs:element name="file_id" type="xs:int" minOccurs="0" > maxOccurs="1"/> > ....................................... > ............</xs:sequence> > </xs:complexType> > > Now the 'file_id' field above is not mandatory and may be blank. The way our > old WS responds in case there is nor file_id associated with type itemT is > as follows. > <item> > <item_id>1602</item_id> > <file_id/> > .......................... > </item> > SO even if there is no value for file_id it still returns an empty tag. > > Now this is of type xs:int I cannot do a null check - Hence in my java code > whenever I try to access it > like > item.getFileId() - It always throws an exception stacktrace as follows > > org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException > at > org.apache.xmlbeans.impl.values.JavaIntHolder.set_text(JavaIntHolder.java:42) > at > org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1085) > at > org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1224) > at > org.apache.xmlbeans.impl.values.JavaIntHolder.intValue(JavaIntHolder.java:52) > at > org.apache.xmlbeans.impl.values.XmlObjectBase.getIntValue(XmlObjectBase.java:1442) > at com.company.webservices.live.impl.ItemTImpl.getFileId(Unknown Source) > at > com.company.live.ws.service.NewWebService.fetchItem(LiveWebService.java:150) > > > Is there a way in xmlbeans by which I can check that whether a "int value" > is present or not (like we do for String i.e. null check) and only then try > to retrieve the fileId value? > > I tried using item.isSetFileId() but that returns as true. > > I also tried item.xgetFileId() - checked if that is null but again when we > try to get intValue() it throws same exception. > > Can anyone kindly help? > > Thanks in advance, > SSP > > ________________________________ > Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!. --------------------------------------------------------------------- To unsubscribe, e-mail: HYPERLINK "mailto:user-unsubscr...@xmlbeans.apache.org"user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: HYPERLINK "mailto:user-h...@xmlbeans.apache.org"user-h...@xmlbeans.apache.org _____ The INTERNET now has a personality. YOURS! HYPERLINK "http://in.rd.yahoo.com/tagline_yyi_1/*http://in.yahoo.com/" \nSee your Yahoo! Homepage.