7 Replies Latest reply: Jan 25, 2013 1:21 AM by EJP RSS

    xml parsing error

    986562
      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 ?
        • 1. Re: xml parsing error
          Kayaman
          And what's the XML?
          • 2. Re: xml parsing error
            986562
            I am trying to parse following xml.

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <OTA_HotelRateAmountNotifRQ PrimaryLangID="en" Version="3" Target="Production" TimeStamp="2013-01-23T12:09:27.580+05:30" xmlns="http://www.opentravel.org/OTA/2003/05">
            <POS CSAUUID="7691c417-63ff-43f4-9aa6-2328976f55b2-864084952">
            <Source AgentDutyCode="5644b40976b07f0" AgentSine="157">
            <RequestorID ID="38223" ID_Context="CLTZ" Type="10"/>
            <BookingChannel Type="4"/>
            </Source>
            </POS>
            <RateAmountMessages>
            <RateAmountMessage>
            <StatusApplicationControl RatePlanType="13" IsRoom="true" InvCode="79149" End="2013-01-20" Start="2013-01-19" Override="true"/>
            <Rates>
            <Rate Sun="true" Sat="true" Fri="true" Thur="true" Weds="true" Tue="true" Mon="true">
            <BaseByGuestAmts>
            <BaseByGuestAmt AgeQualifyingCode="10" NumberOfGuests="1" DecimalPlaces="2" CurrencyCode="EUR" AmountAfterTax="100"/>
            </BaseByGuestAmts>
            </Rate>
            </Rates>
            </RateAmountMessage>
            </RateAmountMessages>
            </OTA_HotelRateAmountNotifRQ>
            • 3. Re: xml parsing error
              jtahlborn
              I assume you realize that the root element of that xml is "OTA_HotelRateAmountNotifR*Q*", not "OTA_HotelRateAmountNotifR*S*" which the schema requires?
              • 4. Re: xml parsing error
                986562
                <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                <OTA_HotelRateAmountNotifRQ PrimaryLangID="en" Version="3" Target="Production" TimeStamp="2013-01-23T12:09:27.580+05:30" xmlns="http://www.opentravel.org/OTA/2003/05">
                <POS CSAUUID="7691c417-63ff-43f4-9aa6-2328976f55b2-864084952">
                <Source AgentDutyCode="5644b40976b07f0" AgentSine="157">
                <RequestorID ID="38223" ID_Context="CLTZ" Type="10"/>
                <BookingChannel Type="4"/>
                </Source>
                </POS>
                <RateAmountMessages>
                <RateAmountMessage>
                <StatusApplicationControl RatePlanType="13" IsRoom="true" InvCode="79149" End="2013-01-20" Start="2013-01-19" Override="true"/>
                <Rates>
                <Rate Sun="true" Sat="true" Fri="true" Thur="true" Weds="true" Tue="true" Mon="true">
                <BaseByGuestAmts>
                <BaseByGuestAmt AgeQualifyingCode="10" NumberOfGuests="1" DecimalPlaces="2" CurrencyCode="EUR" AmountAfterTax="100"/>
                </BaseByGuestAmts>
                </Rate>
                </Rates>
                </RateAmountMessage>
                </RateAmountMessages>
                </OTA_HotelRateAmountNotifRQ>
                • 5. Re: xml parsing error
                  EJP
                  Why post the same thing again with the same error in it?
                  • 6. Re: xml parsing error
                    986562
                    Sorry ..
                    Actully i am trying to parse OTA_HotelRateAmountNotifRS

                    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                    <OTA_HotelRateAmountNotifRS PrimaryLangID="en" Version="3" Target="Production" TimeStamp="2013-01-23T12:09:27.580+05:30" xmlns="http://www.opentravel.org/OTA/2003/05">
                    <POS CSAUUID="7691c417-63ff-43f4-9aa6-2328976f55b2-864084952">
                    <Source AgentDutyCode="5644b40976b07f0" AgentSine="157">
                    <RequestorID ID="38223" ID_Context="CLTZ" Type="10"/>
                    <BookingChannel Type="4"/>
                    </Source>
                    </POS>
                    <RateAmountMessages>
                    <RateAmountMessage>
                    <StatusApplicationControl RatePlanType="13" IsRoom="true" InvCode="79149" End="2013-01-20" Start="2013-01-19" Override="true"/>
                    <Rates>
                    <Rate Sun="true" Sat="true" Fri="true" Thur="true" Weds="true" Tue="true" Mon="true">
                    <BaseByGuestAmts>
                    <BaseByGuestAmt AgeQualifyingCode="10" NumberOfGuests="1" DecimalPlaces="2" CurrencyCode="EUR" AmountAfterTax="100"/>
                    </BaseByGuestAmts>
                    </Rate>
                    </Rates>
                    </RateAmountMessage>
                    </RateAmountMessages>
                    </OTA_HotelRateAmountNotifRS>
                    • 7. Re: xml parsing error
                      EJP
                      Good, so why are you posting that? Does it work? If not, what's the error message now?