Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » Newbie question: How to use SAX with Eclipse?
Newbie question: How to use SAX with Eclipse? [message #5353] Sun, 22 June 2003 17:33 Go to next message
Eclipse UserFriend
Originally posted by: sunifyre.yahoo.com

Hi,

I'm trying to develop a SAX application to read and parse an XML document
and output it to another file. However, I can't seem to figure out which
parser to use in Eclipse in the XMLReader object.

As it is, what I have done so far:
//
package xml2;
import org.xml.sax.*;
....
//Default parser to use
private String parserClass= "org.apache.xerces.parsers.SAXParser";
....
//Create instances needed for parsing
XMLReader reader = XMLReaderFactory.createXMLReader(parserClass);
....
//rest of code

For some reason, while this code compiles, it gives me a runtime error:
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
at
org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLRead erFactory.java:1
21)
at SAXTreeViewer.buildTree(SAXTreeViewer.java:49)
at SAXTreeViewer.init(SAXTreeViewer.java:38)
at SAXTreeViewer.main(SAXTreeViewer.java:66

Anyone have any suggestions, comments, advice please?

Thanks,

Sunitha Kumar
sunifyre@nospam.yahoo.com
Re: Newbie question: How to use SAX with Eclipse? [message #5403 is a reply to message #5353] Sun, 22 June 2003 17:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sunitha,

> I'm trying to develop a SAX application to read and parse an XML document
> and output it to another file. However, I can't seem to figure out which
> parser to use in Eclipse in the XMLReader object.
>
> As it is, what I have done so far:
> //
> package xml2;
> import org.xml.sax.*;
> ...
> //Default parser to use
> private String parserClass= "org.apache.xerces.parsers.SAXParser";
> ...
> //Create instances needed for parsing
> XMLReader reader = XMLReaderFactory.createXMLReader(parserClass);
> ...
> //rest of code
>
> For some reason, while this code compiles, it gives me a runtime error:
> java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
> at
>
org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLRead erFactory.java:1
> 21)
> at SAXTreeViewer.buildTree(SAXTreeViewer.java:49)
> at SAXTreeViewer.init(SAXTreeViewer.java:38)
> at SAXTreeViewer.main(SAXTreeViewer.java:66
>
> Anyone have any suggestions, comments, advice please?

Looks like a classpath problem. First of all you have created a java
project.
Then you placed your code in. Next step is to add the external libs (like
your xerces
parser). As far as I remember it the createXMLReader method uses forName
therefore
it wont through an compile exception on runtime.

You can add additional libraries in preferences of the project(project
contextmenu
(leftclick on project)). I think that helps.

Another solution is to stop using xerces and use the xml facility which is
shipped with
SDK 1.4. Look at the xml tutorial at java.sun.com.

I hope I could provide a solution,


Martin (Kersten)
Re: Newbie question: How to use SAX with Eclipse? [message #5408 is a reply to message #5403] Sun, 22 June 2003 18:13 Go to previous message
Eclipse UserFriend
Originally posted by: sunifyre.yahoo.com

"Martin Kersten" <Martin.Kersten@student.uni-magdeburg.de> wrote in message
news:bd58cm$6bn$1@rogue.oti.com...
>
> Another solution is to stop using xerces and use the xml facility which is
> shipped with SDK 1.4. Look at the xml tutorial at java.sun.com.

Thanks, Martin - I'll try that
=)
Previous Topic:XML tree viewer source
Next Topic:What is Web tools
Goto Forum:
  


Current Time: Mon Jun 09 06:28:53 EDT 2025

Powered by FUDForum. Page generated in 0.48586 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top