Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Nitish Naharas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you check if you get the same error even when you don't use a DTD ?
 
Nitish Naharas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh btw, the topic should say external dtd instead of internal dtd. Sorry for the confusion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic