Author Mode Default Operations
- JSOperationAllows you to call the Java API from custom JavaScript content.Note: For the Oxygen XML WebApp Component, this operation cannot be invoked using the JavaScript API.
function doOperation(){
//The current node is either entirely selected...
currentNode = authorAccess.getEditorAccess().getFullySelectedNode();
if(currentNode == null){
//or the cursor is placed in it
caretOffset = authorAccess.getEditorAccess().getCaretOffset();
currentNode = authorAccess.getDocumentController().getNodeAtOffset(caretOffset);
}
//Get current value of the @type attribute
currentTypeValue = "";
currentTypeValueAttr = currentNode.getAttribute("type");
if(currentTypeValueAttr != null){
currentTypeValue = currentTypeValueAttr.getValue();
}
//Ask user for new value for attribute.
newTypeValue = javax.swing.JOptionPane.showInputDialog("Input @type value", currentTypeValue);
if(newTypeValue != null){
//Create and set the new attribute value for the @type attribute.
attrValue = new Packages.ro.sync.ecss.extensions.api.node.AttrValue(newTypeValue);
authorAccess.getDocumentController().setAttribute("type", attrValue, currentNode);
}
}
- RemovePseudoClassOperation
Let's consider that there is a pseudo-class called myClass on the element
paragraph and there are CSS styles matching the pseudo-class.
paragraph:myClass{
font-size:2em;
color:red;
}
paragraph{
color:blue;
}
In the previous example, by removing the pseudo-class, the layout of the
paragraph is rebuilt by matching the other rules (in this case, the
foreground color of the paragraph element will become blue.
- TogglePseudoClassOperationAn implementation of an operation to toggle on/off the pseudo-class of an element. Accepts the following parameters:
-
name - Name of the pseudo-class to be toggled on/off.
- elementLocation - The XPath location that identifies the element. Leave it empty for the current element.
-
paragraph:myClass{
color:red;
}
paragraph{
color:blue;
}
By default, the paragraph content is rendered in blue. Suppose that we have a
TogglePseudoClassOperation configured for the myClass
pseudo-class. Invoking it the first time will set the myClass pseudo-class
and the paragraph will be rendered in red. Invoking the operation again, will remove the
pseudo-class and the visible result will be a blue rendered paragraph
element.
-
ExecuteMultipleWebappCompatibleActionsOperation
An implementation of an operation that runs a sequence of Oxygen XML WebApp Component-compatible actions, defined as a list of IDs.
-
DeleteElementsOperation
Deletes the nodes indicated by the
elementLocationsparameter XPath expression. If missing, the operation will delete the node at the cursor location. - DeleteElementOperation
Deletes the node indicated by the
elementLocationparameter XPath expression. If missing, the operation will delete the node at the cursor location. - InsertXIncludeOperation
Insert an
XIncludeelement at the cursor offset. Opens a dialog box that allows you to browse and select content to be included in your document and automatically generates the corresponding XInclude instruction.
- ${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.
- ${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.
- ${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:Parameter urlFormat: ${ask('message', url, 'default_value')}Description: Input is considered a URL. Oxygen XML Editor 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.
passwordFormat: ${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.
genericFormat: ${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_urlFormat: ${ask('message', relative_url, 'default')}Description: Input is considered a URL. Oxygen XML Editor tries to make the URL relative to that of the document you are editing. Note: If the$askeditor variable is expanded in content that is not yet saved (such as an untitled file, whose path cannot be determined), then Oxygen XML Editor 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.
comboboxFormat: ${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_valuevalues. 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 theosxkey. 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_comboboxFormat: ${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_valuevalues. 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.
radioFormat: ${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_valueand 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 returnosxfor the output.
'default-value'- optional parameter. Provides a default value.
- ${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.
- ${uuid} - Universally unique identifier, a unique sequence of 32 hexadecimal digits generated by the Java UUID class.
- ${id} - Application-level unique identifier. It is a short sequence of 10-12 letters and digits that is not guaranteed to be universally unique.
- ${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.
- ${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 [OXYGEN_INSTALL_DIR]/frameworksdirectory.
- ${pd} - Current project folder as file path. Usually the current folder selected in the Project View.
- ${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.nameJava 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. 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.