Rename elements in a table column at once

Post here questions and problems related to editing and publishing DITA content.
max3036
Posts: 2
Joined: Thu Jan 11, 2024 10:24 pm

Rename elements in a table column at once

Post by max3036 »

Question: Is there a way to rename a recurring element in a table's column all at once without affecting the other columns that have that same element?
I am trying to rename all the <p> elements in my table's first column without changing the <p> elements in all the other columns.
So far I've tried refactoring and using grid mode, but nothing seems to work.
I know I can change each <p> element one at a time, but I need to update several tables, and a single click solution would be great to know, if there is one.
max3036
Posts: 2
Joined: Thu Jan 11, 2024 10:24 pm

Re: Rename elements in a table column at once

Post by max3036 »

I figured it out.
In Text mode, right click the element you would like to rename and select Copy XPath.
In Author mode, navigate to the Refactoring menu (this can be done in multiple ways).
In the Refactoring menu, select Rename element. A new menu displays.
In the text box titled Target elements (XPath), paste the copied XPath.
Edit the pasted XPath by removing the bracketed number next to row.
Example:
Paste: /reference/refbody[1]/section[1]/p[1]/table[1]/tgroup[1]/tbody[1]/row[2]/entry[1]/p[1]
Paste with edit: /reference/refbody[1]/section[1]/p[1]/table[1]/tgroup[1]/tbody[1]/row/entry[1]/p[1]
In the text box titled New local name, enter the new element you would like the current element to be renamed to.
Select Finish.

In addition to this, if you would like to insert an element into an column entries that have text but no other element, you can select Wrap element content in the Refactoring menu.
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Rename elements in a table column at once

Post by Radu »

Hi,
Thanks for sharing the solution, indeed XML Refactoring looks like the proper solution for this one.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply