Page 1 of 1

programmatically add wrapping tags

Posted: Tue Dec 19, 2023 1:11 am
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!

Re: programmatically add wrapping tags

Posted: Tue Dec 19, 2023 9:21 am
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