"Find/Replace in Files" in Author Action?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Frank Ralf
Posts: 452
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

"Find/Replace in Files" in Author Action?

Post by Frank Ralf »

Hi,

I have a rather dangerous regular expression for Find/Replace in Files and would like to provide the function via an Author Action instead of letting the users enter the regex manually. Is there an Author Default Operation available for that?

TIA
Frank
Frank Ralf
parson AG
www.parson-europe.com
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: "Find/Replace in Files" in Author Action?

Post by Radu »

Hi Frank,

Sorry, we do not have such an operation.
Do you want to search for certain content or to replace content?
Also the Find Replace in Files is performed directly over the XML content, it can match tag names as well as text content. Does your regexp also match tag names?

The Author editing mode has an internal node structure so you cannot search in it using our API directly strings like

Code: Select all

<tag>text</tag>
. So probably this could be implemented by a custom Java operation but the operation would approach the problem in a slightly different way, navigate all nodes and possibly apply the regexp pattern on the text content which is between them.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Frank Ralf
Posts: 452
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: "Find/Replace in Files" in Author Action?

Post by Frank Ralf »

Thanks for the information, Radu. I will try the other options you mention.

Kind regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Frank Ralf
Posts: 452
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: "Find/Replace in Files" in Author Action?

Post by Frank Ralf »

Hi,

This request pops up again from time to time. So is this perhaps possible with more recent versions of oxygen?

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: "Find/Replace in Files" in Author Action?

Post by Radu »

Hi Frank,

I'm trying to better understand your needs. Let's say there would be a pre-defined Author operation, what parameters would it take, what would it do with them? Would it also change XML structure or only text content between tags?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Frank Ralf
Posts: 452
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: "Find/Replace in Files" in Author Action?

Post by Frank Ralf »

Hi Radu,

Thanks for your quick response. I need an action where the user can perform a complex find and replace operation with pre-configured regular expression find/replace patterns. The user should not be able to alter the find/replace patterns. Here's an example:

Find

Code: Select all

href="references.dita#[^"]+"\s*>\s*Ref\.\s+(\d+)\s*</xref>
Replace with

Code: Select all

keyref="references/ref\1" />
Hope this clarifies things.

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: "Find/Replace in Files" in Author Action?

Post by Radu »

Hi Frank,

I would suggest you create a custom XML refactoring operation based on XSLT:

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

Such refactoring operations can also be provided at framework level. For example the Dita framework configuration has a special folder with custom DITA refactor actions:

OXYGEN_INSTALL_DIR\frameworks\dita\refactoring

Once defined for a framework, when you open a DITA topic you can right click inside it and there is a special "Refactoring" submenu where you will find the new added action.

An example of a custom XSLT refactor operation which can be applied on a DITA Map:

http://blog.oxygenxml.com/2018/01/sorti ... okmap.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Frank Ralf
Posts: 452
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: "Find/Replace in Files" in Author Action?

Post by Frank Ralf »

Hi Radu,

Many thanks for the pointer.

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Post Reply