In "Add/Change attribute" refactoring, support value XPath expressions

Are you missing a feature? Request its implementation here.
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

In "Add/Change attribute" refactoring, support value XPath expressions

Post by chrispitude »

Let's say I have a table like this:

image.png
image.png (37.82 KiB) Viewed 456 times

I would like each row to have an @id value equivalent to its first-column value, so it can be specifically referenced.

It would be great if the Add/Change attribute refactoring operation had a "Evaluate value as XPath" that would evaluate the given value using the XPath 3.0 xsl:evaluate() function. Then, I could run the refactoring operation to set the @id attribute, with the value specified as

Code: Select all

string(entry[1])
Special characters could be handled, if needed:

Code: Select all

string(entry[1]) => replace("[^-.A-Za-z0-9_:]+", "_")
In our actual DITA content, we have multiple such .dita topic files of error message tables, each with many (potentially hundreds) of rows. If the refactoring operation had such a feature, it would be trivial to process the entire set in one refactoring operation on the selected resources.

A sample DITA topic file is attached:

error_messages.zip
(800 Bytes) Downloaded 90 times
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: In "Add/Change attribute" refactoring, support value XPath expressions

Post by chrispitude »

Here is the refactoring operation I used for now:

set-evaluated-attribute.zip
(1.47 KiB) Downloaded 115 times
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: In "Add/Change attribute" refactoring, support value XPath expressions

Post by Radu »

Hi Chris,
Makes sense, thanks for sharing your samples and the custom XML refactoring action you created.
I had a similar need when replying to an older forum thread:
post66324.html#p66324
So there is already this registered issue, I added your details to it:
EXM-50799 Add/change attribute value could be an xpath expression

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply