ODFXSLTRunner

From OpenOffice.org Wiki

Jump to: navigation, search

Contents

[hide]

Simplify the application of XSLT stylesheets to ODF documents

ODFXSLTRunner is a small Java application that allows you to apply XSLT stylesheets to XML streams included in ODF packages without extracting them from the package. It can be used from the command line. A driver to use it within Ant buildfiles is also available.

Getting and building ODFXSLTRunner

odfxsltrunner is build by a NetBeans project. After you have checked out the sources, you can open the project in NetBeans and build odfxsltrunner.

A binary release of odfxsltrunner.jar is available here.

Building and running odfxsltrunner.jar requires additional jar files. Please see Requirements for details.

Command Line Options

ODFXSLTRunner is called by one of the below command lines:

java -jar odfxsltrunner.jar <style sheet> [-v] [-p <path in package>] [-l log file]  <input package> [<output package> [name=value ...]]
java -jar odfxsltrunner.jar <style sheet> [-v] [-p <path in package>] [-l log file] -t <input package> <output package> [name=value ...]
java -jar odfxsltrunner.jar <style sheet> [-v] [-p <path in package>] [-l log file] -r <package> [name=value ...]
java -jar odfxsltrunner.jar <style sheet> [-v] [-p <path in package>] [-l log file] -o <input package> <output file> [name=value ...]
java -jar odfxsltrunner.jar <style sheet> [-v] [-p <path in package>] [-l log file] -i <input file> <output package> [name=value ...]

The default is to apply the XSLT stylesheet <style-sheet> to the stream content.xml of the ODF file <input package>. If no <output package> parameter is specified, then the result of the transformation will be printed to the standard output. If an <output package> is specified, the <input package> is copied to the <output package>, and the steam content.xml of the <output package> is replaced with the result of the transformation.

The -p option allows to specify another stream in the package as source of the transformation than content.xml.

The -t options allows to specify a template for the output package. If it is used, the result of the transformation is stored in the content.xml stream (or the stream specified by the -p option) of the <output package>, but other streams of <output package> than that are not modified. This option can be used together with the -i option to create an ODF file from a plain XML file.

The -i option allows to specify a plain XML file <input file> as source of the transformation.

If the -o option is specified, the result of the transformation is stored in the plain <output file> rather than in a ODF package. This is for instance of interest if the result of the transformation is HTML.

The -r option allows to modify the content.xml stream (or the stream specified by the -p option) in place. If it is specified, the result of the transformation just replaces the stream that was the source of the transformation. This option should be used with care, because it modifies the original input ODF file.

The -v option enables a verbose mode.

The -l option can be used to redirect diagnostic messages into a log file. By default they are printed on standard error.

XSLT Parameters can be passed to the transformation by specifying them as name=value pairs. They must appear behind all other command line parameters.

Requirements

odfxsltrunner requires J2RE 5, or a later version of Java. It further requires ODFDOM (at least version v0.6.1). The ODFDOM jar file must be either located in folder called lib next to the odfxsltrunner.jar file, or it must be in the classpath.

Note: ODFDOM v0.6.1 requires Apache's xerces. The jar file xercesImpl.jar also must exist in a folder lib next to odfxsltrunner.jar file, or it must be in the classpath.

Background Information

ODFXSLTRunner - a new tool in the ODF Toolkit project

Personal tools
Collection