Running Validation from the Command Line
The Java class com.saxonica.Validate
allows you to validate a source XML document against a given schema, or simply to check a
schema for internal correctness.
To validate one or more source documents, using the Java platform, write:
java com.saxonica.Validate [options] source.xml...The equivalent on the .NET platform is:
Validate [options] source.xml...It is possible to use glob syntax to process multiple files, for example Validate
*.xml
.
In the above form, the command relies on the use of xsi:schemaLocation
attributes within the instance document to identify the schema to be loaded. As an
alternative, the schema can be specified on the command line:
In this form of the command, it is possible to specify multiple schema documents and/or
multiple instance documents, in both cases as a semicolon-separated list. Glob syntax (such
as *.xml
) is available only if the -s:
prefix is omitted, because
the shell has to recognize the argument as a filename.
Thus, source files to be validated can be listed either using the -s
option,
or in any argument that is not prefixed with "-
". This allows the standard
wildcard expansion facilities of the shell interpreter to be used, for example
*.xml
validates all files in the current directory with extension
"xml".
If no instance documents are supplied, the effect of the command is simply to check a schema for internal correctness. So a schema can be verified using the command:
[java com.saxonica.Validate | Validate] -xsd:schema.xsdMore generally the syntax of the command is:
[java com.saxonica.Validate | Validate] [options] [params] [filenames]where options generally take the form -code:value
and params take the form
keyword=value
.
The options are as follows (in any order):
-catalog:filenames |
filenames is either a file name or a list of file names separated by semicolons; the files are OASIS XML catalogs used to define how public identifiers and system identifiers (URIs) used in a source document or schema are to be redirected, typically to resources available locally. For more details see Using XML Catalogs. |
-config:filename |
Loads options from a configuration file. This must describe a schema-aware configuration. |
-init:initializer |
The value is the name of a user-supplied class that implements the interface |
-limits:min,max |
Sets upper limits on the values of |
-quit:(on|off) |
With the default setting, |
-r:classname |
Use the specified |
-s:file;file... |
Supplies a list of source documents to be validated. Each document is validated
using the same options. The value is a list of filenames separated by semicolons.
It is also possible to specify the names of source documents as arguments without
any preceding option flag; in this case shell wildcards can be used. A filename
can be specified as " |
-scmin:filename |
Loads a precompiled schema component model from the given file. The file should be
generated in a previous run using the |
-scmout:filename |
Makes a copy of the compiled schema (providing it is valid) as a schema component model to the specified XML file. This file will contain schema components corresponding to all the loaded schema documents. This option may be combined with other options: the SCM file is written after all document instance validation has been carried out. |
-stats:filename |
Requests creation of an XML document containing statistics showing which schema
components were used during the validation episode, and how often (coverage data).
This data can be used as input to further processes to produce user-readable
reports; for example the data could be combined with the output of
|
-t |
Requests display of version and timing information to the standard error output. This also shows all the schema documents that have been loaded. |
-top:element-name |
Requires that the outermost element of the instance being validated has the
required name. This is written in Clark notation format
|
-u |
Indicates that the name of the source document and schema document are supplied as URIs; otherwise they are taken as filenames, unless they start with "http:" or "file:", in which case they they are taken as URLs. |
-val:strict|lax |
Invokes strict or lax validation (default is |
-x:classname |
Requests use of the specified SAX parser for parsing the source file. The
classname must be the fully-qualified name of a Java class that implements the
|
-xi:on|off |
Apply XInclude processing to all input XML documents (both schema documents and instance documents). This currently only works when documents are parsed using the Xerces parser, which is the default in JDK 1.5 and later. |
-xmlversion:1.0|1.1 |
If set to 1.1, allows XML 1.1 and XML Namespaces 1.1 constructs. This option must
be set if source documents using XML 1.1 are to be validated, or if the schema
itself is an XML 1.1 document. This option causes types such as
|
-xsd:file;file... |
Supplies a list of schema documents to be used for validation. The value is a list
of filenames separated by semicolons. If no source documents are supplied, the
schema documents will be processed and any errors in the schema will be notified.
This option must not be used when |
-xsdversion:1.0|1.1 |
Indicates whether the schema processor is to act as an XSD 1.0 or XSD 1.1
processor. The default is XSD 1.0. New features in XSD 1.1 are not permitted
unless |
-xsiloc:on|off |
If set to |
--feature:value |
Set a feature defined in the |
-? |
Display command syntax. |
Parameters on the command line can be used to supply values for any
saxon:param
declarations in the stylesheet. See Parameterizing Schemas for details. The format of
parameters is the same as for the XSLT and XQuery command lines: name=value
to
supply a simple value; +name=filename
to supply the contents of an XML
document as the parameter value; or ?name=expression
to supply the result of
evaluating an XPath expression (for example, ?date=current-date()
).
The results of processing the schema, and of validating the source document against the
schema, are written to the standard error output. Unless the -t
option is
used, successful processing of the source document and schema results in no output.