[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to use SAX to validate XML against a schema?
Ok. Elliotte. There are these additional lines: ---> factory.setValidating(true); ---> factory.setNamespaceAware(true); SAXParserFactory factory = SAXParserFactory.newInstance(); ---> factory.setValidating(true); ---> factory.setNamespaceAware(true); 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); Regards, Jairton. ----- Original Message ----- From: "Elliotte Rusty Harold" <elharo@m...> To: "Jose Airton" <jairtonf@y...> Cc: <xml-dev@l...> Sent: Monday, March 29, 2004 2:57 PM Subject: Re: 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 > elharo@m... > Effective XML (Addison-Wesley, 2003) > http://www.cafeconleche.org/books/effectivexml > http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|