gov.nih.nci.cagrid.common
Class SchemaValidator

java.lang.Object
  extended by gov.nih.nci.cagrid.common.SchemaValidator

public class SchemaValidator
extends java.lang.Object

SchemaValidator Validates XML documents against a schema. For validating multiple documents against the same schema, create an instance of this class with the schema filename and pass the documents to the validator in succession to save on the overhead of creating new parser factories.

Version:
$Id$
Author:
David W. Ervin

Field Summary
static java.lang.String JAXP_SCHEMA_LANGUAGE
           
static java.lang.String JAXP_SCHEMA_SOURCE
           
static java.lang.String W3C_NAMESPACE
           
 
Constructor Summary
SchemaValidator(java.lang.String schemaFilename)
          Initializes the schema validator to perform validation against an XML Schema
 
Method Summary
static void main(java.lang.String[] args)
          This utility can be run from the command line as well
 void validate(java.io.File xmlFile)
          Validates the contents of an XML file against the schema
 void validate(java.lang.String xml)
          Validates XML against the schema
static void validate(java.lang.String xsdFilename, java.io.File xmlFile)
          Validates the contents of an XML file against an xml schema
static void validate(java.lang.String xsdFilename, java.lang.String xmlText)
          Validates xml text against an xml schema
static void verify(java.lang.String xsdFilename)
          Verify that a schema is well formed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAXP_SCHEMA_LANGUAGE

public static final java.lang.String JAXP_SCHEMA_LANGUAGE
See Also:
Constant Field Values

JAXP_SCHEMA_SOURCE

public static final java.lang.String JAXP_SCHEMA_SOURCE
See Also:
Constant Field Values

W3C_NAMESPACE

public static final java.lang.String W3C_NAMESPACE
See Also:
Constant Field Values
Constructor Detail

SchemaValidator

public SchemaValidator(java.lang.String schemaFilename)
                throws SchemaValidationException
Initializes the schema validator to perform validation against an XML Schema

Parameters:
schemaFilename - The filename of the schema to use for validation
Throws:
SchemaValidationException
Method Detail

validate

public void validate(java.lang.String xml)
              throws SchemaValidationException
Validates XML against the schema

Parameters:
xml - The XML text to validate
Throws:
SchemaValidationException

validate

public void validate(java.io.File xmlFile)
              throws SchemaValidationException
Validates the contents of an XML file against the schema

Parameters:
xmlFile - The file to load XML from for validation
Throws:
SchemaValidationException

validate

public static void validate(java.lang.String xsdFilename,
                            java.lang.String xmlText)
                     throws SchemaValidationException
Validates xml text against an xml schema

Parameters:
xsdFilename - The filename of the xml schema to validate against
xmlText - The text of an xml document to be validated
Throws:
SchemaValidationException

verify

public static void verify(java.lang.String xsdFilename)
                   throws SchemaValidationException
Verify that a schema is well formed

Parameters:
xsdFilename -
Throws:
SchemaValidationException

validate

public static void validate(java.lang.String xsdFilename,
                            java.io.File xmlFile)
                     throws SchemaValidationException
Validates the contents of an XML file against an xml schema

Parameters:
xsdFilename - The filename of the xml schema to validate against
xmlFile - The file to load XML from for validation
Throws:
SchemaValidationException

main

public static void main(java.lang.String[] args)
This utility can be run from the command line as well

Parameters:
args -