Batch search & replace

Post here questions and problems related to editing and publishing DITA content.
davdup
Posts: 22
Joined: Wed May 29, 2019 5:43 pm

Batch search & replace

Post by davdup »

Hi!
Is there a way to make batch search and replace actions, based on a txt or other input file, on a complete DITA map hierarchy? I already found the powerful search/replace tool over a DITA hierarchy, but it can only do one search at a time, and I would have hundreds to do in my conversion process...
Perhaps there is another way using refactoring or XSLT methods...
Basically I would like to convert

Code: Select all

<term id="PLEM">PLEM</term>
<term id="FLET">FLET</term>
<term id="PLET">PLET</term>
...
into

Code: Select all

<abbreviated-form  keyref="PLEM"/>
<abbreviated-form  keyref="FLET"/>
<abbreviated-form  keyref="PLET"/>
...
for hundreds of terms, over all my DITA map hierarchy.
Thanks for the help!

David
Radu
Posts: 9058
Joined: Fri Jul 09, 2004 5:18 pm

Re: Batch search & replace

Post by Radu »

Hi David,

Oxygen has support for XML refactoring based on applying a custom XQuery update or XSLT script:

https://www.oxygenxml.com/doc/versions/ ... tools.html

I created a sample XSLT refactor script based on what you described:

https://github.com/oxygenxml/dita-refac ... ated-forms

Basically if you have somewhere on your disk a folder containing the custom operation XML and XSLT documents, then in the Oxygen Preferences->"XML / XML Refactoring" page you point to that folder, then from the main "Tools" menu you can access the "XML Refactoring" action and it should contain a "Convert terms to abbreviated forms" action which can be applied on multiple files.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
davdup
Posts: 22
Joined: Wed May 29, 2019 5:43 pm

Re: Batch search & replace

Post by davdup »

Fantastic!
I should really go further into XSLT and try to do it myself! I cloned your example repository, and will probably find some more very useful stuff in there! :)
Thanks you made my day.

David
Post Reply