Framework: ChangeAttributeOperation

Post here questions and problems related to oXygen frameworks/document types.
pieterjan_vdw
Posts: 41
Joined: Wed Jun 20, 2018 11:30 am

Framework: ChangeAttributeOperation

Post 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 1018 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
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Framework: ChangeAttributeOperation

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
pieterjan_vdw
Posts: 41
Joined: Wed Jun 20, 2018 11:30 am

Re: Framework: ChangeAttributeOperation

Post 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
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Framework: ChangeAttributeOperation

Post 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
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply