Script to process multiple Transformations

Post here questions and problems related to editing and publishing DITA content.
Bob.Conlin
Posts: 22
Joined: Sun Aug 14, 2011 5:21 am

Script to process multiple Transformations

Post by Bob.Conlin »

Hi,
I have a project that includes a dozen or more pdf targets from a single ditamap, a dozen transformations (each using a different ditaval), and a few dozen dita files. Conditional profiling takes care of which topics to include with which pdf targets. I currently run each transformation, change the pdf file name (save as), and then run the next transformation. Is there a way to automate this process? Maybe an Ant script that would run each transformation, change the output file name, and the the next, etc. Idealy I could start the script in oXygen and when it was finished have a complete set of new pdf files. Researching the internet it looks like this is possible but I've never found the detail I need to make this work.
TIA, Bob
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Script to process multiple Transformations

Post by Radu »

Hi Bob,

What you could try to do would be to define a different output directory for each of your transformation scenarios in order to avoid overwriting the PDF.

or:

I looked through the DITA OT ANT build files and there seems to be an undocumented ANT parameter called outputFile.
If you edit a transformation scenario and in the Parameters tab add a new parameter called outputFile with a value like:
${cfd}/out/test.pdf
you should obtain in the out directory a PDF called test.pdf. You should use an absolute path to specify the output PDF file, or Oxygen editor variables which resolve to an absolute path as in my example.

So each transformation scenario could use this parameter.
Then you could run each individual scenario one at a time.

But what we plan for Oxygen 14.0 (in a couple of months) is the ability to select multiple transformation scenario and then execute them sequentially. So this would finally solve your problem because in this way you could press one button and then have all the transformation scenarios executed sequentially on the input DITA Map.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Bob.Conlin
Posts: 22
Joined: Sun Aug 14, 2011 5:21 am

Re: Script to process multiple Transformations

Post by Bob.Conlin »

Hi Radu,
I tried the outputFile parameter and had some odd results. The transformation ran and created the correctly named pdf but then opened the pdf from the previous unmodified transformation (the file that had the unmodified file name). At first I thought the previous transformation was the one that had been performed but there the new file was in the folder. The modified output folder worked as well. When you make the changes for oXygen 14.0 for running multiple transforms be sure that the file that opens is the same as the file transformed using the outputFile parameter.

Thanks again, Bob
Bob.Conlin
Posts: 22
Joined: Sun Aug 14, 2011 5:21 am

Re: Script to process multiple Transformations

Post by Bob.Conlin »

Another interesting feature (?). Regardless of the value under the Output tab, Output folder with a value for outputFile the pdf lands in the parent folder (location of ditamap). I added "out/" to the beginning of each of the file names for outputFile and the files land in the out folder. For the changes your working on for 14.0 maybe some adjustments should be made.
HTH, Bob
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Script to process multiple Transformations

Post by Radu »

Hi Bob,

Related to this remark:
When you make the changes for oXygen 14.0 for running multiple transforms be sure that the file that opens is the same as the file transformed using the outputFile parameter.
Indeed when the transformation finishes Oxygen somehow needs to open the PDF file which was generated by the ANT publishing process, thing which is hard to do because the build files may be changed in any way by users or in this case a certain parameter may influence the PDF output file name.
In this case Oxygen opened the old PDF file which was still lying around in the output folder.
We'll see what we can do but it's probably good practice to clean all the output directory's content before the transformations start.

About this remark:
Regardless of the value under the Output tab, Output folder with a value for outputFile the pdf lands in the parent folder (location of ditamap).
You should set absolute file paths as values for the outputFile parameter, something like: C:\Users\radu_coravu\Desktop\test.pdf.

This parameter is an internal parameter so I do not think that the DITA OT intended it for this, I just thought it would be a good workaround for this particular problem.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Script to process multiple Transformations

Post by Radu »

Hi Bob,

I also discussed this with Jarno Elovirta and added an improvement request for this on the DITA OT features list:

https://sourceforge.net/tracker/?func=d ... _id=132728

Jarno's approach if you just want to change the file name (and not the path where the PDF will be placed) is to better set this parameter: outputFile.base.

So if you set outputFile.base to fileName you would obtain in the output folder fileName.pdf. The extension is appended to this parameter's value automatically by the build scripts:

Code: Select all

<condition property="outputFile" value="${dita.map.output.dir}/${outputFile.base}${xsl.formatter.ext}">
<not><isset property="outputFile"/></not>
</condition>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Bob.Conlin
Posts: 22
Joined: Sun Aug 14, 2011 5:21 am

Re: Script to process multiple Transformations

Post by Bob.Conlin »

Thanks Radu, outputFile.base works great. Delivers the correctly named file to the right place without any extra baggage.
Post Reply