Package com.saxonica
Class Validate
- java.lang.Object
-
- com.saxonica.Validate
-
public class Validate extends java.lang.Object
This Validate class provides a command line interface that allows validation of a source document against a schema, and/or checking that a source schema is a valid schema.Apart from error and optional progress messages, no output is produced.
-
-
Field Summary
Fields Modifier and Type Field Description protected EnterpriseConfiguration
config
protected Processor
processor
protected int
repeat
protected boolean
showTime
protected java.lang.String
topLevelElementName
protected boolean
useURLs
protected java.lang.String
validationMode
protected int
xsdLanguageVersion
-
Constructor Summary
Constructors Constructor Description Validate()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyLocalOptions(CommandLineOptions options, Configuration config)
Customisation hook: apply options defined locally in a subclassprotected void
badUsage(java.lang.String message)
Report incorrect usage of the command line, with a list of the options and arguments that are availableint
doValidate(java.lang.String[] args)
Support method for main program.static javax.xml.transform.Source
loadDocument(java.lang.String sourceFileName, boolean useURLs, Configuration config)
Load a document, given a filename or URLstatic void
main(java.lang.String[] args)
Main program, can be used directly from the command line.void
processFile(javax.xml.transform.Source source, SchemaValidator validator)
Process a single file using a supplied schemaprotected static int
quit(java.lang.String message, int code)
Exit with a messageprotected void
setConfiguration()
Create the configuration.void
setPermittedOptions(CommandLineOptions options)
Set the options that are recognized on the command line.
-
-
-
Field Detail
-
processor
protected Processor processor
-
config
protected EnterpriseConfiguration config
-
useURLs
protected boolean useURLs
-
showTime
protected boolean showTime
-
repeat
protected int repeat
-
validationMode
protected java.lang.String validationMode
-
xsdLanguageVersion
protected int xsdLanguageVersion
-
topLevelElementName
protected java.lang.String topLevelElementName
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Main program, can be used directly from the command line.- Parameters:
args
- List of arguments supplied on operating system command line
-
setConfiguration
protected void setConfiguration()
Create the configuration. This method is intended to be overridden in a subclass
-
setPermittedOptions
public void setPermittedOptions(CommandLineOptions options)
Set the options that are recognized on the command line. This method can be overridden in a subclass to define additional command line options.- Parameters:
options
- the CommandLineOptions in which the recognized options are to be registered.
-
doValidate
public int doValidate(java.lang.String[] args)
Support method for main program. This support method can also be invoked from subclasses that support the same command line interface. It also provides a surrogate for the command line interface that is amenable to JUnit testing. Calling this method never throws a checked Exception and never does a System.exit();- Parameters:
args
- the command-line arguments- Returns:
- a return code to be returned. Zero indicates success, +1 indicates that validation completed successfully and found the schema or instance to be invalid, +2 indicates that validation was not carried out successfully.
-
applyLocalOptions
protected void applyLocalOptions(CommandLineOptions options, Configuration config)
Customisation hook: apply options defined locally in a subclass- Parameters:
options
- the CommandLineOptionsconfig
- the Saxon Configuration
-
quit
protected static int quit(java.lang.String message, int code)
Exit with a message- Parameters:
message
- The message to be outputcode
- The result code to be returned to the operating system shell- Returns:
- the requested return code
-
loadDocument
public static javax.xml.transform.Source loadDocument(java.lang.String sourceFileName, boolean useURLs, Configuration config) throws XPathException
Load a document, given a filename or URL- Parameters:
sourceFileName
- the name of the source fileuseURLs
- true if name is to be treated as a URIconfig
- the Saxon configuration- Returns:
- the Source object that results from loading the document
- Throws:
XPathException
- if a document cannot be loaded
-
processFile
public void processFile(javax.xml.transform.Source source, SchemaValidator validator) throws SaxonApiException
Process a single file using a supplied schema- Parameters:
source
- The source XML document to be validatedvalidator
- The schema validator used to perform the validation- Throws:
SaxonApiException
- If the validation fails (or if validation could not be attempted)
-
badUsage
protected void badUsage(java.lang.String message)
Report incorrect usage of the command line, with a list of the options and arguments that are available- Parameters:
message
- The error message
-
-