glassfrog.tools
Class XMLValidator

java.lang.Object
  extended by glassfrog.tools.XMLValidator

public class XMLValidator
extends java.lang.Object

A class to validate a given XML file with a specified XML Schema. This will help eliminate any errors the user has when putting together the config files associated with the server by catching them and returning the message to the user before any execution

Author:
jdavidso

Field Summary
private  javax.xml.parsers.DocumentBuilder builder
           
private  javax.xml.parsers.DocumentBuilderFactory factory
           
private  java.lang.String xsdFile
           
 
Constructor Summary
XMLValidator(java.lang.String xsdFile)
          The constructor for the validator.
 
Method Summary
 void setSchema(java.lang.String xsdFile)
          Set the schema for the xml to validate against
 boolean validateXML(java.lang.String xmlFile)
          Run the xml validator on the fgiven file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xsdFile

private java.lang.String xsdFile

factory

private javax.xml.parsers.DocumentBuilderFactory factory

builder

private javax.xml.parsers.DocumentBuilder builder
Constructor Detail

XMLValidator

public XMLValidator(java.lang.String xsdFile)
The constructor for the validator. This will set up the DocumentBuilder and the associated XML Schema file for this validator.

Parameters:
xsdFile - A path to the XML Schema to use
Method Detail

setSchema

public void setSchema(java.lang.String xsdFile)
Set the schema for the xml to validate against

Parameters:
xsdFile - a path to the xsd to validate against

validateXML

public boolean validateXML(java.lang.String xmlFile)
                    throws javax.xml.parsers.ParserConfigurationException,
                           org.xml.sax.SAXException,
                           java.io.IOException
Run the xml validator on the fgiven file

Parameters:
xmlFile - The file to validate
Returns:
True for a valid XML file, False otherwise
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException