ODF Validator

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

ODF Validator is available as Java library for command line or embedded use, as well as a servlet. An instance of the servlet is hosted online courtesy of the OpenDoc Society. This page primarily describes the command line tool.

How to start

To use the '''ODF Validator''', the following steps are required:


Usage Summary

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

 java -jar "<path>/odfvalidator.jar"

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

  -jar "<path>/odfvalidator.jar"

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 <expclude pattern>] 
              [-o outputfile] [-1.0|-1.1|-1.2] <odffiles>
 odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-x <expclude pattern>]
              [-o outputfile] -S <schemafile> &lt;odffiles>
 odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C &lt;configfile>
 odfvalidator -g <odffiles>
 odfvalidator -h
 odfvalidator -V

If no parameters are specified, the files 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:

-1.0: Use the ODF 1.0 schemas regardless of the version specified by the validated document.

-1.1: Use the ODF 1.0 schemas regardless of the version specified by the validated document.

-1.2: Use the ODF 1.0 schemas regardless of the version specified by the validated document.

-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 <odffiles> 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 regular expression from validation.

-C: Validate using configuration file <configfile>.

-S: Use the specified <schemafile> 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 <expclude pattern>]
              [-o outputfile] [-1.0|-1.1|-1.2] <odffiles>

<odffiles> 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 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

To 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 &lt;expclude pattern&gt;]
 [-o outputfile] -S <schemafile> <odffiles>

<schemafile> is the schema that shall be used.

All other command line option are as described in 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 Java 2 API documentation. The following properties are supported:

A sample configuration file looks like this:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE properties SYSTEM "">
  <entry key="strict-schema">/home/odf11-cd2/msv/OpenDocument-strict-schema-v1.1-cd2.rng</entry>
  <entry key="manifest-schema">/home/odf11-cd2/msv/OpenDocument-manifest-schema-v1.1-cd2.rng</entry>
  <entry key="mathml-schema">/home/odf11-cd2/msv/mathml2.xsd</entry>
  <entry key="path1">/home/testdocs</entry>
  <entry key="path2">/home/temp</entry>

What is checked?

The following items are checked:

The following actions take place before or during the validation:

Where do I get the schemas?

The OpenDocument schemas are available on the OASIS OpenDocument Technical Committee page. The ODF 1.0 and 1.1 schemas can be downloaded directly from that page]. A zip file containing the most recent ODF 1.2 schemas is available in the document section.

The MathML DTD that is included in the ODF Validator us the one that is included in the /share/dtd/math/1_01/ folder of each Open Office installation.


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:


ODF Validator further requires the following packages:

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 Apache 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 source code is located here. ODF Validator uses Mercurial for source control. Please check the help for instruction how to use Mercurial.

Powered by the Apache CMS.

Apache "ODF Toolkit" is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Copyright © 2011 The Apache Software Foundation Licensed under the Apache License, Version 2.0. Contact Us
Apache and the Apache feather logos are trademarks of The Apache Software Foundation.
Other names appearing on the site may be trademarks of their respective owners.