users@jaxb.java.net

unexpected root element

From: Shannon Hughes <srhughes_at_LUCENT.COM>
Date: Thu, 19 Jun 2003 18:04:38 -0600

I am receiving the following exception during unmarshalling:

[org.xml.sax.SAXParseException: unexpected root element DESIGN_DATA]
 at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:306)
 at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:134)......

The xml file I am unmarshalling contains a reference to a dtd which I have converted to an XML schema for the JAXB binding compiler to take advantage of the vendor extensions. Since the xml file contains a reference to a dtd I setup a class that extends the SAX DefaultHandler object and resolve my entities using this class. I have tried resolving to my XML schema and to an empty schema but get the same error. Is something out of wack between the compiled JAXB classes and XML file?

Here is my code (removed methods and exceptions for better readability):

 System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
 SAXParserFactory spf = SAXParserFactory.newInstance();
 saxParser = spf.newSAXParser();
 xmlReader = saxParser.getXMLReader();
 xmlReader.setEntityResolver(EmptySchemaResolver.getInstance());
 JAXBContext jcontext = JAXBContext.newInstance(CONTEXT_PATH);
 unmarshaller = jcontext.createUnmarshaller();

 InputSource inputSource = createInputSource(xmlFile);
 SAXSource xmlSource =
  new SAXSource(xmlReader, inputSource);
 unmarshaller.setValidating(false);
 Object obj = unmarshaller.unmarshal(xmlSource);