I was reading today an internal distribution list and I saw an interesting thread about autonumbered lists using WordML (2003):
“I embarked on a journey to try and transform InfoPath rich text (xhtml) to WordML. I encounter a problem when I try to transform a rich text node that contains multiple numbered lists: in the rich text they both number from 1-3, but in Word the result is 1,2,3 and 4,5,6.”
Zander Westendarp provides a great workaround: If you increment the value of the w:listDefId elements for each element, you can get autonumbered lists that always restart the numbering.
When I work with WordML or SpreadsheetML, I always build a template of the document/spreadsheet that I want to generate and save it as XML. It’s the best way to get started with the code that you want to generate. I made an experiment to test this approach and explore the resulting WordML. Follow these simple steps…
- Start Microsoft Word 2003.
- Create a document with two sets of numbered lists as shown in Figure 1:
Figure 1. Create two sets of autonumbered lists
- On the File menu, click Save As.
- In the Save as type list, select the XML Document (*.xml) option.
- In the File name box, type a new name for the document.
- Click Save.
Once you create the XML Document file, you can open the file using a text editor program to explore the content of the file. Find all the w:listDef elements and you will see how the w:listDefId attribute is always incremented.
Tip: If you want to see a nice and readable indented XML file, see this blog entry.
I know that WordML is a big topic and every document is a separate story. Newsgroups, forums, and DLs are always full of different questions. Taking about lists is just a single topic – that by the way is huge and complex by itself. Fortunately there are documents, articles, books, and cool bloggers who share their knowledge.
Here are some WordML resources that I use when I am stuck with WordML:
- Overview of WordprocessingML.
- XML Schema Reference
- Office 2003 XML
- Office 2003 XML for Power Users
- Powering Office 2003 with Office XML
- XML in Office 2003: Information Sharing with Desktop XML
If you want to learn more about lists and WordML, read Oleg Tkachenko’s blog entry: Generating WordprocessingML using XSLT: Lists. Also read John Durant’s blog entry: WordProcessingML, XML, and Lists.
Finally, to learn WordML, divide and conquer, that’s my strategy…