public class XMLValidator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEFAULT_DYNAMIC_VALIDATION
Default dynamic validation support (false).
|
protected static boolean |
DEFAULT_MEMORY_USAGE
Default memory usage report (false).
|
protected static boolean |
DEFAULT_NAMESPACE_PREFIXES
Default namespace prefixes (false).
|
protected static boolean |
DEFAULT_NAMESPACES
Default namespaces support (true).
|
protected static java.lang.String |
DEFAULT_PARSER_NAME
Default parser name.
|
protected static boolean |
DEFAULT_SCHEMA_FULL_CHECKING
Default Schema full checking support (false).
|
protected static boolean |
DEFAULT_SCHEMA_VALIDATION
Default Schema validation support (false).
|
protected static boolean |
DEFAULT_TAGGINESS
Default "tagginess" report (false).
|
protected static boolean |
DEFAULT_VALIDATION
Default validation support (false).
|
protected static java.lang.String |
DYNAMIC_VALIDATION_FEATURE_ID
Dynamic validation feature id (http://apache.org/xml/features/validation/dynamic).
|
protected static java.lang.String |
NAMESPACE_PREFIXES_FEATURE_ID
Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes).
|
protected static java.lang.String |
NAMESPACES_FEATURE_ID
Namespaces feature id (http://xml.org/sax/features/namespaces).
|
protected static java.lang.String |
SCHEMA_FULL_CHECKING_FEATURE_ID
Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).
|
protected static java.lang.String |
SCHEMA_VALIDATION_FEATURE_ID
Schema validation feature id (http://apache.org/xml/features/validation/schema).
|
protected static java.lang.String |
VALIDATION_FEATURE_ID
Validation feature id (http://xml.org/sax/features/validation).
|
Constructor and Description |
---|
XMLValidator() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args)
The main program for the XMLValidator class
|
java.lang.StringBuffer |
validate(java.lang.String filePath)
Validate a single XML file or directory of XML files.
|
java.lang.StringBuffer |
validate(java.lang.String filePath,
java.util.Date modifiedSinceDate) |
java.lang.StringBuffer |
validate(java.lang.String filePath,
java.lang.String[] inputFileNames)
Validate a single XML file or directory of XML files, processing only the
xml files that match the ID list provided.
|
java.lang.StringBuffer |
validate(java.lang.String filePath,
java.lang.String[] inputFileNames,
java.lang.String reportFilePath,
java.util.Date modifiedSinceDate)
Validate a single XML file or directory of XML files.
|
static java.lang.String |
validateFile(java.io.File f)
Validates an XML File to the external DTD or schema that is present in the
File.
|
static java.lang.String |
validateFile(java.io.File f,
boolean showWarnings)
Validates an XML File to the external DTD or schema that is present in the
File.
|
static java.lang.String |
validateString(java.lang.String s)
Validates an XML String to the external DTD or schema that is present in
the String.
|
static java.lang.String |
validateString(java.lang.String s,
boolean showWarnings)
Validates an XML String to the external DTD or schema that is present in
the String.
|
static java.lang.String |
validateUri(java.lang.String URI)
Validates an XML document at the given URI.
|
static java.lang.String |
validateUri(java.lang.String URI,
boolean showWarnings)
Validates an XML document at the given URI.
|
protected static final java.lang.String NAMESPACES_FEATURE_ID
protected static final java.lang.String NAMESPACE_PREFIXES_FEATURE_ID
protected static final java.lang.String VALIDATION_FEATURE_ID
protected static final java.lang.String SCHEMA_VALIDATION_FEATURE_ID
protected static final java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
protected static final java.lang.String DYNAMIC_VALIDATION_FEATURE_ID
protected static final java.lang.String DEFAULT_PARSER_NAME
protected static final boolean DEFAULT_NAMESPACES
protected static final boolean DEFAULT_NAMESPACE_PREFIXES
protected static final boolean DEFAULT_VALIDATION
protected static final boolean DEFAULT_SCHEMA_VALIDATION
protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING
protected static final boolean DEFAULT_DYNAMIC_VALIDATION
protected static final boolean DEFAULT_MEMORY_USAGE
protected static final boolean DEFAULT_TAGGINESS
public static void main(java.lang.String[] args)
args
- The command line argumentspublic java.lang.StringBuffer validate(java.lang.String filePath) throws java.io.FileNotFoundException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.lang.Exception
filePath
- A single XML file or directory
contianing XML files to be validated.java.io.FileNotFoundException
- DESCRIPTIONjava.io.IOException
- DESCRIPTIONjavax.xml.parsers.ParserConfigurationException
- DESCRIPTIONorg.xml.sax.SAXException
- DESCRIPTIONjava.lang.Exception
- DESCRIPTIONpublic java.lang.StringBuffer validate(java.lang.String filePath, java.util.Date modifiedSinceDate) throws java.io.FileNotFoundException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.lang.Exception
java.io.FileNotFoundException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.lang.Exception
public java.lang.StringBuffer validate(java.lang.String filePath, java.lang.String[] inputFileNames) throws java.io.FileNotFoundException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.lang.Exception
filePath
- A single XML file or directory
contianing XML files to be validated.inputFileNames
- An array of all the ID names found
in the directory indicated in filePath to be validated. If null, then
the list of files is obtained from the filePath directory.java.io.FileNotFoundException
- DESCRIPTIONjava.io.IOException
- DESCRIPTIONjavax.xml.parsers.ParserConfigurationException
- DESCRIPTIONorg.xml.sax.SAXException
- DESCRIPTIONjava.lang.Exception
- DESCRIPTIONpublic java.lang.StringBuffer validate(java.lang.String filePath, java.lang.String[] inputFileNames, java.lang.String reportFilePath, java.util.Date modifiedSinceDate) throws java.lang.Exception
filePath
- A single XML file or directory contianing XML files
to be validated.inputFileNames
- An array of all the ID names found in the directory
indicated in filePath to be validated. If null, then the list of files
is obtained from the filePath directory. the file list is obtainedreportFilePath
- The file where a validation report will be appended.
If null then nothing is written.java.lang.Exception
- DESCRIPTIONpublic static final java.lang.String validateString(java.lang.String s)
s
- An XML String, which must include a DTD or schema declaration.public static final java.lang.String validateString(java.lang.String s, boolean showWarnings)
s
- An XML String, which must include a DTD or schema
declaration.showWarnings
- Set to true to check for warnings as well as errors.public static final java.lang.String validateUri(java.lang.String URI)
file:///usr/local/nonesuch.xml
- an XML document on the local system.
http://www.nonesuch.com/nonsuch.xml
- an XML document on the Internet.
URI
- A URI path to an XML document.public static final java.lang.String validateUri(java.lang.String URI, boolean showWarnings)
file:///usr/local/nonesuch.xml
- an XML document on the local system.
http:///www.nonesuch.com/nonsuch.xml
- an XML document on the Internet.
URI
- A URI path to an XML document.showWarnings
- Set to true to check for warnings as well as errors.public static final java.lang.String validateFile(java.io.File f)
f
- An XML File, which must include a DTD or schema declaration.public static final java.lang.String validateFile(java.io.File f, boolean showWarnings)
f
- An XML File, which must include a DTD or schema
declaration.showWarnings
- Set to true to check for warnings as well as errors.