Betsy Rolland
LIS 600 Independent Study

Transforming XML to Microsoft XML
Terry Brooks
Winter 2006

Create a Hand-Coded Microsoft Word XML (WordprocessingML) File that Opens in MS Word

The instructions below will walk you through creating a simple "Hello, World" XML file that opens directly in Microsoft Word without needing any transformation.

Document:

wordProcXML.xml

Steps:

  1. Create a new XML file.

  2. Insert the following header and processing instructions at the top:

    <?xml version="1.0" encoding="UTF-8"?> Regular XML header
    <?mso-application progid="Word.Document"?> Associates the XML document with Microsoft Word
    <w:wordDocument Defining the Word Document
    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" Maps to the "w" prefix. This namespace contains all core WordProcessingML elements and attributes.
    xml:space="preserve"> Preserves whitespace in the document.

  3. Add a body tag. The wordProcessingML syntax is
  4. <w: body>

    </w: body>

  5. Within the body tag, add your text. Each element of text needs to be in a separate structure. Any styles or formatting can only be applied to this unit; mixed elements are not allowed. For example, if you want to have a bold sentence with italics in the middle, you would need to create three separate text elements: (1) the bold words at the beginning of the sentence, (2) the bold and italicized words in the middle of the sentence and (3) the bold words at the end of the sentence. The sentence below would require three separate paragraph structures to display properly in Word.
  6. The quick brown fox jumped over the lazy dog.
    bold bold and italics bold

    Each text element is contained within the following structure:

    <w: p> "paragraph"

    <w: r> "run"
    <w: t>Hello, World!</w: t> "text"
    </w: r>
    </w: p>

  7. Close off all tags, save the page as XML, then open in Word.