ODF Applications > XSLT Transformation

XSLT Transformation

Download version of 28 Mar 2006

This is an alpha version of a stylesheet that converts the content.xml of an OpenDocument text file to XHTML. It is intended to give you a reasonable idea of what the file looks like, not to do a completely accurate job of rendering the file.


Because this stylesheet looks only at the content.xml file, it cannot completely represent the style information of the document, some of which resides in the styles.xml file. Because it is constructing only a single XHTML output file, it does not include images.

Using the Stylesheet

You can’t just run this stylesheet against an .odt file with a typical transformation program because the OpenDocument file is in a .zip format. Instead, you need a special program that can read directly from the compressed file. That program is ODTransform.java. This program should work with any package that implements the java.xml.transform API, but has been tested only with Xalan. The odtransform.sh shell file shows its invocation with the Xalan libraries; change the paths to match your Xalan installation.

To convert the file testfile.odt to testfile.xhtml, you would enter this at the command line:

./odtransform.sh -inOD testfile.odt -in content.xml -out testfile.xhtml

FYI: Here are the usage instructions for the ODTransform program.

Usage: ODTransform options
   -in inputFilename
   -xsl transformFilename
   -out outputFilename
If the input filename is within an OpenDocument file, then:
   -inOD inputOpenDocFileName
If you wish to output an OpenDocument file, then:
   -outOD outputOpenDocumentFileName

Option names are case-insensitive.

See list of changes