You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Gregor Karlinger <gr...@iaik.at> on 2000/11/02 12:04:54 UTC
Bug? in org.apache.xerces.readers.DefaultEntityHandler
Hi all,
I am trying to parse the following xml document with the xerces 1.2.1
parser:
---------------------------------------------------------------
<!DOCTYPE doc [
<!ELEMENT doc ANY>
<!ATTLIST doc attrExtEnt ENTITY #IMPLIED>
<!ENTITY ent1 "Hello">
<!ENTITY ent2 SYSTEM "world.txt">
<!ENTITY entExt SYSTEM "earth.gif" NDATA gif>
<!NOTATION gif SYSTEM "viewgif.exe">
]>
<doc attrExtEnt="entExt">
&ent1;, &ent2;!
</doc>
<!-- Let world.txt contain "world" (excluding the quotes) -->
---------------------------------------------------------------
I am using the following code to establisch the non-validating
parser:
---------------------------------------------------------------
DOMParser domParser = new DOMParser();
domParser.setFeature("http://xml.org/sax/features/validation", false);
domParser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false);
domParser.setIncludeIgnorableWhitespace(false);
domParser.setFeature("http://xml.org/sax/features/namespaces", true);
InputSource inputSource = new InputSource(testFile);
domParser.parse(inputSource);
---------------------------------------------------------------
I get an exeption when trying to parse the file. See the stack trace:
---------------------------------------------------------------
java.lang.NullPointerException
at org.apache.xerces.utils.StringPool.addSymbol(StringPool.java:348)
at org.apache.xerces.readers.DefaultEntityHandler.addExternalEntityDecl(DefaultEntityHandler.java:226)
at org.apache.xerces.framework.XMLDTDScanner.scanEntityDecl(XMLDTDScanner.java:2808)
at org.apache.xerces.framework.XMLDTDScanner.scanDecls(XMLDTDScanner.java:1441)
at org.apache.xerces.framework.XMLDTDScanner.scanDoctypeDecl(XMLDTDScanner.java:1115)
at org.apache.xerces.framework.XMLDocumentScanner.scanDoctypeDecl(XMLDocumentScanner.java:2177)
at org.apache.xerces.framework.XMLDocumentScanner.access$000(XMLDocumentScanner.java:86)
at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.dispatch(XMLDocumentScanner.java:775)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:380)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
---------------------------------------------------------------
Stepping into the xerces code, I found the reason in the class
org.apache.xerces.readers.DefaultEntityHandler, in method
addExternalEntityDecl:
Since the value of the field "fSystemId" is null, invoking the
method StringPool.addSymbol in line 226 results in a
NullPointerException?
What is the reason for this behaviour?
Regards, Gregor
---------------------------------------------------------------
Gregor Karlinger
mailto:gregor.karlinger@gmx.net
http://GregorKarlinger.tsx.org
Student of Telematics
Graz, Austria
---------------------------------------------------------------
AW: Bug? in org.apache.xerces.readers.DefaultEntityHandler
Posted by Gregor Karlinger <gr...@iaik.at>.
Hi all,
I have just recognized the reason for this error. Since I have created
the InputSource for the DOMParser from a FileInputStream without explicitely
setting the system id, the "fSystemId" field of the DefaultEntityHandler has
been initialized with a null value.
Maybe the "fSystemId" should be checked against null before invoking the
StringPool.addSymbol method to avoid a NullPointerException.
Regards, Gregor
---------------------------------------------------------------
Gregor Karlinger
mailto:gregor.karlinger@iaik.at
http://www.iaik.at
Phone +43 316 873 5541
Institute for Applied Information Processing and Communications
Austria
---------------------------------------------------------------
> -----Ursprüngliche Nachricht-----
> Von: Gregor Karlinger [mailto:gregor.karlinger@iaik.at]
> Gesendet: Donnerstag, 02. November 2000 12:05
> An: ML Xerces
> Betreff: Bug? in org.apache.xerces.readers.DefaultEntityHandler
>
>
> Hi all,
>
> I am trying to parse the following xml document with the xerces 1.2.1
> parser:
>
> ---------------------------------------------------------------
> <!DOCTYPE doc [
> <!ELEMENT doc ANY>
> <!ATTLIST doc attrExtEnt ENTITY #IMPLIED>
> <!ENTITY ent1 "Hello">
> <!ENTITY ent2 SYSTEM "world.txt">
> <!ENTITY entExt SYSTEM "earth.gif" NDATA gif>
> <!NOTATION gif SYSTEM "viewgif.exe">
> ]>
> <doc attrExtEnt="entExt">
> &ent1;, &ent2;!
> </doc>
>
> <!-- Let world.txt contain "world" (excluding the quotes) -->
> ---------------------------------------------------------------
>
> I am using the following code to establisch the non-validating
> parser:
>
> ---------------------------------------------------------------
> DOMParser domParser = new DOMParser();
> domParser.setFeature("http://xml.org/sax/features/validation", false);
>
> domParser.setFeature("http://apache.org/xml/features/continue-afte
> r-fatal-error", false);
> domParser.setIncludeIgnorableWhitespace(false);
> domParser.setFeature("http://xml.org/sax/features/namespaces", true);
> InputSource inputSource = new InputSource(testFile);
> domParser.parse(inputSource);
> ---------------------------------------------------------------
>
> I get an exeption when trying to parse the file. See the stack trace:
>
> ---------------------------------------------------------------
> java.lang.NullPointerException
> at org.apache.xerces.utils.StringPool.addSymbol(StringPool.java:348)
> at
> org.apache.xerces.readers.DefaultEntityHandler.addExternalEntityDe
> cl(DefaultEntityHandler.java:226)
> at
> org.apache.xerces.framework.XMLDTDScanner.scanEntityDecl(XMLDTDSca
> nner.java:2808)
> at
> org.apache.xerces.framework.XMLDTDScanner.scanDecls(XMLDTDScanner.
> java:1441)
> at
> org.apache.xerces.framework.XMLDTDScanner.scanDoctypeDecl(XMLDTDSc
> anner.java:1115)
> at
> org.apache.xerces.framework.XMLDocumentScanner.scanDoctypeDecl(XML
> DocumentScanner.java:2177)
> at
> org.apache.xerces.framework.XMLDocumentScanner.access$000(XMLDocum
> entScanner.java:86)
> at
> org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.d
> ispatch(XMLDocumentScanner.java:775)
> at
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocume
> ntScanner.java:380)
> at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
>
> ---------------------------------------------------------------
>
> Stepping into the xerces code, I found the reason in the class
> org.apache.xerces.readers.DefaultEntityHandler, in method
> addExternalEntityDecl:
>
> Since the value of the field "fSystemId" is null, invoking the
> method StringPool.addSymbol in line 226 results in a
> NullPointerException?
>
> What is the reason for this behaviour?
>
> Regards, Gregor
> ---------------------------------------------------------------
> Gregor Karlinger
> mailto:gregor.karlinger@gmx.net
> http://GregorKarlinger.tsx.org
> Student of Telematics
> Graz, Austria
> ---------------------------------------------------------------
>