Hi there, I'm in the process of trying to convert a programme from using many different parsers, to just using the Xerces one... and I encountered the same problem. I'm sure my project is in the classpath (which is set thru a batch file) but when I run I get : File: C:\apps\jas\etc\ds.xml not found.
Any other ideas why it might not be working? (I converted a NonValidatingDomParser from ibm to a DOMParser) Thanks in advance, Allison > -----Original Message----- > From: giuseppe laricchiuta [SMTP:[EMAIL PROTECTED] > Sent: Monday, September 11, 2000 4:27 AM > To: [EMAIL PROTECTED] > Subject: Re: SAXException > > Rohit, > > You have classpath problem. > > I had the same problem, my test project has this classpath > parser.MyContentHandler > and the command I use to run the class SaxParserDemo is: > c:\..\theFolder where the contents.xml file is parser.MyContentHandler > contents.xml > first to run this make sure you have in the classpath all the classes you > need (use a batch fiele > to set within a dos shell session the classpath) > > > have fun with it > > for anything you need drop me an e-mail > > giuseppe > > > giuseppe laricchiuta > Bauer & Partner the business and technology group > Schützenmattstrasse 266 > Ch 8180 Bülach > tel.+41(0)1-86418-00 > fax.+ 41(0)1-86418-44 > www.bauer-partner.de > [EMAIL PROTECTED] > > > [EMAIL PROTECTED] wrote: > > > Hey All, > > I was trying out a simple example from the book Java and XML(Brett > > McLaughlin), wherein i initiate the SAX parser by passing it a URI. > > Unfortunately, the org.xml.sax.Exception is generated whenever i run > the > > program. The XML document exists in the same directory as the program. > This is > > what i entered in the Command prompt window: > > C:\XML\XMLBooks\JavaXML\Chapter3\java SAXParserDemo contents.xml > > The java interpreter generated the following error: > > Error in parsing: File > "file:///C:/XML/XMLBooks/JavaXML/Chapter3/contents.xml" > > not found. > > > > I tried using the complete pathname to the XML document but still got an > error: > > C:\XML\XMLBooks\JavaXML\Chapter3\java SAXParserDemo > > C:\XML\XMLBooks\JavaXML\Chapter3\contents.xml > > ( Note : No Linebreak in actual command) > > I got the following error: > > Error in parsing: File "C:\XML\XMLBooks\JavaXML\Chapter3\contents.xml" > not > > found. > > > > However, the exception is not generated when i hardcode the name of the > file in > > the program as in: > > parser.parse("contents.xml"); > > > > I appreciate and thanks in advance for any answers/suggestions. > > > > Here is the code i compiled (From the book : Java and XML by Brett > McLaughlin): > > > > > __________________________________________________________________________ > ____________________ > > > > // File : SAXParserDemo.java - Parse an XML file using SAX, > > // displaying callbacks in the parsing lifecycle. > > > > import java.io.IOException; // Exceptions that can result from loading > XML Doc > > > > import org.xml.sax.SAXException; // Exceptions generated while parsing > XML > > Doc. > > > > import org.xml.sax.XMLReader; // Interface for reading XML Docs using > callbacks > > import org.apache.xerces.parsers.SAXParser; // Xerces implementation > of > > XMLReader > > > > /* Function : SAXParserDemo > > * Instatiates the Parser. > > */ > > public class SAXParserDemo > > { > > public void performDemo(String uri) > > { > > System.out.println("Parsing XML file: " + uri + "\n\n"); > > > > try > > { > > // Instantiates a parser > > XMLReader parser = new SAXParser(); > > > > // Parse the document > > parser.parse(uri); > > } catch (IOException e) { > > System.out.println("Error reading URI: " + > e.getMessage()); > > } catch (SAXException e) { > > System.out.println("Error in parsing: " + > e.getMessage()); > > } > > > > } > > > > public static void main(String[] args) > > { > > if (args.length != 1) > > { > > System.out.println("Usage: java SAXParserDemo [XML > URI]"); > > System.exit(0); > > } > > > > String uri = args[0]; > > SAXParserDemo parserDemo = new SAXParserDemo(); > > parserDemo.performDemo(uri); > > } > > } >