Re: [xml-dev] How to use SAX to validate XML against a schema?

From
Elliotte Rusty Harold <>
To
Jose Airton <>
Date
2004-03-29T17:57:41Z
ID
<p06010201bc8e13dd1ea1@[67.31.7.120]>
Thread
Re: [xml-dev] How to use SAX to validate XML against a schema?
At 2:26 PM -0300 3/29/04, Jose Airton wrote:
I found this solution:

     SAXParserFactory factory = SAXParserFactory.newInstance();
     SAXParser saxParser = factory.newSAXParser();
     XMLReader xmlReader = saxParser.getXMLReader();
 
xmlReader.setFeature("<http://apache.org/xml/features/validation/schema>http://apache.org/xml/features/validation/schema", 
true);

This likely will not work because the parser you have created is not 
namespace aware.

Do not use SAXParserFactory or SAXParser ever. Use XMLReaderFactory 
and XMLReader instead.
-- 

   Elliotte Rusty Harold
   
   Effective XML (Addison-Wesley, 2003)
   http://www.cafeconleche.org/books/effectivexml            
   http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA