  | |  | Probable Encoding problem | Probable Encoding problem 2003-08-18 - By Jason
Hello,
One of my colleagues has run into a bit of a problem with the following code:
try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder();
String sInput = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><RequestType>DISCOVER_DATASOURCES</RequestType>";
BufferedReader bReader = new BufferedReader(new StringReader(sInput)); InputSource is = new InputSource(bReader);
Document doc = parser.parse(is);
} catch (Throwable x) { }
When he runs it from the command line everything works fine but embedded in a servlet running in Tomcat it generates the following error/stack trace.
org.xml.sax.SAXParseException: The root element is required in a well-formed doc ument. at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213 ) at org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XM LDocumentScanner.java:570) at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.endO fInput(XMLDocumentScanner.java:790) at org.apache.xerces.framework.XMLDocumentScanner.endOfInput(XMLDocument Scanner.java:418) at org.apache.xerces.validators.common.XMLValidator.sendEndOfInputNotifi cations(XMLValidator.java:712) at org.apache.xerces.readers.DefaultEntityHandler.changeReaders(DefaultE ntityHandler.java:1031) at org.apache.xerces.readers.XMLEntityReader.changeReaders(XMLEntityRead er.java:168) at org.apache.xerces.readers.AbstractCharReader.changeReaders(AbstractCh arReader.java:150) at org.apache.xerces.readers.AbstractCharReader.lookingAtChar(AbstractCh arReader.java:217) at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.disp atch(XMLDocumentScanner.java:686) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS canner.java:381) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl. java:195)
I'm pretty sure this is an encoding issue but I'm not really sure how to help him solve it. Any suggestions would be greatly appreciated.
-jason
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|
 |