Before you start
This tutorial is for users of OpenOffice, with a penchant for XML. If you're comfortable with the rigid syntax of the XML file format, and have dabbled with XML Style Language Transformations (XSLT), a world of possibilities opens up when you use OpenOffice as a custom editor for any type of XML-based data. This tutorial demonstrates the power of XSLT harnessed for the automatic manipulation and transformation of any XML-based data to and from the OpenDocument format, thereby bridging the divide between machine-readable XML and human-friendly hypertext.
11 Jan 2008 update: The code on lines 2 and 4 in Listing 10 was revised to:
... <xsl:template match="/"> <!-- Insert OpenDocument from context.xml here - cut and paste !--> </xsl:template> ...
OpenOffice began life as a "rebel with a cause" against Microsoft's popular Office suite. Since then, however, it evolved from yet another open source product to a full fledged suite of efficient and secure office applications—free and highly extensible—gaining more clout along the way from industry giants such as Sun Microsystems and, recently, IBM.
This tutorial focuses on a single facet of OpenOffice's extensibility, working with XML and XSLT filter files to allow plugin support for any data in the XML form. In this way you achieve the best of both worlds: You can store data as machine-friendly XML and still edit it in a human-friendly, custom manner. The former allows easy searches, semantic context and information retrieval, whereas the latter enables efficient editing in an advanced hypertext environment.
The tutorial explains how OpenOffice interacts with XML, through the OpenDocument format. It then walks through building an import filter (required for input file loading) and export filter (required for output file saving).
The XML format chosen for this is a custom XML rendering of the well known VCARD format (specified in RFC2426). VCARD is an Internet Standard used by Apple's iCal and Microsoft Outlook, among others, as online business cards or addressbook entries. While an XML representation for it has yet to be standardized, the author has worked with this format extensively in his Web-desktop environment (see About the Author). Additionally, the XML is easily transformed back to the text-based VCARD.
You'll need the following tools to follow along with this tutorial:
- OpenOffice, version 2.0 or above. These examples were created and demonstrated with the latest version of OpenOffice 2.2. Since then, due to an important and recommended security patch for mishandling of the TIFF file format, version 2.3 has come out, and everything in this tutorial was tested and works with version 2.3 as well.
- Your favorite XML editor is required to edit XML and XSLT files. The author uses vim on UNIX®, and Notepad on Windows®.