Action for changing multiple elements at once

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Frank Ralf
Posts: 482
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Action for changing multiple elements at once

Post by Frank Ralf »

Hi,

I'm working on an action to remove all "status" attributes from a topic using the ChangeAttributeOperation (see also "How to toggle attribute values?".) However, I haven't figured out yet how to make the action work for multiple elements at the same time.

Is this a matter of the correct XPath expression or do I have to use some kind of loop construction? (If yes, how?)

TIA
Frank
Frank Ralf
parson AG
www.parson-europe.com
Frank Ralf
Posts: 482
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: Action for changing multiple elements at once

Post by Frank Ralf »

I've already found "Editing multiple AuthorNodes at once" which suggests that this might have to be solved on the underlying Java level.

Frank
Frank Ralf
parson AG
www.parson-europe.com
alex_jitianu
Posts: 1016
Joined: Wed Nov 16, 2005 11:11 am

Re: Action for changing multiple elements at once

Post by alex_jitianu »

Hello Frank,

ChangeAttributeOperation has an argument named elementLocation. Its value is an XPath expression that identifies the element to process. Unfortunately for you use case, ChangeAttributeOperation processes only one element (so even if you use an XPath expression that identifies multiple elements, only the first one is removed).

Using our JAVA based API you can create a custom change attribute operation. ChangeAttributeOperation can consist in a very good starting point. It already executes the XPath and identifies the nodes. All you have to do is iterate over all of them instead of just processing the first one. We have a tutorial on Author Framework Development. There is also a topic on How to Add a Custom Operation (please take notice that this topic has links to the v16.0 SDK which uses Maven). Once you create the start-up project, inside folder samples/Oxygen Default Frameworks you will find the source code for ChangeAttributeOperation.

Best regards,
Alex
Frank Ralf
Posts: 482
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: Action for changing multiple elements at once

Post by Frank Ralf »

Hi Alex,

Many thanks for the explanation and for pointing me in the right direction!

Kind regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
Post Reply