Applying a transformation scenario to several files at once

Having trouble installing Oxygen? Got a bug to report? Post it all here.
dagoss
Posts: 24
Joined: Fri Apr 05, 2013 11:01 pm

Applying a transformation scenario to several files at once

Post 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?
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Applying a transformation scenario to several files at o

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dagoss
Posts: 24
Joined: Fri Apr 05, 2013 11:01 pm

Re: Applying a transformation scenario to several files at o

Post 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.
queshaw
Posts: 41
Joined: Wed Aug 08, 2007 5:56 am

Re: Applying a transformation scenario to several files at o

Post 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?
queshaw
Posts: 41
Joined: Wed Aug 08, 2007 5:56 am

Re: Applying a transformation scenario to several files at o

Post 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?
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Applying a transformation scenario to several files at o

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply