1 21 22 package nu.xom.samples; 23 24 import java.io.IOException ; 25 26 import nu.xom.Builder; 27 import nu.xom.ParsingException; 28 import nu.xom.ValidityException; 29 30 41 public class PureValidator { 42 43 public static void main(String [] args) { 44 45 if (args.length <= 0) { 46 System.out.println("Usage: java nu.xom.samples.PureValidator URL"); 47 return; 48 } 49 50 try { 51 Builder parser = new Builder(true, new MinimalNodeFactory()); 52 parser.build(args[0]); 53 System.out.println(args[0] + " is valid."); 54 } 55 catch (ValidityException ex) { 56 System.out.println(args[0] + " is not valid."); 57 System.out.println(ex.getMessage()); 58 System.out.println(" at line " + ex.getLineNumber() 59 + ", column " + ex.getColumnNumber()); 60 } 61 catch (ParsingException ex) { 62 System.out.println(args[0] + " is not well-formed."); 63 System.out.println(ex.getMessage()); 64 System.out.println(" at line " + ex.getLineNumber() 65 + ", column " + ex.getColumnNumber()); 66 } 67 catch (IOException ex) { 68 System.out.println( 69 "Due to an IOException, the parser could not check " 70 + args[0] 71 ); 72 } 73 74 } 75 76 } | Popular Tags |