Jsp Xerces Checker Java

From Fxp Wiki

Jump to: navigation, search
 
package vendo;
 
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import java.io.IOException;
 
//http://www.ibiblio.org/xml/books/xmljava/chapters/ch09s06.html
public class XercesChecker {
 
	
  public String XercesChecker(String document) {
      String monresult="";
    //if (args.length <= 0) {
	if (document == null) {
      monresult = ("Usage: java XercesChecker URL"); 
      return monresult;
    }
    //String document = args[0];
    
    DOMParser parser = new DOMParser();
    try {
      parser.parse(document); 
      monresult = (document + " is well-formed.");
    }
 
    catch (SAXException e) {
      monresult = (document + " is not well-formed.");
    }
    catch (IOException e) { 
      monresult = (monresult +
       "Due to an IOException, the parser could not check " 
       + document
      ); 
    }
   return monresult;
  }
 
}
 
 
 
Personal tools