aspose file tools*
The moose likes XML and Related Technologies and the fly likes SAXParser causes a null pointer exception when using internal DTD declaration? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAXParser causes a null pointer exception when using internal DTD declaration?" Watch "SAXParser causes a null pointer exception when using internal DTD declaration?" New topic
Author

SAXParser causes a null pointer exception when using internal DTD declaration?

Nitish Naharas
Greenhorn

Joined: Jul 24, 2001
Posts: 6
Hi,
when using SAXParser with internal DTD declaration similar to the following xml code snippet, I am getting a null pointer exception in xerces 1.4.1. This occurs when the code to invoke parsing is executed i.e.
saxParser.parse(inputSource, new InXMLHandler());

The xml snippet is:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by Joe Coveney (Indus International) -->
<!DOCTYPE InboundRequest [
<!ELEMENT InboundRequest (APIHeader, BusinessObject)>
<!ENTITY % APIHeader SYSTEM "APIHeader.dtd">
%APIHeader;
<!ENTITY % BusinessObject SYSTEM "Catalog.dtd">
%BusinessObject;
]>
the exception when trying to run it is:
java.lang.NullPointerException
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1094)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:374)
at testclass.ParsingTest.main(ParsingTest.java:59)
at symantec.tools.debug.Agent.runMain(Native Method)
at symantec.tools.debug.MainThread.run(Unknown Source)

Have you come across this problem? Any tips/pointers for me?
Regards,
Nitish
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Can you check if you get the same error even when you don't use a DTD ?


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Nitish Naharas
Greenhorn

Joined: Jul 24, 2001
Posts: 6
Ajith,
When I run the program without the external dtd declaration i.e. giving just one dtd name, it has been working.
In the case, where I get the exception, there is an entity declaration as part of DOCTYPE statement and have tried to access the entity using %entity-name, specifying different external dtd's for each entity.
Nitish Naharas
Greenhorn

Joined: Jul 24, 2001
Posts: 6
FYI.
I found that the same works using Sun's ref implementation using jaxp.jar etc. I have filed a bug with xerces J team.
Nitish Naharas
Greenhorn

Joined: Jul 24, 2001
Posts: 6
Oh btw, the topic should say external dtd instead of internal dtd. Sorry for the confusion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SAXParser causes a null pointer exception when using internal DTD declaration?