XML Filter Tools
It's the purpose of these tools to load XML-based filter components and to execute them stand-alone. The basic concept of XML-based filter components are described in the OOo Guide to XML Filters.
Note: There have been some questions on what you can actually do with xfilter. If a filter was written according to the XML-based filter concept, then it can be used with the tool. Unfortunately, OpenOffice.org currently does not include any such filters. The reason is that the concept is fairly new, and most filters (including the MS filters) have been developed before that. StarOffice 6.0, which is based on OpenOffice.org but includes (among others; see FAQ) some additional filters has three new filters that can be used with the xfilter tool.
Use
- You need:
- an installed OOo
- xfilter binaries for that build
- the regcomp binary from the ODK
- Copy the files for your platform into the OOo program directory
- Call the starter script with parameters for the component name and input file. The starter script will register the libraries and then call the actual xfilter program.
Example:
- Windows:
> copy xfilter.exe xfiltermi.dll xfilter.bat <OOo directory>\program > cd <OOo directory>\program > xfilter.bat com.sun.comp.hwpimport.HwpImportFilter input.hwp
- *nix:
> cp xfilter libxfilter??.so xfilter.sh <OOo directory>/program > cd <OOo directory>/program > xfilter.sh com.sun.comp.hwpimport.HwpImportFilter input.hwp
Implementation Detail
The program consists of a starter application, which initializes the UNO runtime and the UCB to provide for UNO component instantiation and input/output functionality, respectively. Then, the starter program instantiates the filter component (as given on the command line), and imitates the use of the component through the XImporter and XFilter interfaces.
Limitations in the emulation of the OOo filter invocation are:
- The
XImporter::setTargetDocument()
call received an empty reference where the document model is expected - The
XFilter::filter()
call receives a MediaDescriptor, which contains only an URL and an opened XInputStream for the input file. - Additional services or components usually provided for and initialized by OOo may not be available.
In order to generate output on the console, the com.sun.comp.Writer.XMLImporter
component, which is usually instantiated by the filter component, needs to be replaced by a dummy implementation that simply outputs the XML data to the standard console output. This dummy implementation is given in the xfilter DLL/lib (xfiltermi.dll/libxfilter??.so).
StarOffice Filter components, on which the xfilter tool has been tested:
com.sun.comp.hwpimport.HwpImportFilter
com.sun.comp.WPSimport.IWPSImportFilter
com.sun.comp.jsimport.IchitaroImportFilter
Source code
The source code for this probably isn't very interesting, but you
can obtain it from the xml/filtertools
directory in the
CVS archive. You can also browse it online.
Binaries
Binaries for a few platforms can be downloaded here:
- Windows, SRC641 (OpenOffice.org 1.0, StarOffice 6.0)
Please direct comments and suggestions to the xml-dev mailing list (archive) or to dvo.