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("java com.psol.xbe.CheapestClfilename "
return ;
}
*/
Cheapest cheapest = new Cheapest();
Parser parser = ParserFactory.makeParser(PARSER_NAME);
parser.setDocumentHandler(cheapest);
parser.parse("c:/javaMatt/prices.xml"
System.out.println("the cheapest offer is " + cheapest.getVendor() + " $" + cheapest.getMinimum() + ')');
}
}
//===========================================================
<?xml version="1.0"?>
<product>
<name> XML Training </name>
<price price="999.00" vendor="playfield training"/>
<price price="699.00" vendor="xmli"/>
<price price="799.00" vendor="writeit"/>
<price price="899.00" vendor="emailaholic"/>
</product>
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("java com.psol.xbe.CheapestClfilename "
return ;
}
*/
Cheapest cheapest = new Cheapest();
Parser parser = ParserFactory.makeParser(PARSER_NAME);
parser.setDocumentHandler(cheapest);
parser.parse("c:/javaMatt/prices.xml"
System.out.println("the cheapest offer is " + cheapest.getVendor() + " $" + cheapest.getMinimum() + ')');
}
}
//===========================================================
<?xml version="1.0"?>
<product>
<name> XML Training </name>
<price price="999.00" vendor="playfield training"/>
<price price="699.00" vendor="xmli"/>
<price price="799.00" vendor="writeit"/>
<price price="899.00" vendor="emailaholic"/>
</product>