Hi Andrew, Kohsuke,
Part of the stack trace is identical, so it does look like Issue 29.
After some more testing I found that in my test application (attached zip:
ignore-error-sample.zip) this exception is thrown only when I have
annotated the element on which the error occurs (to use my own data type
converter).
My sample XML is shown below, which has a text value for the quantity
element (defined as a nonNegativeInteger type):
<purchaseOrder orderDate="1999-10-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</shipTo>
<billTo country="US">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</billTo>
<items>
<item partNum="123-AB">
<productName>Computer</productName>
<quantity>ABCD EFGH IJKL</quantity>
<USPrice>1499.99</USPrice>
</item>
</items>
</purchaseOrder>
When I am recovering from the error while parsing the XML, I get the
UnmarshalException only when the quantity field is defined as
MyAnnotatedInt and not when MyNormalInt (see schema fragment below).
<xsd:complexType name="Items">
<xsd:sequence>
<xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="productName" type="xsd:string"/>
<xsd:element name="quantity" type="MyAnnotatedInt"/> <!-- no error
when MyNormalInt is used -->
<xsd:element name="USPrice" type="xsd:decimal"/>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="partNum" type="SKU" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="MyNormalInt">
<xsd:restriction base="xsd:nonNegativeInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="MyAnnotatedInt">
<xsd:annotation>
<xsd:documentation>
Don't want a java.math.BigInteger generated in the classes for
every integer field, instead want an int.
</xsd:documentation>
<xsd:appinfo>
<jaxb:javaType name="java.lang.Integer"
parseMethod="primer.MyDatatypeConverter.parseInteger"
printMethod="primer.MyDatatypeConverter.printInteger"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:nonNegativeInteger"/>
</xsd:simpleType>
Thanks,
Gagan
"Andrew Ferguson" <Andrew.Ferguson_at_arm.com>
09/28/2004 03:18 PM
Please respond to
users_at_jaxb.dev.java.net
To
<users_at_jaxb.dev.java.net>
cc
Subject
RE: Re: how to ignore an error during partial unmarshalling
hi,
from the stack trace:
Stack Trace :
javax.xml.bind.UnmarshalException: Unexpected end of element
{
http://srm.i2.com/neg}:biddingType
it sounds very like Issue 29?
https://jaxb.dev.java.net/issues/show_bug.cgi?id=29
thanks,
Andrew
From: Gagan_Bhatnagar_at_i2.com [mailto:Gagan_Bhatnagar_at_i2.com]
Sent: 28 September 2004 10:37
To: users_at_jaxb.dev.java.net
Subject: Re: how to ignore an error during partial unmarshalling
Thanks Kohsuke,
I created a simple test application. And found that there's no problem
while recovering from schema errors.
Somehow I'm getting this problem only in my main application running in
Weblogic Server which uses it's own Xerces implementation. Or possibly
there's a bug in my code.
Will verify and confirm.
Gagan
Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
09/27/2004 09:31 PM
Please respond to
users_at_jaxb.dev.java.net
To
users_at_jaxb.dev.java.net
cc
Subject
Re: how to ignore an error during partial unmarshalling
Gagan_Bhatnagar_at_i2.com wrote:
> Specifically, in certain fields in my XML a string value appears where
an
> integer is defined in the schema. On receiving errors on these elements
I ignore
> the error and return true in my ValidationEventHandler implementation.
However,
> I get an UnmarshalException because endElement event on the same element
throws
> the exception below.
Recovering from errors is often tricky, and there may very well be bugs.
If you could file a bug and attach schemas / test code and what now,
that would be really helpful.
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net