• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10. Word 2003 XML Hacks > 94. Transforming XML into a Word Document

Transforming XML into a Word Document

With the right XSLT stylesheet, you can quickly transform an XML document into a Word document.

A potential killer app for WordprocessingML is the ability to publish Word documents from dynamic XML content. In this hack, we’ll look at a simple XML document that vaguely resembles HTML. The code for this hack will transform the document into a full-fledged WordprocessingML document you can open in Word. Type the following in a standard text editor such as Notepad and save it as simpleDocument.xml:

<doc>
  <h1>Hello, this is my document heading</h1>
  <para>This is <emphasis>italic</emphasis>.</para>
  <h2>This is a sub-heading</h2>
  <para>This text is <strong>bold</strong>.</para>
  <para>This text is <strong><emphasis>bold and italic</emphasis>
                 </strong>.</para>
  <para><emphasis><strong>And so is this.</strong></emphasis>.</para>
  <para>And <emphasis>this is italic and <strong>this is both
                 </strong></emphasis>.</para>
  <para>Finally, <strong>this is bold and <emphasis>this is both
                 </emphasis> and back to just bold</strong>.</para>
</doc>

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint