Getting Started with XForms in OpenOffice

Discover how to design and customize XForms in OpenOffice.

by Bryan Rasmussen

Jun 13, 2008

Page 1 of 4

ost developers have heard of XForms as an XML-based forms language meant to replace traditional HTML Forms. This is essentially correct; XForms was created as the next generation version of HTML forms—but the design goals are such that they can be implemented as forms in environments other than the web browser. One such environment is your typical office application. XForms is implemented as one possible method of doing forms-based applications in OpenOffice or Sun's StarOffice.

The XForm discussed in this article has been tested on both a Microsoft Windows XP installation, and a Xandros Linux installation. Note that the file URI for output submission was adapted for each operating system's specific file paths.

What You Need

This article gives a quick overview of how to design an OpenOffice form as an end-user, and provides the syntax for making an OpenOffice XForm match a required XML output format. The article assumes that readers have at least a simple knowledge of XML, XPath, and XML Schema. To follow along or use the downloadable code, you should have OpenOffice version 2.4 or higher installed.

Choosing an XML Format
You need an XML format for the form. The example discussed here uses a Danish governmental format that represents the data for a single postal address (only the address, not such extraneous information as the identity of whoever resides there) with additional constructs specific to Denmark. This format makes a decent example because it is simple enough to be comprehensible, yet real-world enough to be potentially useful.

The XKOM (for XML Kommittee) AddressPostal format defines a single complex element named AddressPostal that holds a sequence of 11 simple elements, only some of which are required. An instance document has up to four possible namespaces. Here's an example used throughout this article that contains three of those namespaces and the five required elements: