edu.ntnu.item.jt.configloader
Class XMLValidator

java.lang.Object
  extended by edu.ntnu.item.jt.configloader.XMLValidator

public class XMLValidator
extends Object

A class that contains methods for validating an XML file against a DTD or a W3C XML Schema (XSD).

Technique borrowed from http://www.roseindia.net/xml/dom/DOMValidateDTD.shtml.

Author:
Thomas Langerud

Field Summary
(package private)  String javaEncoding
           
(package private)  String parserClass
           
(package private)  String schemaFeature
           
(package private)  String schemaLocationFeature
           
(package private)  String validationFeature
           
 
Constructor Summary
XMLValidator()
           
 
Method Summary
 void validateDTD(String XMLFile, String DTDFile, int tempdata)
          Method that checks an XML file against a DTD file.
 void validateXSD(String XMLFile)
          Method to validate an XML file against a W3C XML Schema Definition (XSD)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parserClass

String parserClass

validationFeature

String validationFeature

schemaFeature

String schemaFeature

schemaLocationFeature

String schemaLocationFeature

javaEncoding

String javaEncoding
Constructor Detail

XMLValidator

public XMLValidator()
Method Detail

validateDTD

public void validateDTD(String XMLFile,
                        String DTDFile,
                        int tempdata)
                 throws XMLValidationException
Method that checks an XML file against a DTD file. If the XML file is well formed and valid according to the DTD, nothing happens If the XML file is not well formed, or not valid, an exception is raised. Well formed means that the XML file conforms to the rules of the XML language (start and end tags, correct nesting, attributes in quotes) Valid documents are always well formed, but well formed documents need not be valid

Parameters:
XMLFile - Path to the XML file that is to be validated
DTDFile - Path to the DTD file against which XMLFile is to be validated
tempdata - value 1 if the XML document should be written to std.out, 2 if a temp file should be used (temp.tmp)
Throws:
XMLValidationException

validateXSD

public void validateXSD(String XMLFile)
                 throws XMLValidationException,
                        FileNotFoundException
Method to validate an XML file against a W3C XML Schema Definition (XSD)

Parameters:
XMLFile - The XML document to validate
Throws:
XMLValidationException - If the XML document is not well formed
FileNotFoundException - If the XML document is not found