Re: Xmlbeans errors for empty int tag

2010-03-23 Thread Jacob Danner
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



Xmlbeans errors for empty int tag

2010-03-23 Thread Soumya
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 -




...



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! 
http://downloads.yahoo.com/in/internetexplorer/