I have the unenviable task of writing a template system that sits on top of word 2007/10/13 which allows people to inject simple logic into the document from a back end data store (TBD but this is likely an exported XML document of some form) in the following forms:
- Direct binding to a data element (for example a paragraph/heading/section title)
- Repeating a data element a number of times (for example a table body or list)
- Providing in-line logic (for example an if-block which checks a business rule result value).
Rather than providing a program to do this on a case by case basis, we want to put this in the hands of the client which means they need to use the authoring tools provided by word. They can use an add-in that we're writing to markup a document, then upload this document as a template to our solution with the above directives in and execute them from there.
I've looked at the following ideas all of which have big holes in them unfortunately.
- XML schema. This is gone in Word 2007+ unfortunately though.
- Adding an XML namespace to the content.xml file and writing the directives in using attributes in that namespace (easy to post-process then!). Can't work out how to edit these or display them on the document via VSTO unfortunately.
- Adding content inline which contains template instructions (don't like this as it breaks the semantic separation between template and document content).
- Using content controls (which is fine but only 2013+ have repeat capability without ugly hacks)
- Others?
Does anyone have any ideas on the best approach to resolve this problem or workaround for the above issues?
I'm using VSTO + VS2012 as the toolchain and need to target 2007, 2010 and 2013 versions of Word.