xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott M Stark" <sst...@bear.com>
Subject Should the ParserFactory example work?
Date Sat, 12 Feb 2000 10:16:30 GMT
A simple example of creating a parser using method 1 "How do I construct a
parser in Xerces-J v1.0?"
using either the 1.0.0 or 1.0.1 parsers produces a ClassCastException
because org.apache.xerces.parsers.DOMParser
does not implement the org.xml.sax.Parser interface. What am I not
understanding here?

import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Document;
import org.xml.sax.Parser;
import org.xml.sax.helpers.ParserFactory;
import org.xml.sax.SAXException;

class tstXerces
 public static void main(String[] args) throws Exception
  String parserClass = "org.apache.xerces.parsers.DOMParser";
  Parser parser = ParserFactory.makeParser(parserClass);

bash-2.02$ java -cp "/Java/xerces-1_0_1/xerces.jar;." tstXerces
Exception in thread "main" java.lang.ClassCastException:
        at tstXerces.main(tstXerces.java:14)

Bear Stearns is not responsible for any recommendation, solicitation, 
offer or agreement or any information about any transaction, customer 
account or account activity contained in this communication.

View raw message