Open Office XML: An Introduction

Since Microsoft’s introduction of the Open Office XML format, it has slowly become an industry accepted standard. Those nifty little “.[file-type]x” formats, i.e. .docx, .xlsx, .pptx, are openable by the standard selection of office application suites. Because of this standard, we can programmatically create documents, spreadsheets, or even presentations via XML. In this article, we’ll introduce you to the terminology and basic concepts you’ll need to know.

A file is made up of packages and parts. A package is, in essence, the collective file, or can also be simply a collection of parts. A part can be a block of text, an image, or a cell in a spreadsheet.

The standard office formats, documents, spreadsheets, and presentations, have particular sub-languages of the Open Office XML structure: WordrocessingML, SpreadsheetML, and PresentationML, respectively. Each of these sub-languages go into more depth on how to build the appropriate parts, relationships, and characteristics of that particular filetype. There also existing supporting sub-languages, such as DrawingML, that are more directly tuned and related to typical parts found in these documents.

Generating parts is pretty straightforward:

<w:document>
  <w:body>
    <w:p/>
  </w:body>
</w:document>

In this example, we have a document part, a body to that document, and a paragraph. Each XML entity, in this example, is considered to be a part of an OOXML package.

Where OOXML becomes powerful, however, is not the simple creation and customization of parts. Relationships, i.e. how parts relate to one another and the package itself, is where you can truly begin to build more advanced documents. A common relationship is for an image:

<w:pict>
  <v:imagedata r:id="rId4"/>
</w:pict>
<Relationships ...>
   <Relationship Id="rId4" Type="../relationships/image"
      Target="image.jpg" />
</Relationships>

With this example, we have an image referenced to the external file of image.jpg via a relationship. Relationships are referenced via the Id attribute.

In our next article, we’ll build a “Hello, world!” document with Open Office XML and WordprocessingML.

For more information, check out: http://openxmldeveloper.org/

Michael Marr
About Michael Marr
Michael Marr is a staff writer for WebProNews

One thought on “Open Office XML: An Introduction

  1. Pingback: Australian Government Adopts Open Office XML Format | Programming Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>