You can define short names for predefined blocks of code called code templates. The short
names are displayed in the Content Completion window when the word at cursor position is a
prefix of such a short name. If there is no prefix at cursor position (a whitespace precedes
the cursor), all the code templates are listed.
Oxygen XML Editor comes with numerous predefined code templates. You can also define your own code
templates for any type of editor. For more details, see the example for XSLT editor code
templates.
To obtain the template list, you can use the Content Completion on request shortcut key
(CTRL+SPACE) or the Code Templates on request shortcut key (CTRL+SHIFT+SPACE). The first
shortcut displays the code templates in the same content completion list with
elements from the schema of the document. The second shortcut displays only the code
templates and is the default shortcut of the action .
The syntax of the code templates allows you to use the following
editor
variables:
- ${caret} - The position where the caret is
inserted. This variable can be used in a code template , in Author operations, or
in a selection plugin.
- ${selection} - The XML content of the current
selection in the editor panel. This variable can be used in a code template
and Author
operations, or in a selection plugin.
- ${ask('message', type, ('real_value1':'rendered_value1';
'real_value2':'rendered_value2'; ...), 'default_value')} - To prompt for
values at runtime, use the ask('message', type, ('real_value1':'rendered_value1';
'real_value2':'rendered_value2'; ...), 'default-value'') editor variable. The
following parameters can be set:
- 'message' - the displayed message. Note the quotes that enclose the
message.
- type - optional parameter. Can have one of the following values:
- 'default-value' - optional parameter. Provides a default value in the
input text box.
Examples:
- ${ask('message')} - Only the message displayed for the user is
specified.
- ${ask('message', generic, 'default')} -
'message' is displayed, the type is not specified (the default
is string), the default value is 'default'.
- ${ask('message', password)} - 'message' is
displayed, the characters typed are masked with a circle symbol.
- ${ask('message', password, 'default')} - same as before, the
default value is 'default'.
- ${ask('message', url)} - 'message' is
displayed, the parameter type is URL.
- ${ask('message', url, 'default')} - same as before, the default
value is 'default'.
- ${timeStamp} - Time stamp, that is the current
time in Unix format. It can be used for example to save transformation results in different
output files on each transform.
- ${uuid} - Universally unique identifier.
- ${id} - Application-level unique identifier.
- ${cfn} - Current file name without extension and
without parent folder.
- ${cfne} - Current file name with extension.
- ${cf} - Current file as file path, that is the
absolute file path of the current edited document.
- ${cfd} - Current file folder as file path, that is
the path of the current edited document up to the name of the parent folder.
- ${frameworksDir} - The path (as file path)
of the frameworks subfolder of the Oxygen XML Editor installation
folder.
- ${pd} - Current project folder as file path.
- ${oxygenInstallDir} - Oxygen XML Editor installation folder as
file path.
- ${homeDir} - The path (as file path) of the user
home folder.
- ${pn} - Current project name.
- ${env(VAR_NAME)} - Value of the
VAR_NAME environment variable. The environment variables are managed by the
operating system. If you are looking for Java System Properties, use the
${system(var.name)} editor variable.
- ${system(var.name)} -
Value of the var.name Java system property. The Java system properties can be
specified in the command line arguments of the Java runtime as
-Dvar.name=var.value. If you are looking for operating system environment
variables, use the${env(VAR_NAME)} editor variable instead.
- ${date(pattern)} - Current date. Follows the given
pattern. Example: yyyy-MM-dd.