Currently Being Moderated

Today’s Office program support XML formats for saving and exchanging documents. There are two major standards: OASIS Open Document Format for Office Applications and Microsoft Office Open XML which is developed for Microsoft Office 2007.

At the moment the Microsoft Office Suite supports the following XML formats:

 

  • DataDiagramingML for MS Visio,
  • SpreadsheetML for MS Excel,
  • PresentationML for MS Powerpoint and
  • WordprocessingML for MS Word.

 

This weblog is about WordprocessingML - in short WordML. Using WordML you can create Word documents from your SAP Web Application Server.

 

Introduction into WordML

 

Since Word 2003 we can save documents in XML, more precisely in WordML. I suggest you create a Word document with the text content "Hello SDN community" and save this document as an XML document. The result will look like the following:

 

Hello SDN community!

 

In fact I simplified this example such the structure is easier to recognize. The document starts with an XML processing instruction mso-application progid="Word.Document". The root element is w:wordDocument.

 

You will immediately recognize similarities to HTML. The text content of the document resides within the element w:body. A single paragraph is the content of an element w:t within an element w:p.

 

If you write the text "Hello SDN community!" in boldface mode this is represented by an element w:b:

 

Hello SDN community!

 

The element w:r represents a run element: the container for data in a Word document. This container can contain text, pictures and so on. In the example above we have a text content within the element w:t. The element w:rPr represents the so called run properties for the paragraph and w:b sets asian and latin characters bold. 

Word is a very powerful tool so it is not surprising that the syntax is very complex. You can download the  WordprocessingML Schemas and additional information from http://www.microsoft.com/office/xml/default.mspx

Tips for Beginners

 

For your first XSL transformation generating WordML following tips may be useful:

 

Create a Word document as a template that you fill with additional elements w:p. Try to keep it as simple as possible and try to delete elements you don’t need.

 

Inspect the WordML representation of a Word document with the XML Toolbox. This tool is a free Word add-in that shows the current word document in an external viewer. You can download this tool from msdn.microsoft.com . In fact you need the .NET framework to use it.

 

Don’t forget the special Word processing instruction. Using XSLT you can insert it with following code:

 

  progid="Word.Document"

Possible Applications

 

Typical applications for WordML applications are normalizations of Word documents. We can change the o:DocumentProperties element to change the author’s or company’s name:

 

  First Try
  Tobias Trapp
   Tobias Trapp
  3
  0
  2006-09-12T15:09:00Z
  2006-09-12T16:06:00Z
  1
  48
  307
  AOK Systems GmbH
  2
  1
  354
  11.6113

With XSLT you can perform many cleanup tasks like removing comments or removing any direct formatting that hasn’t been applied with a style. Many people apply such transformations because they want to be sure that the receiver (perhaps a customer) of a word document gets only the visible information but not changes, comments and so on.

 

A typical application in R/3 is the generation of documentation. We can write a transformations that works on data stored in your R/3 system, the RTTI information of your ABAP classes, the transportation system and so on.

 

I don’t suggest that you start to write your own output management system after reading this blog. In my opinion the lightweight XSF output of SAP smartforms is more appropriate for generating different output like HTML-eMails, PDF and Word documents.

 

The techniques described above are not restricted to Word. They are XML formats for other word processors like Open Office using OASIS Open Document Format for Office Applications.

Comments

Actions

Filter Blog

By date:
By tag: