2 import java.io.IOException;
3 import javax.xml.parsers.DocumentBuilderFactory;
4 import javax.xml.parsers.DocumentBuilder;
5 import javax.xml.parsers.ParserConfigurationException;
6 import org.w3c.dom.Document;
7 import org.xml.sax.SAXException;
8 import org.xml.sax.SAXParseException;
9 import org.xml.sax.ErrorHandler;
26 public static void main(String[] args) {
29 DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
30 fac.setValidating(
true);
33 DocumentBuilder b = fac.newDocumentBuilder();
37 Document d = b.parse(
new java.io.FileInputStream(fil),
38 args[1] + File.separator);
40 catch(SAXException e) {
41 System.err.println(e.getMessage());
43 catch(IOException e) {
44 System.err.println(e.getMessage());
46 catch (ParserConfigurationException e) {
47 System.err.println(e.getMessage());
59 public void warning(SAXParseException e)
throws SAXException {
69 public void error(SAXParseException e)
throws SAXException {
79 public void fatalError(SAXParseException e)
throws SAXException {
89 private void printInfo(String s, SAXParseException e) {
90 System.err.println(s +
92 + e.getLineNumber() +
": "
void fatalError(SAXParseException e)
Writes error messages to System.err
void warning(SAXParseException e)
Writes warning messages to System.err
static void main(String[] args)
Main method.
void printInfo(String s, SAXParseException e)
Prints the error message to System.err
Inner class for error handling.
void error(SAXParseException e)
Writes error messages to System.err
Class to validate xml files.