• Skip to content
  • Skip to link menu
The KOffice Project
  • KOffice Homepage / Developer Resources / File Format
 

How to validate an OASIS OpenDocument file

It is important to check that all files produced by KOffice when choosing the OASIS OpenDocument file format, conform to the OASIS OpenDocument RelaxNG schema. Developers will try to ensure that, but it can also be helpful to check yourself, in order to help them fix such problems before they create interoperability trouble.

Download the RelaxNG schemas

Your first mission is to download the latest RelaxNG schema of the OASIS OpenDocument specification from www.oasis-open.org. Make sure you take the three RNG schemas, and the human-readable version of the specification as well, with the comments (either the .sxw or the .pdf)

Download jing

Jing is a java tool for checking XML files against a RelaxNG schema. You can get it from http://www.thaiopensource.com/relaxng/jing.html (follow the download link). For instance I got jing-20030619.zip

Download JRE 1.4

Unless you're using the gcj-compiled version of jing, you need a Java Runtime Environment. Jing recommends using JRE 1.4, which can be downloaded from from java.sun.com

Write shellscripts

Create a script (e.g. I named it oasislint), which does something like


#!/bin/sh
java -jar $HOME/src/jing/bin/jing.jar \
     -i /d/kde/opendocument/OpenDocument-schema-v1.1.rng $*
    

You will need to adjust the paths to the .jar and .rng files, of course. If java isn't in your path, you'll also need to change your PATH environment variable, or use a fully-qualifed path to the java binary in the script.

Create a similar script named oasislint-strict which uses OpenDocument-strict-schema-v1.1.rng instead.

Finally, it would be helpful to have a script that automatically checks the XML files inside a ZIP package (since KOffice documents are ZIP packages), so that you don't have to unzip it by hand. Here is one, which I called oasisfilecheck:


#!/bin/sh
input="$1"
echo "$input" | grep -v '^/' >/dev/null 2>&1 && input="$PWD/$input"
tmpdir=/tmp/oasistmp
rm -rf $tmpdir ; mkdir $tmpdir && cd $tmpdir || exit 1
unzip -o $input || exit 1
for f in content.xml styles.xml meta.xml settings.xml; do
  echo "Checking $f..." ; oasislint $f
  if test $? -eq 0 ; then
    echo "Checking $f strict..." && oasislint-strict $f
  fi
done
   

Inform

Skip menu "Inform"
  • Home
  • KDE Home
  • News
  • Information
  • FAQ
  • Add-ons for KOffice
  • People
  • Mailing Lists
  • Support KOffice

Latest Releases

Skip menu "Latest Releases"
  • KOffice 1.6.3
  • KOffice 2.0-beta1
  • Security

KOffice Applications

Skip menu "KOffice Applications"
  • KOffice Workspace
  • KWord
  • KSpread
  • KPresenter
  • Kexi
  • Kivio
  • Karbon14
  • Krita
  • KPlato
  • KChart
  • KFormula
  • Kugar

Documentation

Skip menu "Documentation"
  • KOffice 1.6.3
  • Supported File Formats

Competitions

Skip menu "Competitions"
  • Recent Competitions
  • KOffice2 Design

Download

Skip menu "Download"
  • Download

Development

Skip menu "Development"
  • Developer Resources
    • Information
    • API Reference
    • Tasks
    • Filters
    • File Format
      • KDE Developer Site
    • Website
    • KDE Developer Site
  • Get Involved
  • KOffice Sprints

Global navigation links

  • KDE Home
  • KDE Accessibility Home
  • Description of Access Keys
  • Back to content
  • Back to menu
Maintained by koffice.org Web Team
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal