Page 1 of 1

Applying a transformation scenario to several files at once

Posted: Wed Feb 18, 2015 4:28 pm
by dagoss
I have a DITA-OT transformation scenario that using the ${cf} for its input. This is perfectly fine 95% of the time

Sometimes a significant change is made to the OT plugin that necessitates rebuilding all of the ditamaps in a specific directory. Instead of opening each map individually and building it, is there a way to configure a transformation to do this?

Re: Applying a transformation scenario to several files at o

Posted: Wed Feb 18, 2015 5:14 pm
by adrian
Hi,

A transformation scenario can only transform one file at a time, but you can make use of batch transformations from the Project view (Window > Show View > Project) which allow you to apply the same scenario (or even individual associated scenarios) for each file.
Steps:
1. (optional, but recommended) Create a logical folder in your project (right click on project root > New > Logical Folder) and link in that folder all the ditamaps that you rebuild frequently. You can skip this step and work directly on the folder of the ditamap files if you have a dedicated folder just for them(and there are no sub-folders with files of other types). If you have additional files other than the ditamaps in their folder or its sub-folders, the transformation will also be applied to those, and you don't want that. The alternative is to manually select the individual .ditamap files every time you want to apply the transformation, which can be tedious.

2. In the Project view right click on the folder (logical folder, if created at step 1) where the .ditamaps are and from the contextual menu pick Transform > 'Transform with...' (for just one transformation), or better yet, Transform > 'Configure Transformation Scenario(s)' (to associate them) and pick your scenario from the list.
The scenarios used this way must be configured with ${cf} for their input. Each file becomes the current file (${cf}) when its turn arrives to be transformed.
3. After associating them, the second time you want to run the transformations you will be able to use directly Transform > 'Apply Transformation Scenario(s)' and the previously picked scenario(s) will be used. You can also associate individual scenarios for each of the ditamaps and then just run all of them by using 'Apply Transformation Scenario(s)' on the parent folder (or the selected ditamaps).

Regards,
Adrian

Re: Applying a transformation scenario to several files at o

Posted: Wed Feb 18, 2015 5:31 pm
by dagoss
Wow--That's great and exactly what I needed! In fact, the logical folder is even better than what I was trying to do since you can pick and choose which ones you want.

It's amazing how often I think something will be complicated, and it turns out Oxygen can do it in 30 seconds.

Re: Applying a transformation scenario to several files at o

Posted: Wed Feb 25, 2015 12:31 pm
by queshaw
I have read descriptions of the input part. What happens to the output of the current file? How do I specify where it goes? Can I replace the input files with the result of their transformation? If so, is there a way to create backup files, aside from from within the transformation script?

Re: Applying a transformation scenario to several files at o

Posted: Wed Feb 25, 2015 3:46 pm
by queshaw
Specifying the input file as the output file seems to replace the file. I gather you also have to select transformation follows selection.

Is there a way to filter which files are transformed? For example, not graphics?

Re: Applying a transformation scenario to several files at o

Posted: Wed Feb 25, 2015 5:01 pm
by adrian
Hello,

I would not recommend replacing the input files with the result of their transformation since there is no backup. If you make a mistake and the result of the transformation is invalid, you also lose the input files and you can't undo or recover them since they are modified directly in the file system.
Just use a different folder for the output files. e.g. ${cfd}/out/${cfn}.xml

"Association follows selection" is a GUI option, it doesn't change the way transformations work, just the way the GUI works. This option hides the check-boxes and instead relies on the selection from the list if scenarios. I would recommend to leave it off and make use of the check-boxes which are more resilient to accidental changes of associations.

If you apply a scenario on a folder, you can't filter from the scenario which files are transformed. Either create a logical folder and link there only the files you need to transform, or set a file filter at project level (hides the files from the project and also from transformations), menu > Project > Filters, 'Matching files will be hidden:' *.png

Regards,
Adrian