Appendix A. A simple preprocessor for .xxe configuration files and .xxe_gui GUI specification files

In some cases, you want to include, or on the contrary exclude, some configuration elements from a configuration file depending on the working environment of the user.

For example, unless the "XMLmind FO Converter XSL-FO processor plug-in" add-on has been installed, do not add the following menu items to the DITAConvert Document submenu (excerpts from XXE_install_dir/addon/config/dita/xslMenu.incl):

<item label="Convert to _RTF (Word 2000+)..."
      command="dita.convertToRTF"
      parameter="rtf Cp1252" />
...
<item label="Convert to Open_Document (OpenOffice.org 2+ ODT)..."
      command="dita.convertToRTF"
      parameter="odt UTF-8" />

This can be achieved as follows:

<menu label="-" insert="after ##last">
  <separator />
  <menu label="_Convert Document">
    <item label="Convert to X_HTML..."
          command="dita.convertToXHTML" />
    ...
    <?if XSL_FO_PROCESSORS*=XFC?>
    <item label="Convert to _RTF (Word 2000+)..."
          command="dita.convertToRTF"
          parameter="rtf Cp1252" />
    ...
    <item label="Convert to Open_Document (OpenOffice.org 2+ ODT)..."
          command="dita.convertToRTF"
          parameter="odt UTF-8" />
    <separator />
    <?endif?>
    ...
    <item name="convertToPDF" label="Convert to _PDF..."
          command="dita.convertToPS"
          parameter="pdf pdf" />
  </menu>
</menu>

A simple preprocessor is automatically invoked by the .xxe/.incl (XXE configuration files) and .xxe_gui (XXE GUI specification files) loaders prior to using the loaded configuration/GUI specification elements.

This preprocessor supports 3 directives specified using 3 processing-instructions:

<?if TEST?>
...configuration/GUI specification elements...
<?else?>
...configuration/GUI specification elements...
<?endif?>

Testing a condition

TEST is generally the name of a system property. If the system property is defined, the test evaluates to true, otherwise, it evaluates to false. Example (excerpts from DesktopApp.xxe_gui):

<menu name="fileMenu" label="_File" helpId="fileMenu">
  <?if XXE.Feature.NewWindow?>
  <action name="newWindowAction" />
  <separator />
  <?endif?>
  <action name="newAction" />
  <separator />
  ...

However, this test is not limited to testing the existence of a system property. It is also possible to specify:

system_property_name=value

The test evaluates to true when specified system property exists and is equal to specified value.

system_property_name^=value

The test evaluates to true when specified system property exists and starts with specified value.

system_property_name$=value

The test evaluates to true when specified system property exists and ends with specified value.

system_property_name*=value

The test evaluates to true when specified system property exists and contains specified value.

It is also possible to reverse the result of a test by preceding it by "!". Example:

<?if ! os.name*=Linux>
<toolBar name="mainToolBar" insert="after importRTFAction">
  <action name="importDOCXAction" />
</toolBar>
<?endif?>