I am in the process of moving a lot of imperative utilities into apache-ant builds, and I am having a bit of difficulty coming up with a strategy for a specific use case.
Let's say I have a document defined like so:
document.xml
<Document>
<Page source="page1.xml" />
<Page source="page2.xml" />
</Document>
page1.xml
<Page title="Page 1">
</Page>
page2.xml
<Page title="Page 2">
</Page>
I would like to create an ant task that takes these documents and transforms it into a single document like so:
<Document>
<Page title="Page 1">
</Page>
<Page title="Page 2">
</Page>
</Document>
I have decided to go with fmpp/FreeMaker for this task (although it's not a requirement, it seems like it would suit my needs well).
Is there a way to define this transformation in a declarative apache-ant task?
Note: I have so far been able to run a basic fmpp ant that renders a signle template file against a data model. The scope of my question is specifically related to the construction of a document from multiple separate sources, and what that may look like as an an task.
Cheers and thanks for your time!
If
document.xmlhas to be XML (as oppose to a template that#include-s the others)... then it's not a task that fits FMPP's approach very much, but anyway, I guess you should use FMPP'srenderXmlprocessing mode (see http://fmpp.sourceforge.net/settings.html#processingMode) to transform that XML. In the renderer FreeMarker template, when you reach thePageelement, you could call#includeto insert the referred XML as is. (Of course, a lot depends on what else you will have to do with these files.)