I'm posting this again, because nobody answered this the first time-

I am writing an XML book for O'Reilly, and trying to use Xerces as _the_
suggested parser, but am going to need to get some answers on this and
other questions, so please speak up, this could be a nice boost for
Xerces...

Two questions:

1) Is the SAX Parser in Xerces capable of validation?  I assume it is...

2) What is the preferred way to set this mechanism?

        I know SAX2 and the Configurable interface say to do something
like:

        // Request core feature - validation
        parser.setFeature("http://xml.org/....";, true);

        parser.parse(uri);

But to do this, the only way I seem to be able to get the parser is to
instantiate it directly.  In other words:

        Parser parser =
Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
        // Do other things with this parser

But this seems to not be so great.  I would much rather use the
ParserFactory from SAX:

        Parser parser =
ParserFactory.makeParser("org.apache.xerces.parsers.SAXParser");

I know the differnce isn't much, but it seems to be the best way to do
this, as well as much more OO (IMHO).  But it doesn't seem that
org.xml.sax.Parser implements Configurable.  So is there a standard way
to get a SAX Parser and set it's validation feature, without resorting
to a "brute-force" newInstance() call on the class?  Any help would be
appreciated.

Thanks,
Brett

Reply via email to