Custom Refactoring Operation Descriptor File

The second step in creating a custom refactoring operation is to create an operation descriptor file. The easiest way to do this is to use the New document wizard and choose the XML Refactoring Operation Descriptor template.

Introduction to the Descriptor File

This file contains information (such as name, description, and id) that is necessarily when loading an XML Refactoring operation . It also contains the path to the XQuery Update script that is associated with the particular operation through the script element.

You can specify a category for your custom operations to logically group certain operations. The category element is optional and if it is not included in the descriptor file, the default name of the category for the custom operations is Other operations.

The descriptor file is edited and validated against the following schema: frameworks/xml_refactoring/operation_descriptor.xsd.

Declaring Parameters in the Descriptor File

If the XQuery Update script includes parameters, they should be declared in the parameters section of the descriptor file. All the parameters specified in this section of the descriptor file will be displayed in the XML Refactoring tool within the Configure Operation Parameters wizard page for that particular operation.

The value of the first description element in the parameters section will be displayed at the top of the Configure Operation Parameters wizard page.

To declare a parameter, specify the following information:

Specialized Parameters (elementParameter and attributeParameter)

If you want to match elements or attributes, use the specialized parameters elementParameter or attributeParameter. If you use these parameters, Oxygen XML Editor will propose all declared elements or attributes based on the schema associated with the currently edited file.

Example of an elementParameter:

<elementParameter id="elemID">
    <localName label="Name" name="element_localName" allowsAny="true">
        <description>The local name of the attribute's parent element.</description>           
    </localName>
    <namespace label="Namespace" name="element_namespace" allowsAny="true">
        <description>The local name of the attribute's parent element</description>           
    </namespace>        
</elementParameter>

This parameter is used to specify elements by local name and namespace. For this type of parameter, the application displays two combo boxes with elements and namespaces collected from the associated schema of the currently edited file. The text from the label attribute is displayed in the application as label of the associated combo. The name attribute is used to specify the name of the parameter from the XQuery Update script. If you specify the allowsAny attribute, the application will propose <ANY> as a possible value for the Name and Namespace combo boxes.

Example of an attributeParameter:

<attributeParameter dependsOn="elemID">
    <localName label="Name" name="attribute_localName">
        <description>The name of the attribute to be converted.</description>
    </localName>
    <namespace label="Namespace" name="attribute_namespace" allowsAny="true">
        <description>The namespace of the attribute to be converted.</description>
    </namespace>        
</attributeParameter>
This parameter is used to specify attributes by local name and namespace. For this type of parameter, the application displays two combo boxes with attributes and their namespaces collected from the associated schema of the currently edited file. The text from the label attribute is displayed in the application as the label of the associated combo box.
Note: An attributeParameter is dependant upon an elementParameter. The list of attributes and namespaces are computed based on the selection in the elementParameter combo boxes.
Note: All predefined operations are loaded from the installDir/refactoring folder.
Related information
Example of an XML Refactoring Operation