Page 1 of 1

Form control - how to replace text using Author Mode Operations?

Posted: Wed May 04, 2022 6:38 pm
by catominor
Hi,
I want to use the combobox that changes simultaneously two different values (I am using Oxygen 20.1):
1) A @key value of the <author> - this works perfectly with label and value
2) Name of the author within the element <author> - and I cannot achieve that.

What I tried was to add onChange parameter to the oxy_combobox, and then pair oxy_action with onChange with operation, 'InsertOrReplaceFragmentOperation'. However, this does not work:

Code: Select all

 onChange, oxy_action(
                name, 'Replace ',
                operation, 'InsertOrReplaceFragmentOperation',
                arg-fragment, 'Placeholder name',
                arg-insertLocation, './text()',
                arg-insertPosition, 'Replace'   )
            
            );
(My third future step is to replace "Placeholder name" with oxy_xpath that would find the name of the author in another .xml file using @key.)

I also tried other insertLocation xpaths but without success.

Any idea? :)
Thank you very much in advance!
Jan

Re: Form control - how to replace text using Author Mode Operations?

Posted: Thu May 05, 2022 12:10 pm
by alex_jitianu
Hello,
I tried this myself and what I observed was that a new "Placeholder name" part was inserted instead of replacing the entire content. Is this what happens in your case as well? It does this because the operation only replaces the selection and in this case you have no selection. In the later version of Oxygen we added another operation, ReplaceElementContentOperation, which behaves like you desire. For 20.1 you can use JSOperation or XQueryUpdateOperation:

Code: Select all

p {
    content: oxy_combobox( 
            edit, '@attribute',
            editable, false,
            values, 'value1, value2, value3',
            labels, 'Value no1, Value no2, Value no3',
             onChange, oxy_action(
                name, 'Replace ',
                operation, 'XQueryUpdateOperation',
                arg-script, 'replace value of node . with "Placeholder name"'
                )
)
}
Best regards,
Alex

Re: Form control - how to replace text using Author Mode Operations?

Posted: Tue May 10, 2022 10:51 am
by catominor
Dear Alex,
thank you very much :).
Now I will hopefully manage it!
Best regards,
Jan