I haven't implemented this with XMLReaderFactory, but if you're willing to try, you can load the class with the following code:
 
XMLReader parser = (XMLReader) Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
 
 
----- Original Message -----
From: Rob Outar
Sent: Monday, October 28, 2002 3:13 PM
Subject: Class Cast Exception

I am trying to upgrade to  Xerces 2, we are trying something very trivial but it will not work:
 
import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
 

/**
 * @testcase net.onesaf.services.data.xml.sax.TestSAX
 */
public class SAX {
 

    public SAX(){
        try {
            System.out.println("In here");
        XMLReader parser = XMLReaderFactory.createXMLReader(
     "org.apache.xerces.parsers.SAXParser");
   System.out.println("out here");
        }
        catch(Exception e){
   System.out.print(e);
        }
    }
 
but we keep getting a ClassCastException
In here
 
java.lang.ClassCastException
 
What are we doing wrong?
 
Thanks,
 
Rob

Reply via email to