This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML Unmarshalling Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Unmarshalling Error" Watch "XML Unmarshalling Error" New topic

XML Unmarshalling Error

kishore routhu

Joined: Jan 17, 2013
Posts: 14
I am getting the following exception while parsing the xml using JAXB.

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"OTA_HotelRateAmountNotifRS"). Expected elements are (none)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(
10:16:17,533 ERROR [STDERR] at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
10:16:17,534 ERROR [STDERR] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

and my XSD for OTA_HotelRateAmountNotifRS

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="" elementFormDefault="qualified" version="1.005" id="OTA2006A" xmlns="" xmlns:xs="">
<xs:element name="OTA_HotelRateAmountNotifRS">
<xs:documentation xml:lang="en">The OTA_HotelInvCountNotifRS is the message used to indicate the status of processing the OTA_HotelInvCountNotifRQ message.</xs:documentation>
<xs:extension base="MessageAcknowledgementType">
<xs:element name="Inventories" type="InvCountType" minOccurs="0"/>

"MessageAcknowledgementType" is defined as follows

<xs:complexType name="MessageAcknowledgementType">
<xs:element name="Success" type="SuccessType">
<xs:documentation xml:lang="en">The presence of the empty Success element explicitly indicates that the OTA versioned message succeeded. </xs:documentation>
<xs:element name="Warnings" type="WarningsType" minOccurs="0">
<xs:documentation xml:lang="en">Used in conjunction with the Success element to define one or more business errors.</xs:documentation>
<xs:element name="Errors" type="ErrorsType">
<xs:documentation xml:lang="en">Errors is returned if the request was unable to be processed.</xs:documentation>
<xs:element name="UniqueID" type="UniqueID_Type" minOccurs="0">
<xs:documentation xml:lang="en">May be used to return the unique id from the request message.</xs:documentation>
<xs:element ref="TPA_Extensions" minOccurs="0"/>
<xs:attributeGroup ref="OTA_PayloadStdAttributes"/>

attributeGroup "OTA_PayloadStdAttributes" contains the following attributes

Anyone please advice me what are the changes i need to do in XSD for successful parsing of XML ?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19850

That must mean that your XML doesn't conform to those schemas. That's just a guess, though, because you didn't post any of the XML you claim is causing the problem. If you still haven't fixed the problem, I suggest you post your XML.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: XML Unmarshalling Error
jQuery in Action, 3rd edition