Linkwerk Logo

invitation.xml - Transform a single source XML file to several output formats

This is a collection of articles and code snippets to demonstrate the advantages of XML for converting data or documents to several output formats. Legal information for the software is described in the licence file (please note that there are special licence conditions regarding the XML2WordML example; read them carefully). The articles are copyrighted and may not be copied; I appreciate if you link to this page.

The starting point for all examples is my invitation.xml, a sample XML file with a real invitation to a fictitious party ;-). The goal is to display this invitation in different media or software, like the Web, paper (PDF), Microsoft Word; maybe more in the future. Note: invitation.xml does not have a corresponding DTD or schema (XML Schema, Relax NG Schema, etc.), although it does make sense to have a schema for such kind of XML instance. The reason for the missing schema is, that the focus of this samples is how to transform XML, instead of how to model documents with XML.

To begin, take a look at the invitation.xml. It's pretty simple and straight forward. BTW: If you want to try my examples, you'll need an XSLT engine, such as Saxon, Xalan, xsltproc.


If you don't know anything about processing XML with XSLT, it's best to go on with the article about how to convert invitation.xml to XHTML — you probably know XHTML (or at least HTML) which makes the transformation process easier to understand.

2. XML2PDF (aka XML2XSL-FO2PDF ;-)

With the second step I aim at producing a PDF file from invitation.xml. Since PDF is not XML-based, we can't generate PDF with just an XSLT transformation. XSLT is designed for transforming from one XML format to another. The XML format for this task is XSL. It's sometimes called XSL-FO to avoid confusions between XSLT (the transformation language) and XSL-FO (the Formatting Objects XML-format). The formatting of XSL-FO to PDF is done by an XML-FO processing software, which is able to produce PDF.

Read on about transforming XML to PDF.

3. XML2Word (aka XML2WordML)

Since version 2003 of MS Office, Word is able to write and read it's documents in it's own XML format, called WordML. This means, we can transform invitation.xml to Word with XSLT.

Read on about transforming XML to WordML.

3.1 XML2Word with Images

Since WordML requires externally refereneced images to have width/height set, there's a problem when transforming XML with images to WordML.

Read about a solution for detemining images sizes for generating WordML.

© 2005-2007, Stefan Mintert, All rights reserved