How to modify attributes with editor variables?

Oxygen general issues.
avanlooveren
Posts: 26
Joined: Wed Jun 26, 2013 1:08 am

How to modify attributes with editor variables?

Post by avanlooveren »

I need to replace all attributes with a particular name in a single document to have a value of UUID (the editor variable "{uuid}"). I don't think Find/Replace, even with regex, is capable of this.

I'm trying to configure a custom Author action with ChangeAttributeOperation, but I wonder if I'm going about this all wrong. I set the elementLocation to "//*", but I cannot seem to get more than one attribute value to update.

Any help appreciated. Also, is it possible to enable this in Text mode? Thanks!
sorin_carbunaru
Posts: 398
Joined: Mon May 09, 2016 9:37 am

Re: How to modify attributes with editor variables?

Post by sorin_carbunaru »

Hello,

You could use a custom XML Refactoring operation (https://www.oxygenxml.com/doc/versions/ ... tions.html). I did just that to see if it works (and it does work), starting from the default Add/Change attribute operation, and instead of requesting an attribute value from the user, I generated one in the operation's XQuery script, using the generate-id() function.

You can find my try at http://www.oxygenxml.com/forum/files/cu ... ibutes.zip.

Best regards,
Sorin Carbunaru
oXygen XML
avanlooveren
Posts: 26
Joined: Wed Jun 26, 2013 1:08 am

Re: How to modify attributes with editor variables?

Post by avanlooveren »

Sorin,

First, a big THANK YOU. You and your team are always so thorough with your responses and this was no exception.

Priorities shifted, so a lot of time passed before I got to try out your solution, but it works. (Of course, it does, and of course your wonderful product was ready to address my need.)

My tweak, since I did want UUID and not the "element position" that generate-id() produces, was to supplement your provided XQuery with:

Code: Select all

declare namespace uuid = "java:java.util.UUID"
and then use

Code: Select all

uuid:randomUUID()
Thanks again,

-Andre
Post Reply