Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Use XSLT to expand OpenOffice's editing capabilities

Create import and output filters to edit your XML as rich text

Jonathan Levin, Trainer and consultant, Freelance
Jonathan Levin is a freelance trainer and consultant in a myriad array of topics, ranging from XML/XSLT and Ajax, through low-level protocols and device drivers for Linux and Windows. He has designed and developed a lightweight Web-desktop environment called JADE (http://jade.hisown.com) that provides enterprise-class email, calendaring, RSS, and full remote file system functionality which makes extensive use of XML and XSLT along with PHP in the backend and JavaScript in the frontend.

Summary:  You might know that you can pull XML data into OpenOffice's spreadsheet program, Calc, but did you know that you can create a filter to make word-processing documents out of data stored as XML? This tutorial shows you how to use OpenOffice's import/export filters to open your XML data as though it's just a plain document. From there, users can edit the document much more naturally and then save it back to its native format. You can also use this feature to easily turn your documents into XML data.

Date:  11 Jan 2008 (Published 09 Oct 2007)
Level:  Intermediate PDF:  A4 and Letter (340 KB | 29 pages)Get Adobe® Reader®

Activity:  19084 views
Comments:  

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>
...
  

About this tutorial

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.


Prerequisites

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®.

1 of 9 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML
ArticleID=259452
TutorialTitle=Use XSLT to expand OpenOffice's editing capabilities
publish-date=01112008
author1-email=JL@hisown.com
author1-email-cc=dwxed@us.ibm.com