programmatically add wrapping tags

Questions about XML that are not covered by the other forums should go here.
amjc
Posts: 3
Joined: Fri Mar 31, 2023 3:18 pm

programmatically add wrapping tags

Post by amjc »

Hi, I want to replace this

Code: Select all

<entry namest="col1" nameend="col2"><para>Foo
with this

Code: Select all

<entry namest="col1" nameend="col2"><para><emphasis role="bold">Foo</emphasis>
I've done this kind of thing with Python xml.etree.ElementTree, but is there a way to do it in Oxygen?
Maybe I can select Foo with this

Code: Select all

//entry[@namest='col1' and @nameend="col2"]/para/text()
is there a way to wrap it with another tag?
Thanks for reading!
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: programmatically add wrapping tags

Post by Radu »

Hi,
Are you working with DocBook? Is it DocBook 4 or 5?
In the Oxygen main menu "Tools->XML Refactoring" dialog there is a "Wrap element content" action. You could probably use "*:entry[@namest='col1' and @nameend="col2"]/*:para" as the target element and wrap its contents with <emphasis>. Then we have another "Add/Change Attribute" refactoring action which you could use to set the role="bold" on the <emphasis>.
Or you can create your own XML refactoring operations based on XSLT:
https://www.oxygenxml.com/doc/versions/ ... tools.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply