Chose to have a document with multiple pages or a single doc with a table based on 1 datamapper

Suppose I have the following XML:

order /order
order /order

(not sure how I can use a xml structure in the editor so I had to display it like above)

As long as I make sure I set the input data in my datamapper to start at /xml or Use root element I can create documents with a single page (or multiple pages if there is an overflow) with a table that holds a row for each order.
And at the same time I have access to the other sections like document and userinfo.

But what if I wanted to have a single page (or multiple pages if there is an overflow) per order and then a table with just a single row as I am looping over the orders for each page?

Note that both type of documents are in 1 single datamapper.

If I set the Input Data in the datamapper to /xml/order I can accomplish what I want but then I:

  1. Lose the ability to access the document section and the userinfo section as they fall outside the scope
  2. Cannot use the other documents anymore that require the start to be at /xml

Is it possible to do this in a single datamapper?
Right now I did this by using a transform to modify the XML in the process before it goes into the datamapper. This works but I find this not the best solution because we’ll have to maintain multiple xml formats (1 input format and 1 after the transform).

The only other way is that I create 2 datamappers; one for each specific case.
But that would mean that I will have to maintain 2 datamappers.

I was wondering what the most elegant solution is for this.

If you create two distinct DataMapper configs, you will also need to create two distinct Templates.

If it were up to me, that’s the method I’d pick because I’d rather have my resources do one specific thing and do it well, rather than cramming all the logic into a single resource and risking both of my documents failing when I make a single change to the resources a few months down the road.

The XSLT transform is a viable solution as well, but you will still have to have two code-paths in your DataMapper Config/Templates which I think is messy.

Now I don’t know how complex your DataMapper configs or your Templates are, but you have to ask yourself this: what if someone else has to maintain them while you’re on vacation? Would they be able to understand the intricacies of generating two different documents from a single set of resources?

Thanks. That makes a lot of sense. I will not create distinct datamappers. I realised that within the /xml section I will need an additional section where for 1 datamapper it is just 1 section and for another datamapper I create a section per order instead. This way I can always use the /xml/section as the base.
The design is really complex and we don’t have a design per document. The reason for this is that with the classic version we had 1 per document but then we had to make a global change for all documents (50+) which meant a lot of work and since I am the only person within our organization that knows how the system works it took me a long time.
So for Connect we decided to create sections in the template that could be reused for similar looking documents which does work well and speeds up development a lot.
Unfortunately, what you mentioned, is that one wrong update somewhere for a new document could break existing documents.
And then there is the load time. I would assume that one big template file would take longer to load than a very small conditional template.