Importing XML documents into Word 2007 and OpenOffice Writer through XSLTs

By Rick Jelliffe
August 11, 2008 | Comments: 4

One option that has almost no documentation in Word 2007 is the open with transform item, available on a pulldown from the Open dialog box. With it, you can select an XML file, then transform it through an XSLT you select in another box, and theoretically Word attempts to open it. I say theoretically, because the only transformation that actually seems to work is to generate HMTL (not even XHTML).

However, this does work quite well, and it provides an important missing gap in processing XML with Word. (Microsoft makes more noise about the custom content controls, or the CustomXML tags, but neither of these is very satisfactory as soon as you start to want to format documents with multiple repeated tables.)

OpenOffice provides a much more satisfactory way to do this: in the Tools>XML Filter Settings... dialog box you can bind input and output XSLT filters to particular file extensions: in theory this may even allow quite good round-tripping of elements (I daren't hope for attribute preservation too!). (I need to check up, but my impression as that adding support for an equivalent feature in Word would be possible but it isn't there now.) You convert to and from the OpenDocument Format.

I suspect that the reason that OpenOffice has a more advanced and pleasant feature here over Office 2007 is merely that XSLT got a bad reputation at MS for a while a few years back. And the move to a multi-part format OPC does indeed mean that some decisions would need to be made in order to get good XSLT support, especially if they are using XSLT 1: for example, how to generate a separate stylesheet file, and how to support OPC relationships. ODF does not have these issues. (On the other hand, it is not that these are insuperable problems: even just deciding to allow multiple stylesheets on the input data to handle the main document, the stylesheet, the metadata and the media would be workable.)

However, opening an XML file with an XSLT transformation (whether through HTML in Word's case or through ODF in Open Office's case) is a simple, useful and valuable technique for integrating work processing systems into larger XML ecosystems: indeed, where you have web developers who know XSLT (and where the document does not need to be smart), open-with-transform may even be preferable than using other possibilities (XForms, custom content controls with XML binding, etc. that may seem tempting) to shield the developer from having to learn a platform-specific API (such as Java, .NET, etc.)

(If anyone knows how to make Word's open-with-transform work with anything other than HTML/CSS generation, I would be very interested.)


You might also be interested in:


4 Comments

Open with transform was actually intended to transform from XML to WordProcessingML in Word 2003. It can be made to work, although personally I do not think many people will find it worth their while to create the XSLT necessary to do it. No idea where that has gone in Word 2007.

In office 2003 I am hoping to use the XML inference tool to achieve the sort of repeating item trick - but haven't plumbed its depths yet. There doesn't seem any reason it couldn't be used with office 2007 BUT its bizarre that whacky Msoft wouldn't make their 'xml' document format a little more accessible.

i had an aplicattion in visual c# 2005 i am generate a XML File with Microsoft XML format whe open it wit Microsoft Word they show the tables correct but when open the same XML with OpenOffice this donĀ“t show the splits cells it repeats the cells content

Example.
Cells Splits Horizontally with Microsoft Word
| |
Situation|cause 1|Rec1
|cause 2|rec1
|rec2

Out with OpenOffice Writer

Situation|cause 1|Rec1
Situation|cause 2|rec1
Situation|cause 2|rec2

exist any instruction read writer to splits this cells?

Guys,

Dont worry....Converting XML file with XSL into word is so easy.....
First you need to design your XML file by using Infopath...then after that Export into Web (Mht) format. Open the Mht format in Word.

Popular Topics

Archives

Or, visit our complete archives.

Recommended for You

Got a Question?