So while we crack on with producing our DITA based system and user documentation we hit across a stumbling block, due to SVG images not displaying properly in different outputs, we needed to be able to use different image attributes for different transtypes. DITA doesn’t seem to give you this as a default, so its time to use ditaval files to allow for conditional processing. This became a black art the more we did into it, so here is how I have managed to demystify this voodoo. I am only currently interested in two outputs so I created two ditaval files, pdf.ditaval and html.ditaval.
pdf.ditaval
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="otherprops" val="html" action="exclude" />
<prop att="otherprops" val="pdf" action="include" />
</val>
html.ditaval
<?xml version="1.0" encoding="UTF-8"?>
<val>
<prop att="otherprops" val="html" action="include" />
<prop att="otherprops" val="pdf" action="exclude" />
</val>
For each ant target to deal with the transtype, you add a new property of args.filter like the following
<target name="docfacto.pdf" description="build to book for Docfacto">
<ant antfile="${dita.dir}/build.xml">
<property name="output.dir" location="${release.dir}/pdf"/>
<property name="args.logdir" location="${logs.dir}/pdf" />
<property name="transtype" value="pdf"/>
<property name="args.filter" value="docfacto/pdf.ditaval" />
</ant>
</target>
So when it comes to image definition, the following can be used.
<fig>
<title>Description of the different elements in JavaDoc</title>
<image href="JavaDoc.svg" width="450" otherprops="pdf" placement="break" />
<image href="JavaDoc.svg" otherprops="html"/>
</fig>
The post Conditional image processing with DITA appeared first on Heap Dump.