Page 1 of 1

Multi-operation in authorAction

Posted: Tue Aug 20, 2024 4:54 pm
by leensmits
Hi,
What I want to achieve in the Ixiasoft Web Author is:
1. Check if an element is selected.
2. The element must be "cmd"
3. If so, add an outputclass attribute with value "ABC"
4. Next, at the end of the "cmd" text remove the period (if any) and add text " or"
5. Add a new "info" element after the selected element
6. Add some text to this new "info" element
I am experimenting with these steps in our framework.
- The check on the cmd element works.
- Adding an outputclass works (no.3) OR
- Adding the <info> element works. (no.6)
My problem is, why doesn't it do both?
If I switch the order, then the first operation is handled fine.

Code: Select all

<a:authorAction xmlns:a="http://www.oxygenxml.com/ns/author/external-action"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.oxygenxml.com/ns/author/external-action http://www.oxygenxml.com/ns/author/external-action/authorAction.xsd"
  id="refactor.first.task.step">
  <a:name>Refactor first task step</a:name>
  <a:description>In the first task step, if you select the cmd element, do some fun stuff</a:description>
  <a:operations>
    <a:operation id="InsertFragmentOperation">
      <a:xpathCondition>self::cmd</a:xpathCondition>
      <a:arguments>
        <a:argument name="fragment"><info>Hi there.</info></a:argument>
        <a:argument name="insertLocation">..</a:argument>
        <a:argument name="insertPosition">After</a:argument>
      </a:arguments>
    </a:operation>
    <a:operation id="ChangeAttributeOperation">
      <a:xpathCondition>self::cmd</a:xpathCondition>
      <a:arguments>
        <a:argument name="name">outputclass</a:argument>
        <a:argument name="elementLocation">self::cmd</a:argument>
        <a:argument name="value">original_nav</a:argument>
      </a:arguments>
    </a:operation>
    
  </a:operations>
  <a:accessKey/>
  <a:accelerator>M1 M2 Y</a:accelerator>
  <a:enabledInReadOnlyContext>false</a:enabledInReadOnlyContext>
</a:authorAction>

Re: Multi-operation in authorAction

Posted: Thu Aug 22, 2024 12:16 pm
by Dorina
Hello,
An action contains a sequence of operations, each operation with an activation XPath. The first operation who's xpath returns true is the one that gets executed. To implement your use case you need to:
- create 2 actions, one to change the attribute and another to insert the info element
- create a thrird action that uses the ExecuteMultipleWebappCompatibleActionsOperation operation and executes both actions above. This third action is the one that you would put in the toolbar or bind it in the document. Here is how these actions would look:
action-1.xml:

Code: Select all

<a:authorAction xmlns:a="http://www.oxygenxml.com/ns/author/external-action"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.oxygenxml.com/ns/author/external-action http://www.oxygenxml.com/ns/author/external-action/authorAction.xsd"
  id="refactor.first.task.step.1">
  <a:name>Refactor first task step 1</a:name>
  <a:description>In the first task step, if you select the cmd element, do some fun stuff</a:description>
  <a:operations>
    
    <a:operation id="ChangeAttributeOperation">
      <a:xpathCondition>self::cmd</a:xpathCondition>
      <a:arguments>
        <a:argument name="name">outputclass</a:argument>
        <a:argument name="elementLocation">self::cmd</a:argument>
        <a:argument name="value">original_nav</a:argument>
      </a:arguments>
    </a:operation>
    
  </a:operations>
  <a:accessKey/>
  <a:enabledInReadOnlyContext>false</a:enabledInReadOnlyContext>
</a:authorAction>
action-2.xml

Code: Select all

<a:authorAction xmlns:a="http://www.oxygenxml.com/ns/author/external-action"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.oxygenxml.com/ns/author/external-action http://www.oxygenxml.com/ns/author/external-action/authorAction.xsd"
  id="refactor.first.task.step.2">
  <a:name>Refactor first task step 2</a:name>
  <a:description>In the first task step, if you select the cmd element, do some fun stuff</a:description>
  <a:operations>
    <a:operation id="InsertFragmentOperation">
      <a:xpathCondition>self::cmd</a:xpathCondition>
      <a:arguments>
        <a:argument name="fragment"><info>Hi there.</info></a:argument>
        <a:argument name="insertLocation">..</a:argument>
        <a:argument name="insertPosition">After</a:argument>
      </a:arguments>
    </a:operation>
    
    
  </a:operations>
  <a:accessKey/>
  <a:enabledInReadOnlyContext>false</a:enabledInReadOnlyContext>
</a:authorAction>
main-action.xml

Code: Select all

<a:authorAction xmlns:a="http://www.oxygenxml.com/ns/author/external-action"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.oxygenxml.com/ns/author/external-action http://www.oxygenxml.com/ns/author/external-action/authorAction.xsd"
  id="refactor.first.task.step">
  <a:name>Refactor first task step</a:name>
  <a:description>In the first task step, if you select the cmd element, do some fun stuff</a:description>
  <a:operations>
    <a:operation id="ExecuteMultipleWebappCompatibleActionsOperation">
      <a:xpathCondition>self::cmd</a:xpathCondition>
      <a:arguments>
        <a:argument name="actionIDs">refactor.first.task.step.1, refactor.first.task.step.2</a:argument>
      </a:arguments>
    </a:operation>
   
  </a:operations>
  <a:accessKey/>
  <a:accelerator>M1 M2 Y</a:accelerator>
  <a:enabledInReadOnlyContext>false</a:enabledInReadOnlyContext>
</a:authorAction>
Regards,
Dorina

Re: Multi-operation in authorAction

Posted: Fri Aug 23, 2024 10:50 am
by leensmits
Thank you very much Dorina!

Re: Multi-operation in authorAction

Posted: Fri Aug 23, 2024 3:01 pm
by leensmits
Are there somehow more options to debug? Nothing happens if I press the shortcut...
- Could I test this framework (even though it is meant for the web) a little bit in Oxygen XML editor?
- When I deploy the latest framework in our dev environment, restart Tomcat, is there a log file to see why things do not work?
We run Oxygen XML web author 26.1 inside a web CMS.

Are there more of these framework examples?
Is there more documentation than https://www.oxygenxml.com/doc/versions/ ... soperation

Re: Multi-operation in authorAction

Posted: Mon Aug 26, 2024 4:21 pm
by cosminef
Hello,

After defining the action in the main-action.xml example, did you also add it to the UI, on the toolbar for example? We tested it, and the shortcut works in Web Author after adding the action to the UI, following the instructions here [1].
- Could I test this framework (even though it is meant for the web) a little bit in Oxygen XML editor?
Yes, you can also test it in Oxygen Editor. You need to place the framework folder for Web Author into the frameworks folder in the Oxygen Editor installation directory, for example: \Programs\Oxygen XML Editor 26\frameworks\
- When I deploy the latest framework in our dev environment, restart Tomcat, is there a log file to see why things do not work?
Yes, you can find the logs in: \oxygen-xml-web-author\tomcat\logs\oxygen.log

[1] https://www.oxygenxml.com/doc/versions/ ... e%20action.

Best,
Cosmin

Re: Multi-operation in authorAction

Posted: Tue Aug 27, 2024 1:31 pm
by leensmits
Thanks for your suggestions.
- UI, instead I used (only) a shortcut. Now I reversed that and only have a button. This however was not the fix.
- The oxygen.log was already inspected by me. I switched debug before, but it was not containing any helpful information. However, the Ixiasoft suggested https://www.ixiasoft.com/documentation/ ... 28220.html and that showed much more information. That mentioned the framework folder followed by (1).
Previously, the safest method to upload your latest version of your framework in the Oxygen admin console:
- Log in, and go to frameworks
- Delete the framework
- Upload the new one
- Restart.
Now, it seems not to prevent the frameworkname(1) thing.
So instead I now use:
- Log in, and go to frameworks
- Delete the framework
- Restart
- Log in, and go to frameworks
- Upload the new one
- Restart.

Finally it starting to work! thanks all of you!