Global unwrapping

Questions about XML that are not covered by the other forums should go here.
david_himself
Posts: 40
Joined: Mon Oct 01, 2018 7:29 pm

Global unwrapping

Post by david_himself »

Hi

I want to remove the <seg> tags from every XML file in a project, but

(1) only in body, not teiHeader
(2) regardless of attributes and values
(3) leaving the enclosed material untouched
(4) not adding extra spaces

Were it not for condition (1), it would be easy with regex. Example. Change

my advice <seg type="bodySalute"><rs ref="psn:MH">my Friend</rs>,</seg> I give it you

to

my advice <rs ref="psn:MH">my Friend</rs>, I give it you

How? Thanks in advance.

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

Re: Global unwrapping

Post by Radu »

Hello David,

In the Oxygen main menu Tools->"XML Refactor" you will find an "Unwrap element" action, it can work over multiple files and you need to pass to it an XPath for the element to unwrap, for example maybe in your case "//*:body//*:seg".

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
david_himself
Posts: 40
Joined: Mon Oct 01, 2018 7:29 pm

Re: Global unwrapping

Post by david_himself »

Thanks, Radu. I had already experimentally tried Refactoring in the Document menu of a single file, but the operation was unavailable there. It looks as if it will be available in the right-click menu for the project or the file folder. I will cautiously have a go. Many thanks for prompt reply.

best
David
Post Reply