Editor Variables
An editor variable is a shorthand notation for context-dependent information, such as a file or folder path, a time-stamp, or a date. It is used in the definition of a command (for example, the input URL of a transformation, the output file path of a transformation, or the command line of an external tool) to make a command or a parameter generic and re-usable with other input files. When the same command is applied to multiple files, the notation is expanded at the execution of the command so that the same command has different effects depending on the actual file.
Oxygen XML Editor plugin includes a variety of built-in editor variables. You can also create your own custom editor variables by using the Custom Editor Variables preferences page.
You can use the following editor variables in Oxygen XML Editor plugin commands of external engines or other external tools, in transformation scenarios, and in validation scenarios:
- ${af} - The local file path of the ZIP archive that includes the current edited document.
- ${afd} - The local directory path of the ZIP archive that includes the current edited document.
- ${afdu} - The URL path of the directory of the ZIP archive that includes the current edited document.
- ${afn} - The file name (without parent directory and without file extension) of the zip archive that includes the current edited file.
- ${afne} - The file name (with file extension, for
example
.zip
or.epub
, but without parent directory) of the zip archive that includes the current edited file. - ${afu} - The URL path of the ZIP archive that includes the current edited document.
- ${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. You can set
the following parameters:
'message'
- The displayed message. Note the quotes that enclose the message.type
- Optional parameter, with one of the following values:Note
The title of the dialog box will be determined by the type of parameter and as follows:- For
url
andurl_relative
parameters, the title will be the name of the parameter and the value of the'message'
. - For the other parameters listed below, the title will be the name of that respective parameter.
- If no parameter is used, the title will be "Input".
Parameter url
Format: ${ask('message', url, 'default_value')}
Description: Input is considered a URL. Oxygen XML Editor plugin checks that the provided URL is valid. Example: ${ask('Input URL', url)}
- The displayed dialog box has the nameInput URL
. The expected input type is URL.${ask('Input URL', url, 'http://www.example.com')}
- The displayed dialog box has the nameInput URL
. The expected input type is URL. The input field displays the default valuehttp://www.example.com
.
password
Format: ${ask('message', password, 'default')} Description: The input is hidden with bullet characters. Example: ${ask('Input password', password)}
- The displayed dialog box has the name'Input password'
and the input is hidden with bullet symbols.${ask('Input password', password, 'abcd')}
- The displayed dialog box has the name'Input password'
and the input hidden with bullet symbols. The input field already contains the default abcd value.
generic
Format: ${ask('message', generic, 'default')} Description: The input is considered to be generic text that requires no special handling. Example: ${ask('Hello world!')}
- The dialog box has aHello world!
message displayed.${ask('Hello world!', generic, 'Hello again!')}
- The dialog box has aHello world!
message displayed and the value displayed in the input box is'Hello again!'
.
relative_url
Format: ${ask('message', relative_url, 'default')}
Description: Input is considered a URL. Oxygen XML Editor plugin tries to make the URL relative to that of the document you are editing. Note
If the$ask
editor variable is expanded in content that is not yet saved (such as an untitled file, whose path cannot be determined), then Oxygen XML Editor plugin will transform it into an absolute URL.Example:
- ${ask('File location', relative_url,
'C:/example.txt')} - The dialog box has the name
'File location'
. The URL inserted in the input box is made relative to the current edited document location.
combobox
Format: ${ask('message', combobox, ('real_value1':'rendered_value1';...;'real_valueN':'rendered_valueN'), 'default')}
Description: Displays a dialog box that offers a drop-down menu. The drop-down menu is populated with the given rendered_value
values. Choosing such a value will return its associated value (real_value
).Note
The'default'
parameter specifies the default selected value and can match either a key or a value.Example: ${ask('Operating System', combobox, ('win':'Microsoft Windows';'osx':'Mac OS X';'lnx':'Linux/UNIX'), 'osx')}
- The dialog box has the name'Operating System'
. The drop-down menu displays the three given operating systems. The associated value will be returned based upon your selection.Note
In this example, the default value is indicated by theosx
key. However, the same result could be obtained if the default value is indicated byMac OS X
, as in the following example:${ask('Operating System', combobox, ('win':'Microsoft Windows';'osx':'Mac OS X';'lnx':'Linux/UNIX'), 'Mac OS X')}
${ask('Mobile OS', combobox, ('win':'Windows Mobile';'ios':'iOS';'and':'Android'), 'Android')}
editable_combobox
Format: ${ask('message', editable_combobox, ('real_value1':'rendered_value1';...;'real_valueN':'rendered_valueN'), 'default')}
Description: Displays a dialog box that offers a drop-down menu with editable elements. The drop-down menu is populated with the given rendered_value
values. Choosing such a value will return its associated real value (real_value
) or the value inserted when you edit a list entry.Note
The'default'
parameter specifies the default selected value and can match either a key or a value.Example: ${ask('Operating System', editable_combobox, ('win':'Microsoft Windows';'osx':'Mac OS X';'lnx':'Linux/UNIX'), 'osx')}
- The dialog box has the name'Operating System'
. The drop-down menu displays the three given operating systems and also allows you to edit the entry. The associated value will be returned based upon your selection or the text you input.
radio
Format: ${ask('message', radio, ('real_value1':'rendered_value1';...;'real_valueN':'rendered_valueN'), 'default')}
Description: Displays a dialog box that offers a series of radio buttons. Each radio button displays a 'rendered_value
and will return an associatedreal_value
.Note
The'default'
parameter specifies the default selected value and can match either a key or a value.Example: ${ask('Operating System', radio, ('win':'Microsoft Windows';'osx':'Mac OS X';'lnx':'Linux/UNIX'), 'osx')}
- The dialog box has the name'Operating System'
. The radio button group allows you to choose between the three operating systems.Note
In this example Mac OS X is the default selected value and if selected it would returnosx
for the output.
- For
'default-value'
- optional parameter. Provides a default value.
- ${caret} - The position where the cursor is located. This variable can be used in a code template, in Author mode operations, or in a selection plugin.
- ${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.
- ${cfdu} - Current file folder as URL, that is the path of the current edited document up to the name of the parent folder, represented as a URL.
- ${cfn} - Current file name without extension and without parent folder. The current file is the one currently opened and selected.
- ${cfne} - Current file name with extension. The current file is the one currently opened and selected.
- ${configured.ditaot.dir} - The default directory of the DITA Open Toolkit distribution, as configured in the DITA preferences page.
- ${cp} - Current page number. Used to display the current page number on each printed page in the Editor / Print Preferences page.
- ${currentFileURL} - Current file as URL, that is the absolute file path of the current edited document represented as URL.
- ${date(pattern)} - Current date. The allowed patterns
are equivalent to the ones in the Java SimpleDateFormat class. Example:
yyyy-MM-dd
;Note
This editor variable supports both the xs:date and xs:datetime parameters. For details about xs:date, go to http://www.w3.org/TR/xmlschema-2/#date. For details about xs:datetime, go to http://www.w3.org/TR/xmlschema-2/#dateTime. - ${dbgXML} - The local file path to the XML document that is current selected in the Debugger source combo box (for tools started from the XSLT/XQuery Debugger).
- ${dbgXSL} - The local file path to the XSL/XQuery document that is current selected in the Debugger stylesheet combo box (for tools started from the XSLT/XQuery Debugger).
- ${dita.dir.url} - A special local contextual editor
variable that gets expanded only in the Libraries dialog box that is
accessible from the Advanced tab of DITA transformation scenarios.
The Libraries dialog box allows you to specify additional libraries
(jar files or additional class paths) to be used by the transformer. This
${dita.dir.url} editor variable gets expanded to the value of the
dita.dir
parameter from the Parameters tab of the DITA transformation scenario. - ${ds} - The path of the detected schema as a local file path for the current validated XML document.
- ${dsu} - The path of the detected schema as a URL for the current validated XML document.
- ${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.
- ${framework(fr_name)} - The path (as URL)
of the
fr_name
framework. - ${framework} - The path (as URL) of the current
framework, as part of the
[OXYGEN_INSTALL_DIR]/frameworks
directory. - ${frameworkDir(fr_name)} - The path (as
file path) of the
fr_name
framework.Note
Since multiple frameworks might have the same name (although it is not recommended), for both ${framework(fr_name)} and ${frameworkDir(fr_name)} editor variables Oxygen XML Editor plugin employs the following algorithm when searching for a given framework name:- All frameworks are sorted, from high to low, according to their Priority setting from the Document Type configuration dialog box. Only frameworks that have the Enabled checkbox set are taken into account.
- Next, if the two or more frameworks have the same name and priority, a further
sorting based on the Storage setting is made, in the exact
following order:
- Frameworks stored in the internal Oxygen XML Editor plugin options.
- Additional frameworks added in the Locations preferences page.
- Frameworks installed using the add-ons support.
- Frameworks found in the main frameworks location (Default or Custom).
- ${frameworkDir} - The path (as file path) of
the current framework, as part of the
[OXYGEN_INSTALL_DIR]/frameworks
directory. - ${frameworks} - The path (as URL) of the
[OXYGEN_INSTALL_DIR]
directory. - ${frameworksDir} - The path (as file path) of
the
[OXYGEN_INSTALL_DIR]/frameworks
directory. - ${home} - The path (as URL) of the user home folder.
- ${homeDir} - The path (as file path) of the user home folder.
- ${i18n(key)} - Editor variable used only at framework level to allow translating names and descriptions of Author mode actions in multiple actions. For more details, see Localizing Frameworks.
- ${id} - Application-level unique identifier. It is a short sequence of 10-12 letters and digits that is not guaranteed to be universally unique.
- ${makeRelative(base,location)} - Takes two URL-like
paths as parameters and tries to return a relative path. A use-case would be to insert
content references to a certain reusable component when defining code
templates.
Example:
${makeRelative(${currentFileURL}, ${dictionaryURL}#gogu)}
- ${oxygenHome} - Oxygen XML Editor plugin installation folder as URL.
- ${oxygenInstallDir} - Oxygen XML Editor plugin installation folder as file path.
- ${pd} - The file path for the parent folder of the current project selected in the Navigator view.
- ${pdu} - The URL for the parent folder of the current project selected in the Navigator view.
- ${pn} - Current project name.
- ${ps} - Path separator, which is the separator that can be used on the current platform (Windows, OS X, Linux) between library files specified in the class path.
- ${selection} - The current selected text content in the current edited document. This variable can be used in a code template, in Author mode operations, or in a selection plugin.
- ${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. - ${timeStamp} - Time stamp, that is the current time in Unix format. For example, it can be used to save transformation results in multiple output files on each transformation.
- ${tp} - Total number of pages in the document. Used to display the total number of pages on each printed page in the Editor / Print Preferences page.
- ${tsf} - The transformation result file path. If the current opened file has an associated scenario that specifies a transformation output file, this variable expands to it.
- ${uuid} - Universally unique identifier, a unique sequence of 32 hexadecimal digits generated by the Java UUID class.
- ${xpath_eval(expression)} - Evaluates an XPath 3.0
expression. Depending on the context, the expression can be:
- static - When executed in a non-XML context. For example, you can use
such static expressions to perform string operations on other editor variables for
composing the name of the output file in a transformation scenario's Output
tab.
Example:
${xpath_eval(upper-case(substring('${cfn}', 1, 4)))}
- dynamic - When executed in an XML context. For example, you can use such
dynamic expression in a code template or as a value of a parameter of an
Author mode operation.
Example:
${ask('Set new ID attribute', generic, '${xpath_eval(@id)}')}
- static - When executed in a non-XML context. For example, you can use
such static expressions to perform string operations on other editor variables for
composing the name of the output file in a transformation scenario's Output
tab.