<?xml version="1.0" encoding="UTF-8"?>
<page-revisions type="array">
  <page-revision>
    <created-at type="datetime">2009-05-07T11:45:55Z</created-at>
    <description>Reverted to revision #19</description>
    <id type="integer">1249</id>
    <number type="integer">31</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">12</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Get the [[#Source_Code |'''ODF Validator''' source code]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules (ODF 1.0 and 1.1 documents only): Unknown markup is ignored during validation. For ODF 1.2 documents this option does not have any effect.

'''-e''': Apply extended ODF conformance rules (ODF 1.2 documents only): Unknown markup is ignored during validation. For ODF 1.0/1.1 documents this option does not have any effect.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-s''': Use the strict schema for validation (ODF 1.0/1.1 documents only). 

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, the strict schema is used for validation. If the '''-e''' command line option is specified and if the validated document is an ODF 1.2 document, unknown markup is ignored as specified in the extended conformance class rules for ODF 1.2. If neither '''-c''' nor '''-e'''  nor '''-s''' are specified, the regular ODF schemas are used and errors are reported for unknown markup, unless it appears in styles or metadata of ODF 1.0/1.1 documents.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== What is checked? ==

The following items are checked:
* OpenDocument v1.2 documents:
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; (default, or if '''-c''' is provided) , and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are  validated with respect to the OpenDocument v1.2 schema.
** If the test type is &lt;b&gt;extended conformance test&lt;/b&gt; ('''-e''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.4.2.1 of the OpenDocument v1.2 specification (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the OpenDocument v1.2 schema.
* OpenDocument v1.1/1.0 documents:
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; ('''-c''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.5 of the &lt;a href=&quot;http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1.odt&quot;&gt;OpenDocument specification&lt;/a&gt; (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the schema of the selected OpenDocument version.
** If the test type is &lt;b&gt;validation&lt;/b&gt; (default), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
** If the test type is &lt;b&gt;strict validation&lt;/b&gt; ('''-s''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the strict schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
* All versions:
** If the file is a formula file, then the sub file &lt;i&gt;content.xml&lt;/i&gt; is validated with respect to the MathML 2.0 W3C XSD schema.  The sub files &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are checked as described for other document types.
** The file &lt;i&gt;META-INF/manifest.xml&lt;/i&gt; is validated with respect to the manifest schema of the selected ODF specification.
** If the file is an ODF 1.2 file, then the &lt;i&gt;META-INF/documentsignatures.xml&lt;/i&gt; and &lt;i&gt;META-INF/macrosignatures.xml&lt;/i&gt; sub files are validated with respect to the digital signatures schema of the ODF 1.2 specification.
** For all embedded objects in ODF format, the &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated as described for the main document above.
** It is checked whether the file itself ans all embedded objects in ODF format contain at least a &lt;i&gt;content.xml&lt;/i&gt; or &lt;i&gt;styles.xml&lt;/i&gt; sub file.

The following actions take place before or during the validation:
* A DTD document declaration within a &lt;i&gt;manifest.xml&lt;/i&gt; file is ignored. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens. &lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; Very early ODF implementations in OpenOffice.org wrongly included a document type declaration. Ignoring the document type enables the validation of the manifest despite of this error.
* A namespace &amp;quot;http://openoffice.org/2001/manifest&amp;quot; within a &lt;i&gt;manifest.xml&lt;/i&gt; file is changed to &amp;quot;urn:oasis:names:tc:opendocument:xmlns:manifest:1.0&amp;quot;. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens. &lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; Early ODF implementations in OpenOffice.org used the wrong namespace. Changing it to the correct one enables the validation of the manifest despite the wrong namespace.
* Namespaces defined in the &lt;a href=&quot;http://www.oasis-open.org/committees/download.php/10765/office-spec-1.0-cd-2.pdf&quot;&gt;ODF v1.0 Committee Draft 2&lt;/a&gt; are replaced with those of the &lt;a href=&quot;http://www.oasis-open.org/specs/index.php#opendocumentv1.0&quot;&gt;ODF v1.0 OASIS Standard&lt;/a&gt;. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens.&lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; Changing the namespaces enables the validation of documents that conform to the ODF v1.0 CD2. Such documents have been saved by OpenOffice.org 1.0 beta versions.
* The value of &lt;i&gt;draw:points&lt;/i&gt; attributes is truncated to 2048 characters. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens.&lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; The truncation of this attribute value avoids a stack overflow in MSV while validating the attribute value against a regular expression.
* A namespace &amp;quot;http://openoffice.org/2004/database&amp;quot; within a &lt;i&gt;content.xml&lt;/i&gt; file is changed to &amp;quot;urn:oasis:names:tc:opendocument:xmlns:database:1.0&amp;quot;, and a namespace &amp;quot;http://openoffice.org/2004/office&amp;quot; within a &lt;i&gt;content.xml&lt;/i&gt; file is changed to &amp;quot;urn:oasis:names:tc:opendocument:xmlns:office:1.0&amp;quot;. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens.&lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; These namespaces were used in OpenOffice.org 2.x database documents, because database documents are included in OpenDocument since version 1.2 only. Changing them enables the validation of  OpenOffice.org 2.x database documents.


== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are available on the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee] page. The ODF 1.0 and 1.1 schemas can be downloaded directly from that [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office#technical page]. A zip file containing the most recent ODF 1.2 schemas is available in the [http://www.oasis-open.org/committees/documents.php?wg_abbrev=office document section].

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

The NetBeans project is pre-configured to build ODFDOM while building '''ODF Validator'''. This requires that the ODFDOM sources are located in a folder '''odfdom''' next to the folder of the '''ODF Validator''' project.

Alternatively, the reference to the ODFDOM project in the compile time classpath of the '''ODF Validator''' project may be replaced with a reference to an already compiled '''odfdom.jar'''.

The references to all other jar files must be updated manually before building ''' ODF Validator'''.

'''Note:''' [[ODFDOM]] requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odvalidator.jar''' file, or it must be in the classpath. The '''ODF Validator''' NetBeans projects includes a reference to '''xersesImpl.jar''' in the runtime classpath which has to be adapted after checking out the project.

'''Note:''' [[ODFDOM]] requires at least Xerces 2.8.0. Please note that MSV distribution contains an xercesImpl.jar which is older. 

== Source Code ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here]. '''ODF Validator''' uses Mercurial for source control. Please check the 
&lt;a href=&quot;{{project help page SourceControl}}&quot;&gt;help&lt;/a&gt; for instruction how to use Mercurial.

The '''ODFValidator''' ia a NetBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-05-07T11:44:57Z</created-at>
    <description>Reverted to revision #19</description>
    <id type="integer">1248</id>
    <number type="integer">30</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">12</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Get the [[#Source_Code |'''ODF Validator''' source code]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules (ODF 1.0 and 1.1 documents only): Unknown markup is ignored during validation. For ODF 1.2 documents this option does not have any effect.

'''-e''': Apply extended ODF conformance rules (ODF 1.2 documents only): Unknown markup is ignored during validation. For ODF 1.0/1.1 documents this option does not have any effect.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-s''': Use the strict schema for validation (ODF 1.0/1.1 documents only). 

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, the strict schema is used for validation. If the '''-e''' command line option is specified and if the validated document is an ODF 1.2 document, unknown markup is ignored as specified in the extended conformance class rules for ODF 1.2. If neither '''-c''' nor '''-e'''  nor '''-s''' are specified, the regular ODF schemas are used and errors are reported for unknown markup, unless it appears in styles or metadata of ODF 1.0/1.1 documents.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== What is checked? ==

The following items are checked:
* OpenDocument v1.2 documents:
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; (default, or if '''-c''' is provided) , and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are  validated with respect to the OpenDocument v1.2 schema.
** If the test type is &lt;b&gt;extended conformance test&lt;/b&gt; ('''-e''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.4.2.1 of the OpenDocument v1.2 specification (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the OpenDocument v1.2 schema.
* OpenDocument v1.1/1.0 documents
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; ('''-c''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.5 of the &lt;a href=&quot;http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1.odt&quot;&gt;OpenDocument specification&lt;/a&gt; (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the schema of the selected OpenDocument version.
** If the test type is &lt;b&gt;validation&lt;/b&gt; (default), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
** If the test type is &lt;b&gt;strict validation&lt;/b&gt; ('''-s''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the strict schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
* All versions
** If the file is a formula file, then the sub file &lt;i&gt;content.xml&lt;/i&gt; is validated with respect to the MathML 2.0 W3C XSD schema.  The sub files &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are checked as described for other document types.
** The file &lt;i&gt;META-INF/manifest.xml&lt;/i&gt; is validated with respect to the manifest schema of the selected ODF specification.
** If the file is an ODF 1.2 file, then the &lt;i&gt;META-INF/documentsignatures.xml&lt;/i&gt; and &lt;i&gt;META-INF/macrosignatures.xml&lt;/i&gt; sub files are validated with respect to the digital signatures schema of the ODF 1.2 specification.
** For all embedded objects in ODF format, the &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated as described for the main document above.
** It is checked whether the file itself ans all embedded objects in ODF format contain at least a &lt;i&gt;content.xml&lt;/i&gt; or &lt;i&gt;styles.xml&lt;/i&gt; sub file.

The following actions take place before or during the validation:
* A DTD document declaration within a &lt;i&gt;manifest.xml&lt;/i&gt; file is ignored. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens. &lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; Very early ODF implementations in OpenOffice.org wrongly included a document type declaration. Ignoring the document type enables the validation of the manifest despite of this error.
* A namespace &amp;quot;http://openoffice.org/2001/manifest&amp;quot; within a &lt;i&gt;manifest.xml&lt;/i&gt; file is changed to &amp;quot;urn:oasis:names:tc:opendocument:xmlns:manifest:1.0&amp;quot;. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens. &lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; Early ODF implementations in OpenOffice.org used the wrong namespace. Changing it to the correct one enables the validation of the manifest despite the wrong namespace.
* Namespaces defined in the &lt;a href=&quot;http://www.oasis-open.org/committees/download.php/10765/office-spec-1.0-cd-2.pdf&quot;&gt;ODF v1.0 Committee Draft 2&lt;/a&gt; are replaced with those of the &lt;a href=&quot;http://www.oasis-open.org/specs/index.php#opendocumentv1.0&quot;&gt;ODF v1.0 OASIS Standard&lt;/a&gt;. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens.&lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; Changing the namespaces enables the validation of documents that conform to the ODF v1.0 CD2. Such documents have been saved by OpenOffice.org 1.0 beta versions.
* The value of &lt;i&gt;draw:points&lt;/i&gt; attributes is truncated to 2048 characters. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens.&lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; The truncation of this attribute value avoids a stack overflow in MSV while validating the attribute value against a regular expression.
* A namespace &amp;quot;http://openoffice.org/2004/database&amp;quot; within a &lt;i&gt;content.xml&lt;/i&gt; file is changed to &amp;quot;urn:oasis:names:tc:opendocument:xmlns:database:1.0&amp;quot;, and a namespace &amp;quot;http://openoffice.org/2004/office&amp;quot; within a &lt;i&gt;content.xml&lt;/i&gt; file is changed to &amp;quot;urn:oasis:names:tc:opendocument:xmlns:office:1.0&amp;quot;. For the logging level &lt;b&gt;all&lt;/b&gt;, an information is displayed if this happens.&lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; These namespaces were used in OpenOffice.org 2.x database documents, because database documents are included in OpenDocument since version 1.2 only. Changing them enables the validation of  OpenOffice.org 2.x database documents.


== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are available on the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee] page. The ODF 1.0 and 1.1 schemas can be downloaded directly from that [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office#technical page]. A zip file containing the most recent ODF 1.2 schemas is available in the [http://www.oasis-open.org/committees/documents.php?wg_abbrev=office document section].

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

The NetBeans project is pre-configured to build ODFDOM while building '''ODF Validator'''. This requires that the ODFDOM sources are located in a folder '''odfdom''' next to the folder of the '''ODF Validator''' project.

Alternatively, the reference to the ODFDOM project in the compile time classpath of the '''ODF Validator''' project may be replaced with a reference to an already compiled '''odfdom.jar'''.

The references to all other jar files must be updated manually before building ''' ODF Validator'''.

'''Note:''' [[ODFDOM]] requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odvalidator.jar''' file, or it must be in the classpath. The '''ODF Validator''' NetBeans projects includes a reference to '''xersesImpl.jar''' in the runtime classpath which has to be adapted after checking out the project.

'''Note:''' [[ODFDOM]] requires at least Xerces 2.8.0. Please note that MSV distribution contains an xercesImpl.jar which is older. 

== Source Code ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here]. '''ODF Validator''' uses Mercurial for source control. Please check the 
&lt;a href=&quot;{{project help page SourceControl}}&quot;&gt;help&lt;/a&gt; for instruction how to use Mercurial.

The '''ODFValidator''' ia a NetBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-05-07T11:35:56Z</created-at>
    <description>Reverted to revision #19</description>
    <id type="integer">1247</id>
    <number type="integer">29</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">12</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Get the [[#Source_Code |'''ODF Validator''' source code]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules (ODF 1.0 and 1.1 documents only): Unknown markup is ignored during validation. For ODF 1.2 documents this option does not have any effect.

'''-e''': Apply extended ODF conformance rules (ODF 1.2 documents only): Unknown markup is ignored during validation. For ODF 1.0/1.1 documents this option does not have any effect.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-s''': Use the strict schema for validation (ODF 1.0/1.1 documents only). 

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, the strict schema is used for validation. If the '''-e''' command line option is specified and if the validated document is an ODF 1.2 document, unknown markup is ignored as specified in the extended conformance class rules for ODF 1.2. If neither '''-c''' nor '''-e'''  nor '''-s''' are specified, the regular ODF schemas are used and errors are reported for unknown markup, unless it appears in styles or metadata of ODF 1.0/1.1 documents.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== What is checked? ==

The following items are checked:
* OpenDocument v1.2 documents:
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; (default, or if '''-c''' is provided) , and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are  validated with respect to the OpenDocument v1.2 schema.
** If the test type is &lt;b&gt;extended conformance test&lt;/b&gt; ('''-e''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.4.2.1 of the OpenDocument v1.2 specification (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the OpenDocument v1.2 schema.
* OpenDocument v1.1/1.0 documents
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; ('''-c''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.5 of the &lt;a href=&quot;http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1.odt&quot;&gt;OpenDocument specification&lt;/a&gt; (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the schema of the selected OpenDocument version.
** If the test type is &lt;b&gt;validation&lt;/b&gt; (default), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
** If the test type is &lt;b&gt;strict validation&lt;/b&gt; ('''-s''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the strict schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
* All versions
** If the file is a formula file, then the sub file &lt;i&gt;content.xml&lt;/i&gt; is validated with respect to the MathML 2.0 W3C XSD schema.  The sub files &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are checked as described for other document types.
** The file &lt;i&gt;META-INF/manifest.xml&lt;/i&gt; is validated with respect to the manifest schema of the selected ODF specification.
** If the file is an ODF 1.2 file, then the &lt;i&gt;META-INF/documentsignatures.xml&lt;/i&gt; and &lt;i&gt;META-INF/macrosignatures.xml&lt;/i&gt; sub files are validated with respect to the digital signatures schema of the ODF 1.2 specification.
** For all embedded objects in ODF format, the &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated as described for the main document above.
** It is checked whether the file itself ans all embedded objects in ODF format contain at least a &lt;i&gt;content.xml&lt;/i&gt; or &lt;i&gt;styles.xml&lt;/i&gt; sub file.

== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are available on the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee] page. The ODF 1.0 and 1.1 schemas can be downloaded directly from that [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office#technical page]. A zip file containing the most recent ODF 1.2 schemas is available in the [http://www.oasis-open.org/committees/documents.php?wg_abbrev=office document section].

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

The NetBeans project is pre-configured to build ODFDOM while building '''ODF Validator'''. This requires that the ODFDOM sources are located in a folder '''odfdom''' next to the folder of the '''ODF Validator''' project.

Alternatively, the reference to the ODFDOM project in the compile time classpath of the '''ODF Validator''' project may be replaced with a reference to an already compiled '''odfdom.jar'''.

The references to all other jar files must be updated manually before building ''' ODF Validator'''.

'''Note:''' [[ODFDOM]] requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odvalidator.jar''' file, or it must be in the classpath. The '''ODF Validator''' NetBeans projects includes a reference to '''xersesImpl.jar''' in the runtime classpath which has to be adapted after checking out the project.

'''Note:''' [[ODFDOM]] requires at least Xerces 2.8.0. Please note that MSV distribution contains an xercesImpl.jar which is older. 

== Source Code ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here]. '''ODF Validator''' uses Mercurial for source control. Please check the 
&lt;a href=&quot;{{project help page SourceControl}}&quot;&gt;help&lt;/a&gt; for instruction how to use Mercurial.

The '''ODFValidator''' ia a NetBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-05-07T11:34:33Z</created-at>
    <description>Reverted to revision #19</description>
    <id type="integer">1246</id>
    <number type="integer">28</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">12</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Get the [[#Source_Code |'''ODF Validator''' source code]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules (ODF 1.0 and 1.1 documents only): Unknown markup is ignored during validation. For ODF 1.2 documents this option does not have any effect.

'''-e''': Apply extended ODF conformance rules (ODF 1.2 documents only): Unknown markup is ignored during validation. For ODF 1.0/1.1 documents this option does not have any effect.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-s''': Use the strict schema for validation (ODF 1.0/1.1 documents only). 

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, the strict schema is used for validation. If the '''-e''' command line option is specified and if the validated document is an ODF 1.2 document, unknown markup is ignored as specified in the extended conformance class rules for ODF 1.2. If neither '''-c''' nor '''-e'''  nor '''-s''' are specified, the regular ODF schemas are used and errors are reported for unknown markup, unless it appears in styles or metadata of ODF 1.0/1.1 documents.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== What is checked? ==

The following items are checked:
* OpenDocument v1.2 documents:
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; (default, or if '''-c'' is provided) , and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are  validated with respect to the OpenDocument v1.2 schema.
** If the test type is &lt;b&gt;extended conformance test&lt;/b&gt; ('''-e''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.4.2.1 of the OpenDocument v1.2 specification (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the OpenDocument v1.2 schema.
* OpenDocument v1.1/1.0 documents
** If the test type is &lt;b&gt;conformance test&lt;/b&gt; ('''-c''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are pre-processed as described in section 1.5 of the &lt;a href=&quot;http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1.odt&quot;&gt;OpenDocument specification&lt;/a&gt; (that is &lt;i&gt;foreign elements and attributes&lt;/i&gt; are removed), and are then validated with respect to the schema of the selected OpenDocument version.
** If the test type is &lt;b&gt;validation&lt;/b&gt; (default), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
* If the test type is &lt;b&gt;strict validation&lt;/b&gt; ('''-s''' is provided), and if the file is not a formula file, then the sub files &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated with respect to the strict schema of the selected OpenDocument version. Pre-processing of &lt;i&gt;foreign elements and attributes&lt;/i&gt; is not applied.
* All versions
** If the file is a formula file, then the sub file &lt;i&gt;content.xml&lt;/i&gt; is validated with respect to the MathML 2.0 W3C XSD schema.  The sub files &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are checked as described for other document types.
** The file &lt;i&gt;META-INF/manifest.xml&lt;/i&gt; is validated with respect to the manifest schema of the selected ODF specification.
** If the file is an ODF 1.2 file, then the &lt;i&gt;META-INF/documentsignatures.xml&lt;/i&gt; and &lt;i&gt;META-INF/macrosignatures.xml&lt;/i&gt; sub files are validated with respect to the digital signatures schema of the ODF 1.2 specification.
** For all embedded objects in ODF format, the &lt;i&gt;content.xml&lt;/i&gt;, &lt;i&gt;styles.xml&lt;/i&gt;, &lt;i&gt;meta.xml&lt;/i&gt; and &lt;i&gt;settings.xml&lt;/i&gt; are validated as described for the main document above.
** It is checked whether the file itself ans all embedded objects in ODF format contain at least a &lt;i&gt;content.xml&lt;/i&gt; or &lt;i&gt;styles.xml&lt;/i&gt; sub file.

== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are available on the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee] page. The ODF 1.0 and 1.1 schemas can be downloaded directly from that [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office#technical page]. A zip file containing the most recent ODF 1.2 schemas is available in the [http://www.oasis-open.org/committees/documents.php?wg_abbrev=office document section].

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

The NetBeans project is pre-configured to build ODFDOM while building '''ODF Validator'''. This requires that the ODFDOM sources are located in a folder '''odfdom''' next to the folder of the '''ODF Validator''' project.

Alternatively, the reference to the ODFDOM project in the compile time classpath of the '''ODF Validator''' project may be replaced with a reference to an already compiled '''odfdom.jar'''.

The references to all other jar files must be updated manually before building ''' ODF Validator'''.

'''Note:''' [[ODFDOM]] requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odvalidator.jar''' file, or it must be in the classpath. The '''ODF Validator''' NetBeans projects includes a reference to '''xersesImpl.jar''' in the runtime classpath which has to be adapted after checking out the project.

'''Note:''' [[ODFDOM]] requires at least Xerces 2.8.0. Please note that MSV distribution contains an xercesImpl.jar which is older. 

== Source Code ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here]. '''ODF Validator''' uses Mercurial for source control. Please check the 
&lt;a href=&quot;{{project help page SourceControl}}&quot;&gt;help&lt;/a&gt; for instruction how to use Mercurial.

The '''ODFValidator''' ia a NetBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-05-06T13:16:53Z</created-at>
    <description>Reverted to revision #19</description>
    <id type="integer">1245</id>
    <number type="integer">27</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">12</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Get the [[#Source_Code |'''ODF Validator''' source code]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules (ODF 1.0 and 1.1 documents only): Unknown markup is ignored during validation. For ODF 1.2 documents this option does not have any effect.

'''-e''': Apply extended ODF conformance rules (ODF 1.2 documents only): Unknown markup is ignored during validation. For ODF 1.0/1.1 documents this option does not have any effect.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-s''': Use the strict schema for validation (ODF 1.0/1.1 documents only). 

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified and if the validated document is an ODF 1.0 or ODF 1.1 document, the strict schema is used for validation. If the '''-e''' command line option is specified and if the validated document is an ODF 1.2 document, unknown markup is ignored as specified in the extended conformance class rules for ODF 1.2. If neither '''-c''' nor '''-e'''  nor '''-s''' are specified, the regular ODF schemas are used and errors are reported for unknown markup, unless it appears in styles or metadata of ODF 1.0/1.1 documents.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are available on the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee] page. The ODF 1.0 and 1.1 schemas can be downloaded directly from that [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office#technical page]. A zip file containing the most recent ODF 1.2 schemas is available in the [http://www.oasis-open.org/committees/documents.php?wg_abbrev=office document section].

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

The NetBeans project is pre-configured to build ODFDOM while building '''ODF Validator'''. This requires that the ODFDOM sources are located in a folder '''odfdom''' next to the folder of the '''ODF Validator''' project.

Alternatively, the reference to the ODFDOM project in the compile time classpath of the '''ODF Validator''' project may be replaced with a reference to an already compiled '''odfdom.jar'''.

The references to all other jar files must be updated manually before building ''' ODF Validator'''.

'''Note:''' [[ODFDOM]] requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odvalidator.jar''' file, or it must be in the classpath. The '''ODF Validator''' NetBeans projects includes a reference to '''xersesImpl.jar''' in the runtime classpath which has to be adapted after checking out the project.

'''Note:''' [[ODFDOM]] requires at least Xerces 2.8.0. Please note that MSV distribution contains an xercesImpl.jar which is older. 

== Source Code ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here]. '''ODF Validator''' uses Mercurial for source control. Please check the 
&lt;a href=&quot;{{project help page SourceControl}}&quot;&gt;help&lt;/a&gt; for instruction how to use Mercurial.

The '''ODFValidator''' ia a NetBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-02-10T18:35:11Z</created-at>
    <description>Reverted to revision #19</description>
    <id type="integer">1143</id>
    <number type="integer">26</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">2</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Get the [[#Source_Code |'''ODF Validator''' source code]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules before validation: unknown markup is ignored during validation.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-c''': Use the strict schema for validation.

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified, the strict schema is used for validation. If neither '''-c''' nor '''-s''' are specified, the regular ODF schemas are used, but errors are reported for unknown markup unless it appears in styles or metadata.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are available on the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee] page. The ODF 1.0 and 1.1 schemas can be downloaded directly from that [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office#technical page]. A zip file containing the most recent ODF 1.2 schemas is available in the [http://www.oasis-open.org/committees/documents.php?wg_abbrev=office document section].

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

The NetBeans project is pre-configured to build ODFDOM while building '''ODF Validator'''. This requires that the ODFDOM sources are located in a folder '''odfdom''' next to the folder of the '''ODF Validator''' project.

Alternatively, the reference to the ODFDOM project in the compile time classpath of the '''ODF Validator''' project may be replaced with a reference to an already compiled '''odfdom.jar'''.

The references to all other jar files must be updated manually before building ''' ODF Validator'''.

'''Note:''' [[ODFDOM]] requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odvalidator.jar''' file, or it must be in the classpath. The '''ODF Validator''' NetBeans projects includes a reference to '''xersesImpl.jar''' in the runtime classpath which has to be adapted after checking out the project.

'''Note:''' [[ODFDOM]] requires at least Xerces 2.8.0. Please note that MSV distribution contains an xercesImpl.jar which is older. 

== Source Code ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here]. '''ODF Validator''' uses Mercurial for source control. Please check the 
&lt;a href=&quot;{{project help page SourceControl}}&quot;&gt;help&lt;/a&gt; for instruction how to use Mercurial.

The '''ODFValidator''' ia a NetBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-02-10T13:08:20Z</created-at>
    <description>Reverted to revision #3</description>
    <id type="integer">1109</id>
    <number type="integer">25</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">2</person-id>
    <text>__TOC__

ODFValidator is a tool that validates OpenDocument files and checks certain conformance criteria.

ODFValidator is available as a [http://tools.services.openoffice.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.services.openoffice.org/odfvalidator OpenOffice.org ODF Validator] web page for details regarding the online tool.

== How to start ==
To use the ODFValidator, the following steps are required:

* Check out the [[NetBeans Project |'''odfvalidator''' NetBeans project]].
* Add the jar files listed under [[Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[Where do I get the schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[Where do I get the schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the ODFValidator with


 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;


* If you are using JRE 1.6, call the ODFValidator with


 java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;


== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, ODFValidator is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 
 java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
-Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;
 

These command lines are abbreviated ''odfvalidator'' from now on.

The ODFValidator may be called with the following options:

 
 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V
 

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules before validation: unknown markup is ignored during validation.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-f''': Ignore error messages specified in '''&amp;lt;filterfile&amp;gt;''' (see [[Specifying a filter file|Specifying a filter file]]).

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-c''': Use the strict schema for validation.

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the ODFValidator detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified, the strict schema is used for validation. If neither '''-c''' nor '''-s''' are specified, the regular ODF schemas are used, but errors are reported for unknown markup unless it appears in styles or metadata.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out. It is possible to exclude known validation errors from the output by specifying a [[Specifying a filter file|filter file]] using the '''-f''' option.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, ODFValidator has to be called with the following parameters:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[Validation using default schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[Specifying the schema on the command line|'''-x''' option]].
* '''filter''': Specifies [[Specifying a filter file|filter file]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== Specifying a filter file ==

It is possible to omit the output of known validation errors by adding their error message to a so called filter file. A filter file is an XML file, which matches the following [http://www.relaxng.org/compact-tutorial-20030326.html Relax-NG Compact] schema:

 start = filter
 filter = element filter { filter-attlist, filter-entry+ }
 filter-attlist &amp;= empty
 filter-entry = element filter-entry { filter-entry-attlist, text }
 filter-entry-attlist &amp;=
   attribute task-id {
     xsd:string { pattern = '[a-z]?[0-9]+&quot;' }
   }
 filter-entry-attlist &amp;= attribute resolved-in { xsd:integer }?

A sample filter file is

 &amp;lt;filter&amp;gt;
   &amp;lt;!-- CWS impress25/SRC680m72 --&amp;gt;
   &amp;lt;filter-entry task-id=&quot;i38753&quot; resolved-in=&quot;8864&quot;&amp;gt;attribute &quot;presentation:display-header&quot; has a bad value. Possible values are: false,true&amp;lt;/filter-entry&amp;gt;
 &amp;lt;/filter&amp;gt;

Each '''&amp;lt;filter-entry&amp;gt;''' element described one message that shall be excluded. The message itself is the element content. The mandatory '''task-id''' attribute includes the task which resolves the validation error, or that has been submitted for the validation error if it has not been resolved already. 

The optional '''resolved-in''' attribute contains the build-id of the master where the validation error has been resolved. 
Error messages are only omited if the '''resolved-in''' attribute is provided, or if the build-id is lower than the one which is stored in the '''&amp;lt;meta:generator&amp;gt;''' element of the file that is validated. This means that a validation error is not omitted if it occurs in a file which has been saved with an OOo version where the bug shall be resolved already.

If a error message is omited, a warning is printed that contains the task-id specified in the filter file. Please note that warning are only printed if either the '''-w''' or the '''-v''' switch is present.

A filter file is specified using the '''-f''' command line option or the '''filter''' property in the configuration file.


== Where do I get the schemas? ==

The OpenDocument schemas are those provided on the [[http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee]] page.

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into ODFValidator have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

ODFValidator requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:


 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl



ODFValidator further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* [http://odftoolkit.openoffice.org/servlets/ProjectDocumentList?folderID=759&amp;expandFolder=759&amp;folderID=0 ODFDOM] ''' odfdom.jar''' from [http://odftoolkit.openoffice.org/servlets/ProjectDocumentList?folderID=759&amp;expandFolder=759&amp;folderID=0 ODFDOM] must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

'''Warning:''' Make sure you use an up-to-date release of MSV. Older versions (before msv-20061103) report errors for the OpenDocument schema itself.

== NetBeans Project ==

The '''ODFValidator''' [http://odftoolkit.openoffice.org/source/browse/odftoolkit/tools/odfvalidator/ source code] is located in the ''tools'' folder of the [http://odftoolkit.openoffice.org OpenOffice.org ODF Toolkit Project].

The '''ODFValidator''' ia a NebBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-02-10T13:04:04Z</created-at>
    <description>Reverted to revision #3</description>
    <id type="integer">1108</id>
    <number type="integer">24</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">2</person-id>
    <text>__TOC__

ODFValidator is a tool that validates OpenDocument files and checks certain conformance criteria.

ODFValidator is available as a [http://tools.services.openoffice.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.services.openoffice.org/odfvalidator OpenOffice.org ODF Validator] web page for details regarding the online tool.

== How to start ==
To use the ODFValidator, the following steps are required:

* Check out the [[NetBeans Project |'''odfvalidator''' NetBeans project]].
* Add the jar files listed under [[Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[Where do I get the schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[Where do I get the schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the ODFValidator with


 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;


* If you are using JRE 1.6, call the ODFValidator with


 java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;


== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, ODFValidator is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 
 java -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
-Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;
 

These command lines are abbreviated ''odfvalidator'' from now on.

The ODFValidator may be called with the following options:

 
 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V
 

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules before validation: unknown markup is ignored during validation.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-f''': Ignore error messages specified in '''&amp;lt;filterfile&amp;gt;''' (see [[Specifying a filter file|Specifying a filter file]]).

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-c''': Use the strict schema for validation.

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the ODFValidator detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified, the strict schema is used for validation. If neither '''-c''' nor '''-s''' are specified, the regular ODF schemas are used, but errors are reported for unknown markup unless it appears in styles or metadata.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out. It is possible to exclude known validation errors from the output by specifying a [[Specifying a filter file|filter file]] using the '''-f''' option.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, ODFValidator has to be called with the following parameters:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-f &amp;lt;filterfile&amp;gt;] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[Validation using default schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[Specifying the schema on the command line|'''-x''' option]].
* '''filter''': Specifies [[Specifying a filter file|filter file]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== Specifying a filter file ==

It is possible to omit the output of known validation errors by adding their error message to a so called filter file. A filter file is an XML file, which matches the following [http://www.relaxng.org/compact-tutorial-20030326.html Relax-NG Compact] schema:

 start = filter
 filter = element filter { filter-attlist, filter-entry+ }
 filter-attlist &amp;= empty
 filter-entry = element filter-entry { filter-entry-attlist, text }
 filter-entry-attlist &amp;=
   attribute task-id {
     xsd:string { pattern = '[a-z]?[0-9]+&quot;' }
   }
 filter-entry-attlist &amp;= attribute resolved-in { xsd:integer }?

A sample filter file is

 &amp;lt;filter&amp;gt;
   &amp;lt;!-- CWS impress25/SRC680m72 --&amp;gt;
   &amp;lt;filter-entry task-id=&quot;i38753&quot; resolved-in=&quot;8864&quot;&amp;gt;attribute &quot;presentation:display-header&quot; has a bad value. Possible values are: false,true&amp;lt;/filter-entry&amp;gt;
 &amp;lt;/filter&amp;gt;

Each '''&amp;lt;filter-entry&amp;gt;''' element described one message that shall be excluded. The message itself is the element content. The mandatory '''task-id''' attribute includes the task which resolves the validation error, or that has been submitted for the validation error if it has not been resolved already. 

The optional '''resolved-in''' attribute contains the build-id of the master where the validation error has been resolved. 
Error messages are only omited if the '''resolved-in''' attribute is provided, or if the build-id is lower than the one which is stored in the '''&amp;lt;meta:generator&amp;gt;''' element of the file that is validated. This means that a validation error is not omitted if it occurs in a file which has been saved with an OOo version where the bug shall be resolved already.

If a error message is omited, a warning is printed that contains the task-id specified in the filter file. Please note that warning are only printed if either the '''-w''' or the '''-v''' switch is present.

A filter file is specified using the '''-f''' command line option or the '''filter''' property in the configuration file.


== Where do I get the schemas? ==

The OpenDocument schemas are those provided on the [[http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee]] page.

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into ODFValidator have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

ODFValidator requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:


 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl



ODFValidator further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* [http://odftoolkit.openoffice.org/servlets/ProjectDocumentList?folderID=759&amp;expandFolder=759&amp;folderID=0 ODFDOM] ''' odfdom.jar''' from [http://odftoolkit.openoffice.org/servlets/ProjectDocumentList?folderID=759&amp;expandFolder=759&amp;folderID=0 ODFDOM] must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

'''Warning:''' Make sure you use an up-to-date release of MSV. Older versions (before msv-20061103) report errors for the OpenDocument schema itself.

== NetBeans Project ==

The '''ODFValidator''' [http://odftoolkit.openoffice.org/source/browse/odftoolkit/tools/odfvalidator/ source code] is located in the ''tools'' folder of the [http://odftoolkit.openoffice.org OpenOffice.org ODF Toolkit Project].

The '''ODFValidator''' ia a NebBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-02-10T08:10:18Z</created-at>
    <description>Reverted to revision #15</description>
    <id type="integer">1079</id>
    <number type="integer">23</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">2</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Check out the [[#NetBeans_Project |'''ODF Validator''' NetBeans project]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules before validation: unknown markup is ignored during validation.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-c''': Use the strict schema for validation.

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified, the strict schema is used for validation. If neither '''-c''' nor '''-s''' are specified, the regular ODF schemas are used, but errors are reported for unknown markup unless it appears in styles or metadata.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are those provided on the [[http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee]] page.

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

== NetBeans Project ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here].

The '''ODFValidator''' ia a NebBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
  <page-revision>
    <created-at type="datetime">2009-02-10T06:55:04Z</created-at>
    <description>Reverted to revision #15</description>
    <id type="integer">1060</id>
    <number type="integer">22</number>
    <page-id type="integer">61</page-id>
    <person-id type="integer">2</person-id>
    <text>__TOC__

'''ODF Validator''' is a tool that validates OpenDocument files and checks them for certain conformance criteria.

'''ODF Validator''' is available as an [http://tools.odftoolkit.org/odfvalidator online service] and as a command line tool. This page primarily describes the command line tool. Please visit the [http://tools.odftoolkit.org/odfvalidator ODF Online Validator] web page for details regarding the online tool.

== How to start ==
To use the '''ODF Validator''', the following steps are required:

* Check out the [[#NetBeans_Project |'''ODF Validator''' NetBeans project]].
* Add the jar files listed under [[#Requirements|Requirements]] to the project's libraries.
* Get the ODF 1.0, 1,1 and 1.2 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where your local copies of the schemas are stored to the '''schema.user.properties''' file.
* Get the MathML 1.01 DTD and the MathML 2.0 [[#Where_do_I_get_the_schemas|schemas]], and add the directories where you local copies of the schemas are stored to the '''schema.user.properties''' file.
* Build the project.
* Choose an arbitray OpenDocument file '''&amp;lt;odffile&amp;gt;'''. 
* If you are using JRE 1.5, call the '''ODF Validator''' with

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot; &amp;lt;odffile&amp;gt;

* If you are using JRE 1.6, call the '''ODF Validator''' with

 java 
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;  
 &amp;lt;odffile&amp;gt;

== Usage ==

=== Usage Summary ===

In an Java 1.5 environment, '''ODF Validator''' is invoked by the following command:

 java -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

In an Java 1.6 environment, the following command line has to be used:

 java
 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl
  -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl -jar &quot;&amp;lt;path&amp;gt;/odfvalidator.jar&quot;

These command lines are abbreviated ''odfvalidator'' from now on.

The '''ODF Validator''' may be called with the following options:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;
 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;] [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &amp;lt;configfile&amp;gt;
 odfvalidator -g &amp;lt;odffiles&amp;gt;
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files '''&amp;lt;odffiles&amp;gt;''' are validated using the schema that belongs to the ODF version of the file. For ODF 1.0 files the ODF 1.0 schema is used, for ODF 1.1 files the ODF 1.1 schema is used, and so on. The version of an ODF file is detected for each file separately.

The options have the following meaning:

'''-c''': Apply ODF conformance rules before validation: unknown markup is ignored during validation.

'''-d''': Use MathML 1.01 DTD rather than MathML 2.0 schema for content.xml of formula documents.

'''-g''': Show the generator information of the specified '''&amp;lt;odffiles&amp;gt;''' without validation.

'''-h''': Print a short help.

'''-o''': Print output into specified file rather than standard output.

'''-r''': Process directories recursively.

'''-c''': Use the strict schema for validation.

'''-v''': Verbose: print information like the generator or the documents that are processed.

'''-w''': Print warnings.

'''-x''': Exclude files that match the specified [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression] from validation.

'''-C''': Validate using configuration file '''&amp;lt;configfile&amp;gt;'''.

'''-S''': Use the specified '''&amp;lt;schemafile&amp;gt;''' for validation.

'''-V''': Print version information.

=== Validation using default schemas ===

The ODF 1.0, ODF 1.1, ODF 1.2 schemas as well as the MathML 1.01 DTD and the MathML 2.0 schema are included in the '''ODFValidator.jar''' file. If the ODFValidator is called without the '''-S''' or '''-C''' options, these schemas are used for validation.

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] [-1.0|-1.1|-1.2] &amp;lt;odffiles&amp;gt;

'''&amp;lt;odffiles&amp;gt;''' is the list of files and directories that should be validated. If a directory is specified, all files that have an OpenDocument extension (like '''odt''', '''ods''' or '''ott''') are validated. If '''-r''' is specified additionally, all directories are processed recursively.

By default, the '''ODF Validator''' detects the version of the files that shall be validated and chooses the corresponding schema. The command line options '''-1.0''', '''-1.1''' and '''-1.2''' can be used to specify that the schemas of a particular ODF version should be used for all files, regardless of the version they specify themselves.

The command line option '''-d''' specifies that the MathML 1.01 DTD should be used for the validation of the '''content.xml''' of formula documents. Default is to use the MathML 2.0 schema.

If the '''-c''' command line option is specified, unknown markup is ignored as specified in the conformance rules for ODF 1.0/1.1.  If the '''-s''' command line option is specified, the strict schema is used for validation. If neither '''-c''' nor '''-s''' are specified, the regular ODF schemas are used, but errors are reported for unknown markup unless it appears in styles or metadata.

The optional '''-x''' switch allows to exclude certain files or directories from the validation. The files that shall be excluded are specified by a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. Please note that the full absolute path names of directories and files are matched against this pattern. This means that the regular expression either must include the absolute path of the files and directories that shall be excluded, or must start with '''.*'''. The '''-x''' option can be specified only once. If several paths shall be excluded, these paths have to be specified in a single regular expression using the '''|''' operator.

If '''-w''' is specified additionally, not only validation errors are reported, but also warnings.

If '''-v''' is specified additionally, not only validation errors and warnings are reported, but also the generator stored in the manifest, MIME types, the files that are processed, etc.

If the '''-o''' option is present, all messages go into the specified file. Otherwise, they are printed to standard out.

=== Validation using a non-default schema ===

Tho specify the schema that is used for '''meta-xml''', '''content.xml''', '''styles.xml''' and '''settings.xml''' on the command line, '''ODF Validator''' has to be called with the following parameters:

 odfvalidator [-r] [-c|-s] [-d] [-v|-w] [-x &amp;lt;expclude pattern&amp;gt;]
 [-o outputfile] -S &amp;lt;schemafile&amp;gt; &amp;lt;odffiles&amp;gt;

'''&amp;lt;schemafile&amp;gt;''' is the schema that shall be used.

All other command line option are as described in [[#Validation_using_default_schemas|Validation using default schemas]].

=== Validation using a configuration file ===

The schemas and the files that should be validated can be specified in a configuration file. A configuration file is a Java XML properties file as described in the [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html Java 2 API documentation]. The following properties are supported:

* '''strict-schema''': Specifies the strict schema to be used.
* '''manifest-schema''': Specifies the manifest schema to be used.
* '''mathml-schema''': Specifies the MathML 1.01 schema to be used.
* '''mathml2-schema''': Specifies the MathML 2 schema to be used.
* '''path*''': All properties whose names start with &quot;path&quot; are considered to be files or directories that shall be validated. 
* '''recursive''': This boolean property specifies whether directories are scanned recursively. It takes the values '''true''' and '''false'''.
* '''exclude''': Specifies files and directories that shall be excluded as a [http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum regular expression]. See description of [[#Specifying_the_schema_on_the_command_line|'''-x''' option]].

A sample configuration file looks like this:

 &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
 &amp;lt;!DOCTYPE properties SYSTEM &quot;http://java.sun.com/dtd/properties.dtd&quot;&amp;gt;
 &amp;lt;properties&amp;gt;
  &amp;lt;entry key=&quot;strict-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;manifest-schema&quot;&amp;gt;/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;mathml-schema&quot;&amp;gt;/home/odf11-cd2/msv/mathml2.xsd&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path1&quot;&amp;gt;/home/testdocs&amp;lt;/entry&amp;gt;
  &amp;lt;entry key=&quot;path2&quot;&amp;gt;/home/temp&amp;lt;/entry&amp;gt;
 &amp;lt;/properties&amp;gt;

== Where do I get the schemas? ==

&lt;span id=&quot;Where_do_I_get_the_schemas&quot;&gt;&lt;/span&gt;The OpenDocument schemas are those provided on the [[http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office OASIS OpenDocument technical Committee]] page.

'''Note:''' Due to an issue in MSV, errors are reported that do not exist. To avoid this, the schemas build into '''ODF Validator''' have been modified.

The MathML DTD that is included in the ODFValidator us the one that is included in the '''/share/dtd/math/1_01/''' folder of each OOo/StarOffice installation.

== Requirements ==

'''ODF Validator''' requires J2RE 1.5 or J2RE 1.6. For J2RE 1.6, the following options have to be included into the '''java''' command line:

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure/1.0=org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl  
 -Dorg.iso_relax.verifier.VerifierFactoryLoader=com.sun.msv.verifier.jarv.FactoryLoaderImpl

'''ODF Validator''' further requires the following packages:

* [https://msv.dev.java.net/ MSV]. '''msv.jar''', '''isorelax.jar''', '''relaxngDatatype.jar''' and '''xsdlib.jar''' included in the MSV distribution must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar''' at runtime. 
* [https://isorelax-jaxp-bridge.dev.java.net/ ISORELAX JARV -&amp;gt; JAXP 1.3 Xml Validation Engine Adaptor].  '''isorelax-jaxp-bridge-1.0.jar''' must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 
* ''' odfdom.jar''' from the [[ODFDOM|ODF Toolkit ODFDOM project]]  must be added to the project's libraries and must be in the classpath or a folder called '''lib''' that is next to the '''odfvalidator.jar'''  at runtime. 

== NetBeans Project ==

The '''ODF Validator''' [http://odftoolkit.org/sources/odf-validator-src/show source code] is located [http://odftoolkit.org/sources/odf-validator-src/show here].

The '''ODFValidator''' ia a NebBeans project. To work with the project, just open the project folder.

&lt;p style=&quot;margin: 15px 0px&quot;&gt;&lt;center&gt;Back to: [[Home|ODF Toolkit Wiki Home]]&lt;/center&gt;&lt;/p&gt;
</text>
  </page-revision>
</page-revisions>
