Ant4docbook preprocess docbook files as freemarker templates , to add variables and conditions if needed.
DocBook file with freemarker instructions :
<article xml:lang="en"><title>$ {custom_title}</title><section id="section1"><title>Section level 1</title><para>write your documentation with some conditions[# if (output_format_is_pdf)??]<xref linkend="appendix-xxx" />[# else]<ulink url="appendix-xxx.html">appendix-xxx</ulink>[/ #if]</para></section></article>
Ant script with freemarker parameters :
<project name="ant-project" default="docbbook-preprocessing"><target name="docbbook-preprocessing"><dbk file="docbook.xml" tofile="file.html" preprocessor="true"><parameter name="custom_title" value="My Custom Title" /></dbk><dbk file="docbook.xml" tofile="file.pdf" preprocessor="true"><parameter name="custom_title" value="My Custom Title" /><parameter name="output_format_is_pdf" value="true" /></dbk></target>__</project>