IntelliJ Java IDE
The moose likes XML and Related Technologies and the fly likes XMLReader versus SAXParser Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "XMLReader versus SAXParser" Watch "XMLReader versus SAXParser" New topic
Author

XMLReader versus SAXParser

Kevin Newsom
Greenhorn

Joined: Jul 02, 2001
Posts: 6
I have a series of SAX2 applications that use the constructor SAXParser() to create an instance of the parser.
XMLReader reader = new SAXParser();
These applications work fine.
The O'Reilly book on Java and XML indicates that this class (SAXParser) implements the org.xml.sax.XMLReader interface (pg. 50). If I change my code to use XMLReader instead of SAXParser, I get a ClassNotFoundException: org.apache.xerces.parsers.SAXParser.
Here's the code line that changed:
XMLReader parser = XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser");
Can anyone explain to me why? This problem is also causing me troubles when trying to use Xalan.
Kevin Newsom
Greenhorn

Joined: Jul 02, 2001
Posts: 6
I'm touching this in the hopes of someone seeing it at the top of the list. I'm really stumped on this problem.
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5781
Does it work if you use SAXParserFactory.newSAXParser() ??


Open Group Certified Master IT Architect.
Sun Certified Architect(SCEA).
Kevin Newsom
Greenhorn

Joined: Jul 02, 2001
Posts: 6
Well, I got this to work by implanting the code from XMLReaderFactory into my parsing class. In particular the line:
return (XMLReader)(Class.forName(className).newInstance());
doesn't throw a class not found exception when it is within 'my' class that parses the document.
I still don't know why it wouldn't work before.
I still think I have a problem when using Xalan but we'll see.
Kevin Newsom
Greenhorn

Joined: Jul 02, 2001
Posts: 6
I got it working in the manner that it should. I had to place the appropriate jar files in the lib/ext folder. Having them in the class path didn't seem to cut it.
 
 
subject: XMLReader versus SAXParser
 
Threads others viewed
help on newInstance() method
getting started with xml
Parsing xml file using SAX
error executing ...
parsing confusion
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture