<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="schema-processing" page="commandline" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Running Validation from the Command Line</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Running Validation from the Command Line"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Running Validation from the Command Line</h1>
      <p>The Java class <code>com.saxonica.Validate</code> allows you to validate
a source XML document against a given schema, or simply to check a schema for
internal correctness.</p>
      <p>To validate one or more source documents, using the Java platform, write:</p>
      <p class="command">java  com.saxonica.Validate 
  [options]  source.xml...  </p>
      <p>The equivalent on the .NET platform is:</p>
      <p class="command">Validate [options]  source.xml...  </p>
      <p>It is possible to use glob syntax to process multiple files, for example <code>Validate *.xml</code>.</p>
      <p>In the above form, the command relies on the use of <code>xsi:schemaLocation</code> attributes within the instance
document to identify the schema to be loaded. As an alternative, the schema can be specified on the command line:</p>
      <p class="command">[java com.saxonica.Validate | Validate] -xsd:schema.xsd -s:instance.xml</p>
      <p>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 <code>*.xml</code>) is available only if the "-s:" prefix is omitted, because the
    shell has to recognize the argument as a filename.</p>
      <p>Thus, source files to be validated can be listed either using
the <code>-s</code> 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 <code>*.xml</code> validates all files in the
current directory with extension "xml".</p>
      <p>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:</p>
      <p class="command">[java com.saxonica.Validate | Validate] -xsd:schema.xsd</p>
      <p>More generally the syntax of the command is:</p>
      <p class="command">[java com.saxonica.Validate | Validate] [options] [params] [filenames] </p>
      <p>where options generally take the form <code>-code:value</code> and params take the form <code>keyword=value</code>.</p>
      <p>The options are as follows (in any order): </p>
      <table>
         <tr>
            <td content="para">
               <p>-catalog:filenames</p>
            </td>
            <td content="para">
               <p><i>filenames</i> 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 <a class="bodylink" href="../sourcedocs/xml-catalogs.xml">Using XML Catalogs</a>.
            </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-config:filename</p>
            </td>
            <td content="para">
               <p>Loads options from a <a class="bodylink" href="../configuration/configuration-file.xml">configuration file</a>. 
      This must describe a schema-aware configuration.
    </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-init:initializer</p>
            </td>
            <td content="para">
               <p>The value is the name of a user-supplied class
that implements the interface <a class="bodylink" href="../javadoc/net/sf/saxon/lib/Initializer.html"><code>net.sf.saxon.lib.Initializer</code></a>; this initializer will be called during the initialization process,
and may be used to set any options required on the <a class="bodylink" href="../javadoc/net/sf/saxon/Configuration.html"><code>Configuration</code></a> programmatically. </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-limits:min,max</p>
            </td>
            <td content="para">
               <p>Sets upper limits on the values of minOccurs and maxOccurs allowed in a schema content model, 
in cases where Saxon is not able to implement the rules using a finite state machine with counters. For further
details see <a class="bodylink" href="../schema-processing/min-and-maxoccurs.xml">Handling minOccurs and maxOccurs</a>
            </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-r:classname</p>
            </td>
            <td content="para">
               <p>Use the specified <code>URIResolver</code> to process the URIs of all schema documents and source documents. The URIResolver is a user-defined class,
that implements the <code>URIResolver</code> interface defined in JAXP, whose function is to take a URI supplied as
a string, and return a SAX <code>InputSource</code>. It is invoked to process URIs found in <code>xs:include</code> and
<code>xs:import</code> 
               <code>schemaLocation</code> attributes of schema documents, the URIs found in <code>xsi:schemaLocation</code>
and <code>xsi:noNamespaceSchemaLocation</code> attributes in the source document,
 and (if -u is also specified) to process the URI
of the source file provided on the command line.Specifying <code>-r:org.apache.xml.resolver.tools.CatalogResolver</code> selects the Apache XML resolver 
(part of the Apache Commons project, which must be on the classpath) and enables URIs to be resolved via a catalog, allowing
references to external web sites to be redirected to local copies.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-s:file;file...</p>
            </td>
            <td content="para">
               <p>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 "-" to read the source document from standard input.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-scmin:filename</p>
            </td>
            <td content="para">
               <p>Loads a precompiled schema component model from the given file. The file should be generated in a previous
run using the -scmout option. When this option is used, the -xsd option should not be present. Schemas loaded from
an SCM file are assumed to be valid, without checking.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-scmout:filename</p>
            </td>
            <td content="para">
               <p>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.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-stats:filename</p>
            </td>
            <td content="para">
               <p>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 <code>-scmout</code> to show which components were not used at all during the validation.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-t</p>
            </td>
            <td content="para">
               <p>Requests display of version and timing information to the standard error output.
This also shows all the schema documents that have been loaded.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-top:element-name</p>
            </td>
            <td content="para">
               <p>Requires that the outermost element of the instance being validated has the required
name. This is written in Clark notation format "{uri}local".</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-u</p>
            </td>
            <td content="para">
               <p>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.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-val:strict|lax</p>
            </td>
            <td content="para">
               <p>Invokes strict or lax validation (default is strict). Lax
validation validates elements only if there is an element declaration to validate them against,
or if they have an <code>xsi:type</code> attribute.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-x:classname</p>
            </td>
            <td content="para">
               <p>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 <code>org.xml.sax.XMLReader</code> interface. In the absence
of this argument, the standard JAXP facilities are used to locate an XML parser. Note that the XML parser
performs the raw XML parsing only; Saxon always does the schema validation itself.Selecting <code>-x:org.apache.xml.resolver.tools.ResolvingXMLReader</code> selects a parser
configured to use the Apache entity resolver, so that DTD and other external references
in source documents are resolved via a catalog. The  parser (part of the Apache Commons project)
must be on the classpath.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-xi:on|off</p>
            </td>
            <td content="para">
               <p>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.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-xmlversion:1.0|1.1</p>
            </td>
            <td content="para">
               <p>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 xs:Name, xs:QName, and xs:ID to use the XML 1.1 definitions of these constructs.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-xsd:file;file...</p>
            </td>
            <td content="para">
               <p>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 <code>-scmin</code> is specified. The option may be omitted, in which case the schema to be 
used for validation will be located using the <code>xsi:schemaLocation</code> and
<code>xsi:noNamespaceSchemaLocation</code> attributes in the source document. A filename can be
specified as "-" to read the schema from standard input.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-xsiloc:on|off</p>
            </td>
            <td content="para">
               <p>If set to "on" (the default) the schema processor attempts to load any schema documents referenced
in <code>xsi:schemaLocation</code> and <code>xsi:noNamespaceSchemaLocation</code> attributes in the instance
document, unless a schema for the specified namespace (or non-namespace) is already available. If set to
"off", these attributes are ignored.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>--<i>feature</i>:value</p>
            </td>
            <td content="para">
               <p>Set a feature defined in the <a class="bodylink" href="../javadoc/net/sf/saxon/Configuration.html"><code>Configuration</code></a> interface. 
               The names of features
are defined in the Javadoc for class <a class="bodylink" href="../javadoc/net/sf/saxon/lib/FeatureKeys.html"><code>FeatureKeys</code></a>: the value used here
is the part of the name after the last "/", for example <code>--allow-external-functions:off</code>.
Only features accepting a string or boolean may be set; for booleans the values true/false or on/off
are recognized.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>-?</p>
            </td>
            <td content="para">
               <p>Display command syntax</p>
            </td>
         </tr>
      </table>
      <p>The results of processing the schema, and of validating the source document against the
schema, are written to the standard error output. Unless the <code>-t</code> option is
used, successful processing of the source document and schema results in no output.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="validation-api.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>
