• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing Errors using JAXB | unmarshalling xml  RSS feed

Gurvinder Singh
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a problem unmarshalling some xml data.

My xml has elements like

<InternalPartID displayName="Gold Bracelet">sku123</InternalPartID>

I have generated the java beans from the xsd, and i have put some condition on elements like nillable=true and minOccurs=0

<xs:element ref="AvailabilityDate" minOccurs="0"/>
<xs:element name="AvailabilityDate" type="xs:dateTime" nillable="true"/>

Now my problem arise when i try to unmarshal the above piece of xml.
It gives me parsing errors at the AvailabilityDate.

Since i have put minOccurs="0" and nillable="true", still while unmarshalling it throws exception. If i change the type="xs:dateTime" to "xs:string" it works fine.

Can someone tell me how to resolve this, and skip the empty elements.
I am using JAXB to unmarshal the xml, where while
unmarshaller.unmarshal(byteIn); throws me the exeption.

Caused by: java.lang.IllegalArgumentException:
at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parseYear(Unknown Source)
at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(Unknown Source)
at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(Unknown Source)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$13.parse(RuntimeBuiltinLeafInfoImpl.java:546)

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!