1. Introductory example

XMLmind XSL-FO Converter supports an XSL-FO extension to generate structured document tags (SDTs) in an Office Open XML document. Structured document tags are WordprocessingML elements that may be used to include form fields - such as text fields and drop-down lists - in an OOXML document and store form data in a dedicated part - called a Custom XML Data part - of the document. In other words, the SDT technology makes it possible to produce simple forms that can be loaded and filled in MS-Word 2007+[11]. As Custom XML Data parts are simple XML files the form data can then be easily extracted and processed. For further information regarding structured document tags refer to section 2.5.2 of part 4 (Markup Language Reference) of the Office Open XML specification, available from Ecma International.

The implementation and application area of this extension are better understood with a concrete example. Consider the simple XML instance below:

<?xml version="1.0" encoding="ISO-8859-1"?>

Now imagine we would like a simple form to collect and retrieve the missing information. We will illustrate how to use the XSL-FO extension for Office Open XML to create a form that can be loaded and filled in MS-Word 2007.

  1. Starting from our XML instance we first create an XSL-FO document, by applying an XSLT stylesheet or any other means. The XSL-FO tree will include custom elements that translate to form fields in the OOXML document. For instance the block below will provide a drop-down list with 3 entries for input of the organization category.

      <fo:block><fo:inline border="solid 1pt blue" font-family="Courier"
          binding="category" prompt="[Select category.]"
          <sdt:list-entry value="business" />
          <sdt:list-entry value="non-profit" />
          <sdt:list-entry value="other" />

    The binding attribute of the sdt:drop-down-list element establishes the mapping between the field and an XML element in the Custom XML Data part. In the simplest case the value of this attribute is an XML element name, and the Custom XML Data part is automatically generated by XFC. In the above example the field value will be stored as the content of element category in the Custom XML Data part when the OOXML document is saved.

  2. Using XFC we then convert the XSL-FO document to Office Open XML. The initial display of our sample document in MS-Word 2007 is shown below.

    This simple form includes a drop-down list for input of the organization category, a date field - a specialized text field which provides a date picker - for input of the creation date, and an image chooser for input of the logo. The figure below shows the appearance of the drop-down list when selected.

  3. This form may be used as a convenient means of collecting the missing information. The image below shows our sample document after it has been completed in MS-Word 2007.

  4. After the form has been filled the form data can be easily extracted and processed. (Office Open documents are basically ZIP archives, and the Custom XML part is stored in file customXml/item1.xml.) The Custom XML part of our sample document after it has been completed is shown below. (The content of the logo element is the base64-encoded image data. Part of the content has been deleted for the sake of clarity.) Typical processing of the form data includes updating the original XML document or data in an XML repository.

    <?xml version="1.0" encoding="UTF-8"?><root>

This is just a simple example to introduce the basics of the XSL-FO form field extension for Office Open XML. For further information and reference material, see below. You can also download the sample OOXML document to experiment with the form fields.

[11] This also works in MS-Word 2010 and 2013.