users@jaxb.java.net

unexpected root element!

From: Mohsen Emami-Nouri <Mohsen.Emami-Nouri_at_litescape.com>
Date: Fri, 9 Dec 2005 18:35:31 -0800

Hi,

I am using 1.0.5 RI.I successfully used jxc to create java classes out
of schemas (these schemas include other schemas) . When I am trying to
unmarshall a sample XML, I get a exception.

 

Thanks a lot in advance,

\Mohsen

 

This is the schema:

 

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema
targetNamespace="http://www.ecma-international.org/standards/ecma-323/cs
ta/ed3"
xmlns:csta="http://www.ecma-international.org/standards/ecma-323/csta/ed
3" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

  <xsd:annotation>

    <xsd:documentation>CSTA-request-system-status</xsd:documentation>

  </xsd:annotation>

  <xsd:include schemaLocation="device-feature-types.xsd"/>

  <xsd:include schemaLocation="extension-types.xsd"/>

  <xsd:element name="RequestSystemStatus">

    <xsd:complexType>

      <xsd:sequence>

        <xsd:element ref="csta:sysStatRegisterID" minOccurs="0"/>

        <xsd:element ref="csta:extensions" minOccurs="0"/>

      </xsd:sequence>

    </xsd:complexType>

  </xsd:element>

  <xsd:element name="RequestSystemStatusResponse">

    <xsd:complexType>

      <xsd:sequence>

        <xsd:element name="systemStatus" type="csta:SystemStatusValue"/>

        <xsd:element ref="csta:extensions" minOccurs="0"/>

      </xsd:sequence>

    </xsd:complexType>

  </xsd:element>

</xsd:schema>

 

 

This is the sample XML:

 

<?xml version="1.0" encoding="UTF-8"?>

            <RequestSystemStatus
xmlns="http://www.ecma-international.org/standard/ecma-323/csta/ed3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema"/>

 

 

 

This is my test program code:

 

 

try{

 

Context jc = JAXBContext.newInstance( "com.lsc.sipgw.cstaservice.parser"
);

                                       

Unmarshaller u = jc.createUnmarshaller();

                                       

                                       

StringBuffer xmlStr = new StringBuffer( initMsg); //iniMsg is the above
mentioned XML

                                       

RequestSystemStatusElement rss =
(RequestSystemStatusElement)u.unmarshal( new StreamSource( new
StringReader( xmlStr.toString() ) ) );

 

                                       

}catch ( JAXBException exp){

                                       

            System.out.println(logHeader + "
processCstaInit:JAXBException:" + exp.toString());

 }

 

This throws the following exception:

 

 

jaxbTest processCstaInit:JAXBException:javax.xml.bind.UnmarshalException

 - with linked exception:

[org.xml.sax.SAXParseException: unexpected root element
(uri:"http://www.ecma-international.org/standard/ecma-323/csta/ed3",
local:"RequestSystemStatus"). Expected elements are
<{http://www.ecma-international.org/standards/ecma-323/csta/ed3}associat
edCallingDevice>,<{http://www.ecma-international.org/standards/ecma-323/
csta/ed3}authCode>,<{http://www.ecma-international.org/standards/ecma-32
3/csta/ed3}routeRegisterReqID>,<{http://www.ecma-international.org/stand
ards/ecma-323/csta/ed3}RequestSystemStatus>,<{http://www.ecma-internatio
nal.org/standards/ecma-323/csta/ed3}sysStatRegisterID>,<{http://www.ecma
-international.org/standards/ecma-323/csta/ed3}userData>,<{http://www.ec
ma-international.org/standards/ecma-323/csta/ed3}extensions>,<{http://ww
w.ecma-international.org/standards/ecma-323/csta/ed3}accountCode>,<{http
://www.ecma-international.org/standards/ecma-323/csta/ed3}callingDevice>
,<{http://www.ecma-international.org/standards/ecma-323/csta/ed3}cause>,
<{http://www.ecma-international.org/standards/ecma-323/csta/ed3}networkC
allingDevice>,<{http://www.ecma-international.org/standards/ecma-323/cst
a/ed3}RequestSystemStatusResponse>,<{http://www.ecma-international.org/s
tandards/ecma-323/csta/ed3}mediaCallCharacteristics>,<{http://www.ecma-i
nternational.org/standards/ecma-323/csta/ed3}crossRefIdentifier>,<{http:
//www.ecma-international.org/standards/ecma-323/csta/ed3}deviceHistory>,
<{http://www.ecma-international.org/standards/ecma-323/csta/ed3}messageI
nfo>,<{http://www.ecma-international.org/standards/ecma-323/csta/ed3}sub
jectOfCall>,<{http://www.ecma-international.org/standards/ecma-323/csta/
ed3}associatedCalledDevice>,<{http://www.ecma-international.org/standard
s/ecma-323/csta/ed3}languagePreferences>,<{http://www.ecma-international
.org/standards/ecma-323/csta/ed3}networkCalledDevice>,<{http://www.ecma-
international.org/standards/ecma-323/csta/ed3}lastRedirectionDevice>,<{h
ttp://www.ecma-international.org/standards/ecma-323/csta/ed3}calledDevic
e>,<{http://www.ecma-international.org/standards/ecma-323/csta/ed3}corre
latorData>,<{http://www.ecma-international.org/standards/ecma-323/csta/e
d3}reason>]