You can define short names for predefined blocks of code called code templates. The short
names are displayed in the Content Completion window if the word at cursor position is a
prefix of such a short name. If there is no prefix at cursor position, that is the
character at the left of cursor is a whitespace, all the code templates are listed.
Oxygen XML Editor plugin
comes with
a lot of predefined code templates but you can 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
(usually 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,
- ${ask('user-message', param-type, 'default-value'
?)} - To prompt for values at runtime, use the ask('user-message',
param-type, 'default-value' ?) editor variable. The following parameters can be set:
- 'user-message' - the actual message to be displayed. Note the quotes
that enclose the message.
- param-type - optional parameter. Can have one of the following values:
- url - input is considered to be an URL.
Oxygen XML Editor plugin
checks
that the URL is valid before passing it to the transformation.
- password - input characters are hidden.
- generic - the input is treated as generic text that requires no
special handling.
- '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' will be displayed for the user, the type is not
specified (the default is string), the default value will be
'default'.
- ${ask('message', password)} - 'message' will
be displayed for the user, the characters typed will be replaced with a circle
character.
- ${ask('message', password, 'default')} - Same as above, default
value will be 'default'.
- ${ask('message', url)} - 'message' will be
displayed for the user, the type of parameter will be URL.
- ${ask('message', url, 'default')} - Same as above, default
value will be '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 plugin
installation folder.
- ${pd} - Current project folder as file path.
- ${oxygenInstallDir} -
Oxygen XML Editor plugin
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.
- ${system(var.name)} - Value of the
var.name system variable.
- ${date(pattern)} - Current date. Follows the given
pattern. Example: yyyy-MM-dd.