119. XXE.save

Parameter syntax:

[ '[ifNeeded]' | [checkIsSaved] ]?

Saves document currently opened in XXE.

[ifNeeded]

With this option, this command does nothing at all but can be successfully executed if current document does not need to be saved.

Without this option, this command cannot be executed if current document does not need to be saved.

This option is useful in macro commands such as the one in the first example below.

[checkIsSaved]

With this option, the command does nothing at all. However it cannot be successfully executed unless the current document does not need to be saved.

This option is useful to write macro commands such as the one in the second example below.

Returns Command.EXECUTION_FAILED if document cannot be saved or if user has canceled the command. Otherwise, returns null.

Example 1:

  <command name="editXMLSource">
    <macro>
      <sequence>
        <command name="XXE.save" parameter="[ifNeeded]" />
        <command name="run" parameter='emacs "%D"' />
        <command name="XXE.open" parameter="[reopenIfNewer]" />
      </sequence>
    </macro>
  </command>
  1. Save the document being edited, if this is needed.

  2. Load it in external text editor GNU Emacs. Use this text editor to modify it or simply to view it.

  3. Reload the document in XXE, but only if it has been modified using Emacs.

Example 2: Do not attempt to convert the DITA document to XHTML if this document needs to be saved.

<command name="dita.convertToXHTML">
    <macro>
      <sequence>
        <command name="XXE.save" parameter="[checkIsSaved]" />
        <command name="selectConvertedFile" 
                 parameter="saveDirectoryURL" />
        <command name="dita.toXHTML" parameter='"%_"' />
      </sequence>
    </macro>
  </command>