General

Components

Community

Development

TDF

ODF Validator

Overview

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 use or as web application archive (WAR). An instance of the WAR is hosted online. This page describes the command line tool, the user front-end of the WAR should be self-explaining.

How to start

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

    mvn install
    java -jar "./target/odfvalidator-<VERSION>-jar-with-dependencies.jar" <odffile>

Usage

Usage Summary

In a command-line environment, ODF Validator is invoked by the following command:

     java -jar "<path>/odfvalidator-VERSION-jar-with-dependencies.jar"

This command line is abbreviated odfvalidator from now on.

The ODF Validator may be called with the following options:

    odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-f <filterfile>] [-x <regexp>]
                  [-o outputfile] [-1.0|-1.1|-1.2|1.3] <odffiles>
    odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-f <filterfile>] [-x <regexp>]
                  [-o outputfile] -S <schemafile> <odffiles>
    odfvalidator [-r] [-c|-e|-s] [-v|-w] -O <rngfile> -M <rngfile> -D <rngfile>
                  -m <rngfile> [-f <filterfile>] [-x <regexp>] [-o outputfile]
                  <odffiles>
    odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C <configfile>
    odfvalidator -g <odffiles>
    odfvalidator -h
    odfvalidator -V

If no parameters are specified, the files <odffiles> 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.1 schemas regardless of the version specified by the validated document.

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

-1.3: Use the ODF 1.3 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 or later documents this option does not have any effect.

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

-d: deprecated and ignored; Whether to use MathML 1.01 DTD or MathML 3 schema for validation is auto-detected.

-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 strict ODF <schemafile> for validation with -s.

-O: Use ODF schema <schemafile> for validation.

-M: Use ODF manifest schema <schemafile> for validation.

-D: Use ODF dsig schema <schemafile> for validation.

-m: Use MathML schema <schemafile> for validation.

-f: Use filterfile <filterfile>.

-V: Print version information.

Validation using default schemas

The schemas for supported ODF and MathML versions are contained in the git repository and automatically bundled into the jar file during the build. 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] [-f <filterfile>] [-x <regexp>]
                [-o outputfile] [-1.0|-1.1|-1.2|-1.3] <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, -1.2, etc. 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 validator automatically detects whether the MathML 1.01 DTD or the MathML 3 schema should be used for the validation of the content.xml of formula documents.

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 or later document, unknown markup is ignored as specified in the extended conformance class rules for ODF 1.2 or later. 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 non-default schemas

To specify the schemas that are used on the command line, ODF Validator has to be called with the following parameters:

    odfvalidator [-r] [-c|-e|-s] [-v|-w] -O <rngfile> -M <rngfile> -D <rngfile>
                  -m <rngfile> [-f <filterfile>] [-x <regexp>] [-o outputfile]
                  <odffiles>

-O: <rngfile> is the schema to be used for the meta-xml, content.xml, styles.xml and settings.xml of embedded ODF documents.

-M: <rngfile> is the schema to be used for manifest.xml of the ODF package.

-D: <rngfile> is the schema to be used for for any digital signature files of the ODF package.

-m: <rngfile> is the schema to be used for content.xml of any embedded MathML documents.

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 API documentation. The following properties are supported:

A sample configuration file looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
      <properties>
      <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="mathml3-schema">/home/odf11-cd2/msv/mathml3.rng</entry>
      <entry key="path1">/home/testdocs</entry>
      <entry key="path2">/home/temp</entry>
      </properties>

What is checked

The following items are checked:

The following actions take place before or during the validation:

Where are the ODF schemas

The OpenDocument schemas are available on the OASIS OpenDocument Technical Committee page. The ODF schemas can be downloaded directly from that page.

The MathML 1.01 DTD that is included in the ODF Validator is the one that used to be included in the /share/dtd/math/1_01/ folder of each OpenOffice.org installation.

Requirements

ODF Validator requires JRE 11. The properties required to find necessary classes javax.xml.validation.SchemaFactory and org.iso_relax.verifier.VerifierFactoryLoader are automatically set up by the build process in META-INF/services/ of odfvalidator-<VERSION>-jar-with-dependencies.jar so this jar file can be run without additional settings.

ODF Validator further requires the following packages:

Note: ODFDOM requires Apache Xerces. The jar file xercesImpl.jar is fetched automatically by the maven build.

Source Code

The ODF Validator source code is located here. ODF Validator uses git for source control.

Impressum (Legal Info) | Privacy Policy (Datenschutzerklärung) | Statutes (non-binding English translation) - Satzung (binding German version) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Apache License, v2.0. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License v2.0. “LibreOffice” and “The Document Foundation” are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy. LibreOffice was based on OpenOffice.org.