This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Unmarshalling Error" Watch "XML Unmarshalling Error" New topic
Author

XML Unmarshalling Error

kishore routhu
Greenhorn

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:"http://www.opentravel.org/OTA/2003/05", local:"OTA_HotelRateAmountNotifRS"). Expected elements are (none)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:603)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:244)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:239)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1009)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:446)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:427)
10:16:17,533 ERROR [STDERR] at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:137)
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="http://www.opentravel.org/OTA/2003/05" elementFormDefault="qualified" version="1.005" id="OTA2006A" xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="OTA_HotelRateAmountNotifRS">
<xs:annotation>
<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:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="MessageAcknowledgementType">
<xs:sequence>
<xs:element name="Inventories" type="InvCountType" minOccurs="0"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>

"MessageAcknowledgementType" is defined as follows

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

attributeGroup "OTA_PayloadStdAttributes" contains the following attributes
1.EchoToken
2.TimeStamp
3.Target
4.Version
5.TransactionIdentifier
6.SequenceNmbr
7.TransactionStatusCode



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

Joined: Oct 14, 2005
Posts: 18541
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML Unmarshalling Error
 
Similar Threads
Axis 1.4 throwing org.xml.sax.SAXException: Invalid element
MS Exchange web service: If the 'nillable' attribute is false in the schema, the 'xsi:nil' attribute
XML Schema Validation.
WSSecurity, MTOM and TIBCO 5.6
using JiBX