The first part of transforming XML to WordML is similar to many other transformations. One thing is special when generating WordML markup: WordML requires you to set the size of linked images (in contrary to embedded base64-encoded images).
We update our invitation.xml to include a reference to an image:
There's a new element named picture, which contains a reference to a JPG image on the harddisk and a scaling factor.
Unfortunately XSLT has no means to determine the size of an image. But Java has... Consequently we wrote our own XSLT extensions named PicMe (Picture Metadata) based on standard Java classes, which reads the file an provides an XSLT stylesheet with the required image dimensions.
The usage is quite simply: You need to declare a namespace prefix for PicMe and call the method getXMLMetaData() with the filename as the only argument. getXMLMetaData() returns the image information as an XML structure. The child elements width and height carry width/height in pixels. The extract of the updated XSLT is shown here:
Finally you might want to take a look at the result document in Word: You can download a Screenshot or a Zip-File with the WordML- and Jpeg-File.