[Home] [By Thread] [By Date] [Recent Entries]


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


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member