• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing Errors using JAXB | unmarshalling xml  RSS feed

 
Gurvinder Singh
Greenhorn
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

<InventoryRecord>
<InternalPartID displayName="Gold Bracelet">sku123</InternalPartID>
<StockLevel>10</StockLevel>
<AvailabilityStatus>1004</AvailabilityStatus>
<AvailabilityDate/>
<StockThreshold>10</StockThreshold>
<BackOrderLevel/>
<BackOrderThreshold/>
<PreOrderLevel/>
<PreOrderThreshold/>
</InventoryRecord>

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

eg:
<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)


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