[Blog Map] This blog is inactive. New blog: EricWhite.com/blog
This is one in a series of posts on transforming Open XML WordprocessingML to XHtml. You can find the complete list of posts here.
When implementing a conversion of Open XML word processing documents to HTML, one of the interesting issues is accurately converting numbered and bulleted lists. You must pay special attention to them, because they impact the text that the document contains, but that text isn't directly in the markup. If you are accurately extracting the text of the document, you must process some elements and attributes to assemble the correct text.
Numbered items and bulleted lists are not trivial, and justifiably so. There are a large number of features of numbered and bulleted lists, each used by a different set of users. These features are represented by elements in the markup. However, you don't need to pay attention to all elements. Some aspects of the markup are there just to affect the user interface, and you don't need to pay attention to those elements when determining the textual representation of a numbered or bulleted item. This post presents just the essentials that you need to know to work with numbered and bulleted items.
I've written an MSDN article, Working with Numbered Lists in Open XML WordprocessingML, that describes how Open XML WordprocessingML markup works for numbered and bulleted lists. Thanks to Tristan Davis, Zeyad Rajabi, and Brian Hyams for tech reviewing the article.
Is it possible to implement this kind of numbering based only on a pure XSL?
Hi Nikolay, I'm sure it is possible - in XSLT 1.0, you would need to write some templates that are effectively functions that return a sequence constructor as a return value. XSLT 2.0 has functions, as you probably know, so that is what you would use.
Thanks for posting this, I found the highlighted code sections easier to follow than in the MSDN library. I am trying to do something pretty simple, but am having a tough time finding an example to follow. In C# I have an array of one-word strings and would like to make a numbered list out of them in word.
I made a simple example manually in a .docx, then used the XMLSDK tool to see what paragraph code it generates for an item in the list. I place that paragraph code in a for-loop, increment the NumberingID val by 1 upon each iteration, and then append the new paragraph to the Document.Body; the problem is, when I open my output file in Word, most items on the list has "1." for its list item value.
Is there an example you might point me to, of achieving this?