On June 20, 2011 (two days ago), I posted an update to DocumentBuilder. After more extensive testing, I found and fixed a few bugs in less common scenarios, including if comments in multiple sources contain images, multiple sources contain endnotes with images, and a few other situations. If you have downloaded DocumentBuilder 2.0, please re-download it.
Archive for WordprocessingML
At long last, I have completed and posted a much requested and sorely needed update to DocumentBuilder. DocumentBuilder is code that is part of the PowerTools for Open XML project that handles issues of interrelated markup, enabling you to generate new documents from existing documents in a variety of ways. Many more details on OpenXMLDeveloper.org.
Searching and replacing text in an Open XML WordprocessingML document is not awfully difficult, but there are a few issues that complicate the process. The text that you are searching for may span multiple runs, so the algorithm that searches for text needs to take this into account. The replacement text should have the character formatting of the first character of the string in the document that matches the search string. I’ve written a blog post at OpenXMLDeveloper.org that presents the algorithm, as well as example code written using XmlDocument (Microsoft’s implementation of XML DOM). In addition, I’ve recorded a screen cast that explains the algorithm:
I’ve written a short article at OpenXMLDeveloper.org that shows how to detect tracked revisions using XmlDocument. Previously, I wrote an article on detecting tracked revisions using LINQ to XML or the strongly-typed object model of the Open XML SDK 2.0. However, some developers do not have the option of using LINQ, and instead must use one of a variety of XML DOM Document implementations. The OpenXMLDeveloper.org article presents some XmlDocument code that is pretty easy to translate to other languages and platforms.
I’ve recorded a short screen-cast that explores some approaches to setting margins in a word-processing document. I show setting margins for cells, paragraphs, and sections.
I’ve written a blog post at OpenXMLDeveloper.org that presents some code to query an Open XML WordprocessingML document for fields. The code returns the field code for each field in the document. Using this code, it becomes trivial to query a document for all hyperlinks in the document. This will be the subject of my next post at OpenXMLDeveloper.org.
I’ve posted the second video in this series on Open XML WordprocessingML fields and hyperlinks. In this video, I show how the MarkupSimplifier application makes the markup for fields more understandable. In addition, I explore the ways in which fields can be nested inside other fields. This is a powerful technique, but the markup requires a bit of explanation. Before watching this video, watch the first video of this deep-dive into Open XML WordprocessingML fields and hyperlinks.
Fields are one of the most powerful components of WordprocessingML markup. You will see field markup in hyper-links, the TOC, dates, page references, calculated values, and much more. I’ve been asked a few questions lately about fields in WordprocessingML markup. Fields are perhaps one of the least understood aspects of WordprocessingML markup, but they are really not very hard. I’ve embarked on a four part series to explain field markup, show some example code that makes it easier to work with fields, and then show some code that reliably retrieves all hyper-links in an Open XML WordprocessingML markup. The following video is the first of this four part series:
Sometimes when researching Open XML WordprocessingML markup, extraneous markup gets in the way of your research. The extraneous markup makes it harder to see and understand the markup issues at hand. The MarkupSimplifier class (which is part of the PowerTools for Open XML project) can help a lot, but as downloaded from CodePlex, it is only a class. You need to write code to use the class, and if you want to use the markup simplifier as part of your research process, it is inconvenient. I’ve written a small WinForm application that uses the MarkupSimplifier class, and makes the use of the simplifier class much more seamless in your research.
You can download the Markup Simplifier Application at OpenXMLDeveloper.org. The code is attached to the blog post.
I’ve recorded a six minute video that shows the Markup Simplifier application in action:
I’ve posted a short (3 minute) screen-cast that shows how easy it is to change the schema for my simple document generation system that uses XPath expressions in Open XML WordprocessingML content controls. It was super-easy to do – I didn’t rehearse – just sat down and recorded the screen-cast in a single take.
This post is the 16th in a series of blog posts on generating Open XML documents. Here is the complete list: Generating Open XML WordprocessingML Documents Blog Post Series