xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Elliotte Harold <elharo AT metalab.unc.edu>
- To: vikas yadav <vikas.m.yadav AT gmail.com>
- Cc: xom-interest <xom-interest AT lists.ibiblio.org>
- Subject: Re: [XOM-interest] How to parse XML Schema?
- Date: Fri, 11 Feb 2005 03:21:25 -0500
vikas yadav wrote:
I know how t oparse xml file which have DTD validation
But if xml file have xml schema validation ,then how t oparse that xml file by
using XOM,
Bye....
This is a FAQ, but I don't seem to have added it to the FAQ list. Oops. Sorry bout that. It is addressed in the tutorial though:
http://www.xom.nu/tutorial.xhtml#d0e530
Quoting from that:
For example, suppose you want to use Xerces to perform schema validation. You would set up the Builder thusly:
String url = "http://www.example.com/";
try {
XMLReader xerces = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
xerces.setFeature("http://apache.org/xml/features/validation/schema", true);
Builder parser = new Builder(xerces, true);
parser.build(url);
System.out.println(args[0] + " is schema valid.");
}
catch (SAXException ex) {
System.out.println("Could not load Xerces.");
System.out.println(ex.getMessage());
}
catch (ParsingException ex) {
System.out.println(args[0] + " is not schema valid.");
System.out.println(ex.getMessage());
System.out.println(" at line " + ex.getLineNumber()
+ ", column " + ex.getColumnNumber());
}
catch (IOException ex) {
System.out.println("Due to an IOException, Xerces could not check " + args[0]);
}
--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
-
[XOM-interest] How to parse XML Schema?,
vikas yadav, 02/10/2005
- Re: [XOM-interest] How to parse XML Schema?, Elliotte Harold, 02/11/2005
Archive powered by MHonArc 2.6.24.