Multiple orders in the one XML file?

Sep 24, 2012 at 6:31 AM

Can one have several orders in the one XML data file?

I tried modifying the example orderData.xml and added a new root node of <orders> wrapping several <order>'s but that didn't work.  

I'm looking to use a document template to merge with XML data that contains many "rows" (e.g. order level nodes, or whatever the instance is) to produce a document for each "row" of the data.  (Or equally one document containing an instance of the filled in template for each row.)  Is this possible?  Am I missing the obvious?

Oct 3, 2012 at 4:22 PM


Sorry for my late reply. All orders in a single document is absolutely possible. Just put a foreach around all content you need to repeat. You may want to include a pagebreak to make sure every order starts on a blank page.


Oct 5, 2012 at 1:28 AM

Hello Robert,

Thank you very much for your reply to this and my other topic.

Your ForEach suggestion comes close but there is an issue.  With both your example template and the document I'm attempting to implement there is context information in the header.  Now I can't find a way to select the whole document (including headers and footers) in order to wrap it in the ForEach.

I tried having a higher level document with an IncludeTemplate so now I'm including the entire target template with its headers and footers.  However, when I try to wrap the IncludeTemplate in a ForEach I get the error here.  This error makes reference to altChunk as does your doco on IncludeTemplate.  Am I trying to do something unsupported?


Oct 7, 2012 at 6:22 PM

In ludeTemplate uses altchunks. Only Word itself understands them. Therefore it is smarter to use ImportTemplate.

If you need more control, why not split the xml and create single documents instead of one big document for each node?

You can only switch headers and footers on section breaks, and not dynamically add them. So you current direction probably does not work.

Mar 13, 2013 at 11:04 PM
Hello Again Robert,

With my client we have been through one year end producing documents with fleXdoc and because the volume is small at this time we were able to deal in single documents. However, the volume will increase and a multiple document output file will be required. Unfortunately from your advice so far I have not been able to skin the cat.

Let me pose the issue again. Your example orderTemplate.docx has the same characteristics as the document I want to use in that data in the header changes with each document incidence. Thus how must one change your example XML and order template to generate an output file containing orders for Robert te Kaat, Barry Brunning and as many others as the XML specifies?

If it's simple and you could post the solution that would be much appreciated (as previously). If it's difficult or impossible with the software as it stands then, should you be willing, we could negotiate an appropriate donation for an enhancement. You can contact me on if you choose to.

TIA Barry
Mar 19, 2013 at 4:30 PM
Hello Barry,

The document format itself (docx) is not very well suited for your problem. Headers and footers are separate 'mini documents'. The main document contains sections which refer to a header and footer part. Sections may span the whole document or just a few pages. Trying to create separate headers per order and sections that refer to them is not only complex (and not possible with fleXdoc), it also introduces the risk of creating a page for an order with a header for a different order, resulting in customers seeing other customers order Information.

A better and safer approach could be to not use headers (and make them as small as possible) and use a full height table, allowing you to position the information in the same location as the header would have been.
Mar 31, 2013 at 7:03 PM
Barry, please let me know if my suggestion actually worked for you. I tried it out myself and found that Word let's you specify exact sizes for table rows. That could work if they match the paper size that the document is targeting.

Apr 1, 2013 at 10:24 PM
Hello Robert,

Somehow missed your first response to my question earlier in March so apologies for a belated acknowledgement. Unfortunately what you suggest is really a non-starter as explained next.

The templates come to me ready for a regular Word Mail Merge. They are many pages long and quite complex in structure. I then go in and replace the Word Merge tags with XML elements to have a template that fleXdoc can use. I know that the client would not be happy to pay for my time to rework the documents further to adopt your table suggestion and would start to look for another solution even were I prepared to undertake what would be mind numbing detail work anyway. Nor do I have the time for that with other priorities.

There's a window of a couple of months before the pressure comes back on to this, so if you do have some inspiration for a fleXdoc enhancement that would safely solve the problem (and not mix headers from one order with details from another), then as I say it's possible to appropriately size a donation. Otherwise I'll just produce single documents and otherwise seek to automate their combination.

Best regards,
Jul 23, 2013 at 6:26 PM
Come check out the successor of fleXdoc: Docati!
It supports Word 2010 and 2013 as well and runs in the cloud.

I sure hope to welcome you as a Docati user as well! :-)