I already responded to you. See [1].

[1] http://markmail.org/message/2qzf4yeeg5iy5o7e.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

sri kumar <sri_kumar...@yahoo.co.in> wrote on 12/04/2009 07:18:28 AM:

> 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("http://xml.org/sax/features/namespaces";,
false);
>         aFactory.setFeature
("http://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.DeferredDocumentImpl.setChunkIndex
> (DeferredDocumentImpl.java:1944)
>     at
> com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl.appendChild
> (DeferredDocumentImpl.java:644)
>     at
> com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser.characters
> (AbstractDOMParser.java:1191)
>     at
> com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.characters
> (XMLDTDValidator.java:862)
>     at
>
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument

> (XMLDocumentFragmentScannerImpl.java:463)
>     at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
> (XML11Configuration.java:807)
>     at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
> (XML11Configuration.java:737)
>     at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
> (XMLParser.java:107)
>     at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse
> (DOMParser.java:225)
>     at
> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse
> (DocumentBuilderImpl.java:283)
>     at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)
>     at XMLParser.Parse(XMLParser.java:89)
>     at Main.main(Main.java:116)
>
>
> 89 line number points to -> doc = builder.parse(xmlDataFile);
>
> i was able to find the workaround  if i add this code
>
>  aFactory.setFeature
("http://apache.org/xml/features/dom/defer-node-expansion
> ", false);
>
> the issue is resolved. But i need to know the cause of this problem.
> Was the entity the cause?
>
> Thanks
> Sri kumar

Reply via email to