DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3945>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3945

NPE when using an InputSource for a document with an external parsed entity

           Summary: NPE when using an InputSource for a document with an
                    external parsed entity
           Product: Xerces-J
           Version: 1.4.3
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


If I create a parser (SAX or DOM) and then try an parse an InputSource I create 
directly from a FileReader, I get a NullPointerException if the xml contained 
by the reader has any external parsed entities defined in it. If the xml has no 
external entities (internal ok), the parse succeeds, and if I parse using a 
String systemId instead of a InputSource, the parse also succeeds.  If there is 
some precondition to using InputSources (like setting the systemId...?) then a 
more helpful error message would be a good idea.

e.g.

foo.xml:
<?xml version="1.0"?>

<!DOCTYPE foo [
   <!ENTITY baz SYSTEM "baz.xml">
]>

<foo/>

baz.xml:
<baz/>

foo.java:
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;

public class foo
{
        public static void main (String[] args) 
        {
                try
                {
                        String filename = args[0];
                        XMLReader reader = XMLReaderFactory.createXMLReader
("org.apache.xerces.parsers.SAXParser");
                        InputSource src = new InputSource(new BufferedReader
(new FileReader(filename)));
                        // reader.parse(filename); //this works
                        reader.parse(src); // This NPE's
                }
                catch (Exception ex)
                {
                        System.out.println("Unexpected exception: " + ex);
                        ex.printStackTrace();
                }
        }
        
}

javac -classpath .;xerces.jar foo.java
java -classpath .;xerces.jar foo foo.xml

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

Reply via email to