Update August 26, 2015: I have enhanced this document generation system, and published it as part of Open-Xml-PowerTools, which you can find at https://github.com/OfficeDev/Open-Xml-PowerTools. Going forward, I will be enhancing and maintaining that document generation system. Please feel free to clone / fork that repo, report issues on GitHub, and interact with me there.
Today I’m posting the release of version 2 of my simple document generation system. In this example, you configure the document generation process by creating a template document that contains content controls. You then enter XPath expressions in those content controls. Those XPath expressions specify the data that the document generator pulls from the source data. The source data is an XML document that contains data for each and every document that you generate. The source XML document can also contain detail (children records) that populate tables in the generated document. I detailed how the template document works in the post Generating Open XML WordprocessingML Documents using XPath Expressions in Content Controls.
This post is the 14th in a series of blog posts on generating Open XML documents. Here is the complete list: Generating Open XML WordprocessingML Documents Blog Post Series
In my opinion, the use of XPath expressions in content controls is a superior approach to the one of entering C# code in content controls. The code is cleaner and smaller (this first example is less than 240 lines of code).
I’ve recorded a short (2 minute) screen-cast that demonstrates this example in action.
So please download the example, try it out, and give me feedback.