org.xml.sax.SAXParseException: Content is not allowed in prolog. is thrown out 
when parser a UTF-8 bom formatted XML file
-------------------------------------------------------------------------------------------------------------------------

         Key: XERCESJ-1122
         URL: http://issues.apache.org/jira/browse/XERCESJ-1122
     Project: Xerces2-J
        Type: Bug
  Components: SAX  
    Versions: 2.0.0    
 Environment: Windows XP.
    Reporter: lin zhu 


The following information is printed when I try to parse an XML file saved in 
UTF-8 BOM format:

org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at 
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown 
Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
        at 
org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)

If I save the very XML file to standard UTF-8 format then everything works 
smoothly.

I've tried to debug the source code of Xecers. I found that Xecers actually has 
codes that handle UTF-8 BOM formatted input stream in class 
org.apache.xerces.impl.XMLEntityManager.java (@version $Id: 
XMLEntityManager.java,v 1.94 2005/04/19 03:18:18 mrglavas Exp $). But those 
codes has never been executed in my case. The following is the detail:

In public method setupCurrentEntity() in class XMLEntityManager, there are 
several lines of codes which dealing with UTF-8 BOM format input stream, and 
all those codes are located in the code block starting from line 929 if ( 
reader == null ) { .... }. The "reader" in the if clause is defined in line 
923. And In my case, the reader would not be assigned a "null" value so that 
the codes which dealing with UTF-8 BOM would never been executed.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to