16.1. About process commands

Like macro-commands, a process command in XMLmind XML Editor - Commands is a command specified in XML. But a macro-command acts on elements, attributes and on the text or node selection, while a process command acts on files.

Moreover the current working directory (that is, directory ".") of a process command is always a temporary directory especially created for the execution of the process command. This means that all files and directories created in this temporary directory will go away once the execution of the process command is complete.

Excerpts from rng_section_config/common.incl (same file for all variants):

<command name="sect.toHTML">
  <process>
    <mkdir dir="images" />1

    <copyDocument to="__doc.xml">2
      <resources match="^[a-zA-Z][a-zA-Z0-9.+-]*:/.+" />3

      <resources match=".+\.(png|jpg|jpeg|gif)" copyTo="images" />4
    </copyDocument>

    <transform stylesheet="html.xsl" file="__doc.xml" to="__doc.html" />5

    <upload base="%0">67
      <copyFile file="__doc.html" to="%0" />
      <copyFiles files="images/*" toDir="images" />
    </upload>
  </process>
</command>

1

A process element has a number of child elements which are verbs acting on files and directories. Among these verbs, you'll find mkdir in XMLmind XML Editor - Commands.

Here we use mkdir to create an images/ directory. The images/ directory will contain a copy of some of the image files referenced in the "Simple Section" document being converted.

2

Child element copyDocument in XMLmind XML Editor - Commands is used to copy the document being converted to __doc.xml. Note that in the case the document being converted contains inclusions (XInclude, DITA conref, etc), these inclusions are fully transcluded in order to ease the job of the XSLT engine.

3

This resources element in XMLmind XML Editor - Commands specifies that resource files referenced in the document being converted by the means of absolute URIs (e.g. <image source="http://www.acm.com/logo.gif"/>) should be ignored.

4

This other resources element specifies that resource files referenced in the document being converted by the means of relative URIs ending with ".png", ".jpg", etc, (e.g. <image source="photos/photo43.jpg"/>) should be copied to the images/ directory.

Of course, this implies a fixup of the corresponding reference in __doc.xml (e.g. <image source="photos/photo43.jpg"/> becomes <image source="images/photo43.jpg"/>)

5

Child element transform in XMLmind XML Editor - Commands invokes the XSLT engine (Saxon 6.5 or Saxon 9 depending on the version of the XSLT stylesheet) in order to transform __doc.xml to __doc.html using stylesheet html.xsl.

6

Child element upload in XMLmind XML Editor - Commands is used to upload file __doc.html and directory images/ to the location specified by %0.

By upload, we really mean upload and not simply copy these files somewhere else on the local file system. For example, if you install the add-on called "FTP virtual drive plug-in", you'll be able to select an "ftp:" (or "ftps:" or "sftp:") URI using selectConvertedFile and then upload file __doc.html and directory images/ to the FTP server you have chosen.

7

What is %0?

All commands may be passed a parameter. This parameter may be considered to contain a number of arguments separated with whitespace (an argument itself containing whitespace should be quoted using single or double quotes). Variable %0 specifies the first argument, %2 the second one, etc, up to %9. For example, if a macro or process command is passed parameter "one 'two three' four", then %0 contains "one", %1 contains "two three" and %2 contains "four".

Process command sect.toHTML is passed a parameter containing the quoted URI of the save file, hence %0 contains the URI of the save file.