Word docs from Movable Type
Continuing on from yesterday's post showing how to make a slideshow from posts in your Movable Type weblog, you might be interested in other ways to present your blog posts so that people who don't read blogs can keep up with what you're publishing.
Today we'll look at Microsoft Office's support for XML, particularly WordML, the XML Schema used to make documents in Microsoft Word's XML format. (If you just want to see the end results, take a look at wordml.xml, showing the Professional Network blog as a WordML file.)
To understand how this works, it helps to know a little bit about how WordML works. John R. Durant's blog has some indispensable links about this topic. If you want to view the example output as intended, you'll need Microsoft Office Word 2003, which is the latest version of the popular word processing application. If you load the example in Internet Explorer on Windows, it will automatically prompt you to open the file in Microsoft Word.
If you're viewing the WordML file in another browser, or on a machine that doesn't have the latest version of Word, you'll see that this is a standard, valid XML file, which can be manipulated with the normal tools you use to work with XML.
Making the Document
Starting from the minimum WordML document, we add just enough headers to make the document display properly in Microsoft Word and some formatting so that text that's styled as Header 1 will display with its own formatting. Most other styling can be inherited from your default template in Word. If you really want the document to look like your standard templates, you can simply use Save As to save your default Word template as an XML file and place the appropriate Movable Type template tags in the right place in your file.
Here's what our Professional Network WordML template looks like:
<?xml version="1.0"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:o="urn:schemas-microsoft-com:office:office">
<o:DocumentProperties>
<o:Title><$MTBlogName encode_xml="1"$></o:Title>
<o:Author><MTEntries lastn="1"><$MTEntryAuthorNickname encode_xml="1"$></MTEntries></o:Author>
<o:LastSaved><MTEntries lastn="1"><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTEntries></o:LastSaved>
</o:DocumentProperties>
<w:styles>
<w:style w:type="paragraph" w:styleId="Heading1">
<w:pPr>
<w:pStyle w:val="Heading1"/>
<w:spacing w:before="240" w:after="60"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Trebuchet MS" w:h-ansi="Trebuchet MS" w:cs="Arial"/>
<w:b/>
<w:b-cs/>
<w:sz w:val="28"/>
</w:rPr>
</w:style>
</w:styles>
<w:body>
<MTEntries lastn="5">
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
</w:pPr>
<w:r>
<w:t><$MTEntryTitle encode_xml="1"$></w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t><$MTEntryBody convert_breaks="0" remove_html="1" encode_xml="1"$></w:t>
</w:r>
</w:p>
</MTEntries>
</w:body>
</w:wordDocument>
We've used the convert_breaks="0", remove_html="1" and encode_xml="1" attributes on our MTEntryBody tag to make the text be valid XML that displays correctly in Microsoft Word. The title for each post is styled as a Header 1 in Word, and we've set the template to only display the last five posts.
If you're making use of a template like this in your own organization, you'd want to customize the XML a bit more to follow your formatting standards, and you might also want to limit posts to a specific category in order to have a Word document that summarizes progress on a single project, for example.
Bloggers who are used to updating their status by posting to their Movable Type blogs can use a template like this to easily reformat their posts into a weekly report in Word that can be emailed around or simply posted to a web server for easy access. And, as with the slideshow template, it's easy for a group of people to contribute to a single document by collaboratively editing the posts that make up the final product. Finally, since Movable Type automatically generates RSS and Atom feeds of your posts, you can even subscribe to a feed for the document to see changes and additions as they happen.


Comments