This repository has been archived by the owner. It is now read-only.

Document Assembler: Ability to merge in whole documents or sub-templates #241

wants to merge 6 commits into
base: vNext


None yet
3 participants
Copy link

MalcolmJohnston commented Jul 31, 2018

As some interest was shown in this feature here is the pull request.

From issue 191;

Implementation is as follows;

  • Added two new elements; Document and DocumentTemplate
  • These two elements share common attributes Path and Data
  • The Path attribute can be either a file path or XPath that retrieves a file path from the input XML
  • The Data attribute is intended to hold a base64 encoded string containing the Word document contents
  • The DocumentTemplate element also has a Select attribute so that XML data can be passed to the template


<Repeat Select="//Invoice" />
<DocumentTemplate Path="SubTemplate.docx" Select="." />
<Document Path="Terms.docx" />
<EndRepeat />

With the above in place what I do is take a two pass approach.

Firstly I process the Document and DocumentTemplate elements converting all to a Document element which contains a Data attribute with the base64 encoded content of the Document or assembled DocumentTemplate.

Then I have introduced a second step and as such a dependency on DocumentBuilder in DocumentAssembler. I am not sure if this will be frowned upon or not :)

This second step is largely based on this post from Eric White;

Although in my practical experience (been using this code in production for months) the Word documents generated are valid I had issues with the Unit Tests. I think this is because we are using Office 365 and it looks like the validator only supports up-to 2013 at the minute? I could re-author my test files in 2013 but don't have access to a copy.

Any comments and feedback appreciated, this is my first pull request on an open-source project so be gentle :)


This comment has been minimized.

Copy link

msftclas commented Jul 31, 2018

CLA assistant check
All CLA requirements met.


This comment has been minimized.

Copy link

tomjebo commented Feb 2, 2019

Closing all PRs as this repo is being archived and will no longer be maintained by Microsoft. The project is licensed for continued use and development by forking to your own repo.

@tomjebo tomjebo closed this Feb 2, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.