Hello All,

I was trying to parse a XML Document using DOM Parser.

I got null pointer exception while executing doc = builder.parse(xmlDataFile);

There were few entities in the XML data file. On removing a particular entity, i was able to parse the file successfully

The entity was some thing like this

<!ENTITY SAMPLE.TIF SYSTEM "SAMPLE.TIF" NDATA TIF>
What could be the reason?

EDIT:

Here is the code:

DocumentBuilderFactory aFactory = DocumentBuilderFactory.newInstance();
aFactory.setValidating(false);
aFactory.setFeature("xml.org/sax/features/namespaces", false);
aFactory.setFeature("apache.org/xml/features/validation/schema", false);
aFactory.setIgnoringComments(true);
builder = aFactory.newDocumentBuilder();
doc = builder.parse(xmlDataFile);
This is the trace:

at com.sun.org.apache.xerces.internal.dom.DeferredDoc umentImpl.setChunkIndex(DeferredDocumentImpl.java: 1944)
at com.sun.org.apache.xerces.internal.dom.DeferredDoc umentImpl.appendChild(DeferredDocumentImpl.java:64 4)
at com.sun.org.apache.xerces.internal.parsers.Abstrac tDOMParser.characters(AbstractDOMParser.java:1191)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTD Validator.characters(XMLDTDValidator.java:862)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:463)
at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(DocumentBuilderImpl.java:283)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBu ilder.java:180)
at XMLParser.Parse(XMLParser.java:89)
at Main.main(Main.java:116)
89 line number points to -> doc = builder.parse(xmlDataFile);



i found the solution if i add aFactory.setFeature("apache.org/xml/features/dom/defer-node-expansion", false); the issue is resolved. But i was not able to find what is the cause of this issue. Is the problem with the ENTITY or ...?

Thanks