Automating common tasks

Oxygen general issues.
Grimbly1024
Posts: 2
Joined: Wed Nov 22, 2023 11:25 am

Automating common tasks

Post by Grimbly1024 »

Hello,

I'm sure this must be possible, but I'm struggling to find a solution and would appreciate help.

I often have to take poorly structured XML and convert it into something usable, but I seem to spend an awfully long time manually looking for empty tags and deleting them. I'm SURE there must be an easy way to automate this process rather than having to spend hours doing a find and replace for them.

I'm suprised that there isn't an option in Oxygen to record actions and automate them - as all I want to do is have some kind of script that does the following.

Find '<u> <u>' and replace with ''
(Empty U tag)
Find '<i> <i>' and replace with ''
(Empty I tag)
Find any gaps in the text that are more than 3 spaces
etc etc etc
Whilst it can be done manually I'm having to do this pretty much every day and it's taking up longer and longer.

I'd really appreciate if someone can help as it's driving me mad!

Thanks!
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Automating common tasks

Post by Radu »

Hi,
Is the XML that you need to modify and refine well-formed?
To fix indentation problems why not use our "Format and Indent" action located on the toolbar?
I do not understand this example you gave:
Find '<u> <u>' and replace with ''
(Empty U tag)
Do you mean you search for <u></u> and replace it with <u/>?
If so again our "Format and Indent" action located on the toolbar might help.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Grimbly1024
Posts: 2
Joined: Wed Nov 22, 2023 11:25 am

Re: Automating common tasks

Post by Grimbly1024 »

Thank you for your reply.

What I'm looking for is a way to automate the process of removing 'junk' tags that are left over from being cut and paste from various sources, so there are lots of 'empty' tags - ie
<i> </i>
<paragraph> </paragraph>
<b> </b>

These are just an example, but I regularly see empty tags of every type in my day to day activites.

Does Oxygen have a function to automatically remove all of these tags - as with each document I process I have to do exactly the same task every time which takes a considerable amount of time and can be quite annoying to do each time.

If there were a simple command or script that can be run to remove all of these 'empty' tags I would find it SO much easier.

Thank you.
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Automating common tasks

Post by Radu »

Hi,
I would probably use the Oxygen Tools->"XML Refactoring" dialog, choose the "Delete element" predefined operation and for the element xpath I would use:

Code: Select all

*[not(node())]
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply