Example: Configure Content Completion to Insert a Certain XML Structure
It is possible to configure the Content Completion Assistant to insert a certain
XML structure instead of an element. For example, suppose that whenever a DITA
<change-completed>
element is inserted with the Content
Completion Assistant, you want the current date to be inserted as the text content of
the <change-completed>
element.
This can be achieved by defining a custom Author mode action in
your custom framework:
- In Oxygen XML Editor/Author, go to and edit the document type configuration for your framework.
- Go to the Author tab, then the Actions subtab, and click the New button.
- Define the custom action and include the following details:
- For Operation, choose
ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation
. For information about theInsertFragmentOperation
, see https://www.oxygenxml.com/doc/ug-editor/topics/dg-author-op-InsertFragmentOperation-arguments.html. - In the Arguments table, double-click
fragment and for its value, enter
<change-completed>${date('YYYY-MM-DD')}</change-completed>
.Note: When the schemaAware argument is set totrue
and the user tries to execute the action in a position where thechange-completed
element is not valid, Oxygen XML Web Author will try to insert the fragment in a nearby position or insert additional ancestor elements to make the document valid.
- For Operation, choose
- Go to the Content Completion subtab
and add the action to the content completion menu:
- In the Available actions section, select your custom action and use the Add as sibling button to add it as a sibling of the currently selected action in the Current actions section, or use the Add as child button to add it as a child of the currently selected action in the Current actions section.
- Use the Replacement for section to specify an element to be replaced by the configured action.
Note: If the action is implemented in JavaScript, you will need to also create a dummy action with the same ID in the framework and insert it in the content completion menu. The dummy action should have an operation but it is not important which one. - Save the changes to your custom framework.
- Create an archive that only contains your custom framework folder and upload your framework to Web Author.
Tip: Another possibility to achieve this specific example is to use a custom form control when the
<change-completed>
element is empty.