JDOM Validator

import org.jdom.input.*;
import org.jdom.JDOMException;
import org.xml.sax.*;
import java.io.*;


public class JDOMValidator {

  public static void main(String[] args) {

    SAXBuilder parser = new SAXBuilder(true);

    if (args.length == 0) {
      System.out.println("Usage: java JDOMValidator URL1 URL2...");
    }

    // start parsing...
    for (int i = 0; i < args.length; i++) {

      // command line should offer URIs or file names
      try {
        parser.build(args[i]);
        // If there are no well-formedness errors,
        // then no exception is thrown
        System.out.println(args[i] + " is well formed.");
      }
      catch (JDOMException e) { 
        System.out.println(args[i] + " is not valid.");
        System.out.println(e.getMessage());
      }

    }

  }

}

Previous | Next | Top | Cafe con Leche

Copyright 2000-2002 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified November 29, 2000