Hi
Yong
This
is how I'm doing.
The
XML document shall contain a schema location attribute in the root
element.
SAXParserFactory spf =
SAXParserFactory.newInstance();
spf.setNamespaceAware(true); spf.setValidating(true); spf.setFeature("http://xml.org/sax/features/validation", true); spf.setFeature("http://apache.org/xml/features/validation/schema", true); SAXParser sp = spf.newSAXParser(); SAXErrorHandler eh = new SAXErrorHandler(); XMLReader xmlr = sp.getXMLReader(); xmlr.setErrorHandler(eh); StringReader sr = new StringReader(param); //param is a String representation of the XML document org.xml.sax.InputSource is = new org.xml.sax.InputSource(sr); xmlr.parse(is); /Jakob
-----Oprindelig meddelelse-----
Fra: Miao, Yong [mailto:[EMAIL PROTECTED] Sendt: 15. december 2003 22:52 Til: '[EMAIL PROTECTED]' Emne: How to validate a xml document against a schema? Hi,
Could someone direct me to a Java sample of validating xml document against a schema? The schema may be come with xml document or specified externally.
Thanks, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sr. Staff Engineer Aspen Technology,
Inc. Phone: 425-492-2204 Fax: 425-492-2392 Email:[EMAIL PROTECTED] http://www.aspentech.com/
|
Title: Meddelelse
- How to validate a xml document against a schema? Miao, Yong
- Re: How to validate a xml document against a sc... Scott Nichol
- Hans Jakob Skovenborg