XML validation: Difference between revisions
Content added Content deleted
(→Java: Added implementation) |
m (→{{header|Java}}: Tidy up) |
||
Line 52: | Line 52: | ||
public class XmlValidation { |
public class XmlValidation { |
||
public static void main(String... args) throws MalformedURLException |
public static void main(String... args) throws MalformedURLException { |
||
SAXException { |
|||
URL schemaLocation = new URL("http://venus.eas.asu.edu/WSRepository/xml/Courses.xsd"); |
URL schemaLocation = new URL("http://venus.eas.asu.edu/WSRepository/xml/Courses.xsd"); |
||
URL documentLocation = new URL("http://venus.eas.asu.edu/WSRepository/xml/Courses.xml"); |
URL documentLocation = new URL("http://venus.eas.asu.edu/WSRepository/xml/Courses.xml"); |
||
Line 71: | Line 70: | ||
validator.setErrorHandler(new ErrorHandler(){ |
validator.setErrorHandler(new ErrorHandler(){ |
||
@Override |
@Override |
||
public void warning(SAXParseException exception) |
public void warning(SAXParseException exception) { |
||
throws SAXException { |
|||
System.out.println("warning: " + exception.getMessage()); |
System.out.println("warning: " + exception.getMessage()); |
||
} |
} |
||
@Override |
@Override |
||
public void error(SAXParseException exception) |
public void error(SAXParseException exception) { |
||
throws SAXException { |
|||
System.out.println("error: " + exception.getMessage()); |
System.out.println("error: " + exception.getMessage()); |
||
valid.value = false; |
valid.value = false; |
||
Line 84: | Line 81: | ||
@Override |
@Override |
||
public void fatalError(SAXParseException exception) |
public void fatalError(SAXParseException exception) throws SAXException { |
||
throws SAXException { |
|||
System.out.println("fatal error: " + exception.getMessage()); |
System.out.println("fatal error: " + exception.getMessage()); |
||
throw exception; |
throw exception; |