13.1. About macro commands

In the excerpts from rng_section_config/common.incl below, sect.insertBreak is a macro-command. A macro-command in XMLmind XML Editor - Commands is a command specified in XML as combination of other commands (of any kind: native command, macro-command or process command).

Let's examine sect.insertBreak:

<command name="sect.insertBreak">
  <macro undoable="true">
      <command name="insert" 
        parameter="into {http://www.xmlmind.com/ns/sect}break" />
      <command name="insertNode" parameter="textAfter" />2
      <command name="cancelSelection" />3


The above macro uses the simplest and most common form of combination of other commands: the sequence. It invokes in turn the following native commands: insert in XMLmind XML Editor - Commands, insertNode in XMLmind XML Editor - Commands and cancelSelection in XMLmind XML Editor - Commands.


The newly inserted break element is automatically selected at the end of the execution of command insert. If there is already a text node after the selected break element, then command insertNode silently fails and the sequence of commands is stopped at this point. This kind of failure is harmless and we can even say that, as the developers of the above macro, we count on this behavior.


The above macro has two “nice touches”:

  1. Command cancelSelection is invoked to get rid of the red box around the newly inserted break element. Not strictly needed but nice to have.

  2. The macro has attribute undoable="true". Without this attribute, after sect.insertBreak has been executed in full, the user would have to invoke EditUndo (Ctrl+Z) twice: one time to remove the text node and a second time to remove the break element.