Page 1 of 1

Framework: ChangeAttributeOperation

Posted: Mon Jun 27, 2022 10:10 pm
by pieterjan_vdw
Hi,
I try to use the ChangeAttributeOperation.
It works to add an attribute to the selected element when the given attribute is empty.
However, when there is already an attribute value in my selected element, it simply overrides the existing attribute value.
I would like to add it as a second attribute value.
This is my current action:
changeattributeoperation.png
changeattributeoperation.png (27.37 KiB) Viewed 1044 times
Simple example
Before:
<p nr_jqs="first">this is a paragraph</p>

After clicking the change operation I would like to get:
<p nr_jqs="first 2_jq">this is a paragraph</p>

How can I do this? Thanks a lot in advance.

Kind regards,
Pieterjan

Re: Framework: ChangeAttributeOperation

Posted: Tue Jun 28, 2022 8:11 am
by Radu
Hi Pieterjan,

The default ChangeAttributeOperation just sets the new value instead of the old one, there is no setting to instruct it to preserve the old value.
Maybe you can use a JSOperation instead and write a small script which uses our APIs to check what the old value of the element is, take the old value, combine it with the new value and set it back:
https://www.oxygenxml.com/doc/versions/ ... soperation

There are some sample JSOperations here:
https://github.com/oxygenxml/javascript ... operations

Regards,
Radu

Re: Framework: ChangeAttributeOperation

Posted: Fri Aug 26, 2022 4:06 pm
by pieterjan_vdw
Hi Radu,

In this case this is a framework within a system using the webauthor. If I understand the documentation correctly, this is not possible with a JSOperation.

Do you have another suggestion?

Kind regards,
Pieterjan

Re: Framework: ChangeAttributeOperation

Posted: Mon Aug 29, 2022 12:28 pm
by mihaela
Hello,

The JSOperation cannot be invoked in Oxygen XML Web Author using the JavaScript API, but you can use it as an operation for an Author Action (and it will work als in Web Author).
So, you can use the JSOperation in the document type settings Action dialog.

We will update the documentation to be more clear.

Best Regards,
Mihaela