Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with using Xerces1_3_0 to parse xml file

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi All
do i need to set my classpath to anything with Xerces1_3_0?
when i try to use it with the following java application and xml filw i got classNotFound,please any help with that.
here is the two files:
//package com.psol.xbe;
import org.xml.sax.*;
import org.xml.sax.helpers.ParserFactory;
public class Cheapest extends HandlerBase
{
protected double min=Double.MAX_VALUE;
protected String vendor = null;
public void startElement(String name,AttributeList attributes)
{
if(name.equals("price"))
{
String attribute = attributes.getValue("price");
if(null!=attribute)
{
double price = toDouble(attribute);
if(min>price)
{
min=price;
vendor=attributes .getValue("vendor");
}

}
}
}

protected double toDouble(String string)
{
Double stringDouble = Double.valueOf(string);
if(null != stringDouble)
return stringDouble.doubleValue();
else
return 0.0;

}
public String getVendor()
{
return vendor;

}
public double getMinimum()
{
return min;
}
protected static final String PARSER_NAME = "com.ibm.parsers.SAXParser";
public static void main(String args[]) throws Exception
{
/*
if(args.length <1)
{
System.out.println(&quot;java com.psol.xbe.CheapestClfilename &quot;);
return ;

}

*/

Cheapest cheapest = new Cheapest();

Parser parser = ParserFactory.makeParser(PARSER_NAME);
parser.setDocumentHandler(cheapest);
parser.parse(&quot;c:/javaMatt/prices.xml&quot;);
System.out.println(&quot;the cheapest offer is &quot; + cheapest.getVendor() + &quot; $&quot; + cheapest.getMinimum() + ')');

}

}
//===========================================================


<?xml version=&quot;1.0&quot;?>
<product>
<name> XML Training </name>
<price price=&quot;999.00&quot; vendor=&quot;playfield training&quot;/>
<price price=&quot;699.00&quot; vendor=&quot;xmli&quot;/>
<price price=&quot;799.00&quot; vendor=&quot;writeit&quot;/>
<price price=&quot;899.00&quot; vendor=&quot;emailaholic&quot;/>
</product>

 
> do i need to set my classpath to anything with Xerces1_3_0?

Where did you get it? Are there any instructions for using it, like a readme.txt file or a web page of instructions?

If you can't get it to work by following the instructions or if there aren't any, you might consider getting the JAXP package from There are great instructions and we have had no problems getting it working.

Good luck
-pete
 
Tom,

Certainly all the packages that your class imports have to be in the CLASSPATH somewhere; and presumably your parser &quot;com.ibm.parsers.SAXParser&quot; is to be found in one of the packages somwhere as well?

To track this down, you'd want to know at what line the error message comes, then you can work out which package it can't find.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top