Re: Xmlbeans errors for empty int tag
You are right Wing. Thats exactly the problem :) The actual service doesnt use the xsd. I did think about making it as type xs:string and then check for null but wanted to keep ints as int (Though I agree I can apply a numeric restriction to a string via xsd). Again everytime I will have to use Integer.parse operation. I thought of adding a small method public static boolean isXmlIntNull(XmlInt xmlInt) { if(xmlInt == null || xmlInt.xmlText().equals("")) { return true; } return false; } And call it from the service code like if(!XmlUtils.isXmlIntNull(item.xgetFileId())) { // We only get here if has some value! } the xgetFileId() actually returns a xml-fragment and am checking against that. I now call the method wherever we have that file_id thing... actually its not only file_id - quite a few other fields have the same problem. Thanks all for your inputs. Regards, SSP From: Wing Yew Poon To: user@xmlbeans.apache.org Sent: Wed, 24 March, 2010 6:01:23 PM Subject: RE: Xmlbeans errors for empty int tag Of course, then you do have the inconvenience of having to convert the file_id string to and from an int value, if indeed you are working with ints, but that is the tradeoff. From: Wing Yew Poon Sent: Wednesday, March 24, 2010 10:50 AM To: user@xmlbeans.apache.org Subject: RE: Xmlbeans errors for empty int tag Making file_id nillable in the schema does not help since the web service is still going to output , not . (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 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 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 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 - > > > maxOccurs="1"/> > maxOccurs="1"/> > ... > > > > 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. > > 1602 > > .. > > 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)
RE: Xmlbeans errors for empty int tag
Of course, then you do have the inconvenience of having to convert the file_id string to and from an int value, if indeed you are working with ints, but that is the tradeoff. _ From: Wing Yew Poon Sent: Wednesday, March 24, 2010 10:50 AM To: user@xmlbeans.apache.org Subject: RE: Xmlbeans errors for empty int tag Making file_id nillable in the schema does not help since the web service is still going to output , not . (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 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 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 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 - > > > maxOccurs="1"/> > maxOccurs="1"/> >... > > > > 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. > > 1602 > > .. > > 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-u
RE: Xmlbeans errors for empty int tag
Making file_id nillable in the schema does not help since the web service is still going to output , not . (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 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 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 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 - > > > maxOccurs="1"/> > maxOccurs="1"/> >... > > > > 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. > > 1602 > > .. > > 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.
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 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 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 - > > > maxOccurs="1"/> > maxOccurs="1"/> >... > > > > 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. > > 1602 > > .. > > 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: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/
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 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 - > > > maxOccurs="1"/> > maxOccurs="1"/> > ... > > > > 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. > > 1602 > > .. > > 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: user-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: user-h...@xmlbeans.apache.org