Unmarshal Exception: unexpected root element
843834May 16 2003 — edited May 30 2003Sorry for the length of this.
When I try to unmarshall the following XML I received a SAXParseException: unexpected root element NoteHistoryRequest.
Any Ideas?
Thanks
/////////////////XML File//////////////////
<NoteHistoryRequest>
<LoanInformation>
<LoanNumber>10000010</LoanNumber>
</LoanInformation>
<ListFilter>
<NumberOfRecordToRetrieve>50</NumberOfRecordToRetrieve>
<Token>0</Token>
<StartDate>2003-01-07</StartDate>
<EndDate>2003-05-07</EndDate>
<FilterInfo>
<Name>TransactionType</Name>
<Value>PROB</Value>
</FilterInfo>
</ListFilter>
</NoteHistoryRequest>
//////////////////// END XML////////////////////////////
/////////////////////CODE///////////////////////
JAXBContext jc = JAXBContext.newInstance("wamu.uiatransaction.loan");
NoteHistoryRequest req = (NoteHistoryRequest)
u.unmarshal(new InputSource(new StringReader(msgPayload)));Unmarshaller u = jc.createUnmarshaller();
//msgPayload = String containing XML
//////////////////// END CODE///////////////////////
//////////////////////SCHEMA////////////////////////
loan.xsd
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 2 U (http://www.xmlspy.com) by Salim Djaffar (WaMu) -->
<xs:schema targetNamespace="http://schema.wamu.com/wamuhomeloans/loan/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:crm="http://schema.wamu.com/crm/customer/" xmlns="http://schema.wamu.com/wamuhomeloans/loan/" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="2.6">
<xs:include schemaLocation="loantypes.xsd"/>
<xs:import namespace="http://schema.wamu.com/crm/customer/" schemaLocation="crmtypes.xsd"/>
<xs:element name="NoteHistoryRequest" type="NoteHistoryRequestType"/>
<xs:element name="NoteHistoryResponse" type="NoteHistoryResponseType"/>
<xs:complexType name="NoteHistoryRequestType">
<xs:sequence>
<xs:element name="LoanInformation" type="LoanInformationType" minOccurs="0"/>
<xs:element name="ListFilter" type="ListFilterType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
loantypes.xsd
<xs:schema targetNamespace="http://schema.wamu.com/wamuhomeloans/loan/" xmlns="http://schema.wamu.com/wamuhomeloans/loan/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:crm="http://schema.wamu.com/crm/customer/" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="2.6">
<xs:import namespace="http://schema.wamu.com/crm/customer/" schemaLocation="crmtypes.xsd"/>
<xs:complexType name="LoanInformationType">
<xs:sequence>
<xs:element name="LoanNumber" type="xs:string" minOccurs="0"/>
<xs:element name="SSN" type="xs:string" minOccurs="0"/>
<xs:element name="SystemId" type="xs:string" minOccurs="0"/>
<xs:element name="UserId" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ListFilterType">
<xs:sequence>
<xs:element name="NumberOfRecordToRetrieve" type="xs:double" minOccurs="0"/>
<xs:element name="Token" type="xs:string" minOccurs="0"/>
<xs:element name="StartDate" type="xs:date" minOccurs="0"/>
<xs:element name="EndDate" type="xs:date" minOccurs="0"/>
<xs:element name="FilterInfo" type="NameValueType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="NameValueType">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Value" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
/////////////////////////// END SCHEMA/////////////////////
//////////////Generates/////////////////////
org.xml.sax.SAXParseException: unexpected root element NoteHistoryRequest
at com.sun.xml.bind.unmarshaller.SAXUnmarshallerHandlerImpl.startElement
(SAXUnmarshallerHandlerImpl.java:97)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXP
arser.java:434)
at org.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(XMLNames
paceBinder.java:832)
at org.apache.xerces.impl.XMLNamespaceBinder.startElement(XMLNamespaceBi
nder.java:568)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidat
or.java:796)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElemen
t(XMLDocumentFragmentScannerImpl.java:752)
at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanR
ootElementHook(XMLDocumentScannerImpl.java:927)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1519)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XM
LDocumentFragmentScannerImpl.java:333)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardP
arserConfiguration.java:529)
at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardP
arserConfiguration.java:585)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.j
ava:1148)
at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(Unmarshaller
Impl.java:130)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnm
arshallerImpl.java:139)
at wamu.transformation.uia.alss.UIAToALSSNoteHistoryRequest.translateMes
sage(UIAToALSSNoteHistoryRequest.java:95)
at test.wamu.transformation.uia.TestTranslate.testTranslateMessage(TestT
ranslate.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at test.wamu.transformation.uia.TestTranslate.runTest(TestTranslate.java
:166)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.swingui.TestRunner$16.run(TestRunner.java:623)