[
Lists Home |
Date Index |
Thread Index
]
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@metalab.unc.edu>
To: "Jose Airton" <jairtonf@yahoo.com.br>
Cc: <xml-dev@lists.xml.org>
Sent: Monday, March 29, 2004 2:57 PM
Subject: 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
> elharo@metalab.unc.edu
> Effective XML (Addison-Wesley, 2003)
> http://www.cafeconleche.org/books/effectivexml
>
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA
|