• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh btw, the topic should say external dtd instead of internal dtd. Sorry for the confusion.
 
Die Fledermaus does not fear such a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic