| Refactoring XML Documents / Custom Refactoring Operations | |
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.
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 or XSLT stylesheet 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.
If the XQuery Update script or XSLT stylesheet 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:
XPATH - Type of parameter whose value is an XPATH expression. For this type of parameter, Oxygen XML Developer plugin will use a text input with corresponding content completion and syntax highlighting.
<possibleValues onlyPossibleValuesAllowed="true"> <value name="before">Before</value> <value name="after"default="true">After</value> <value name="firstChild">First child</value> <value name="lastChild">Last child</value> </possibleValues>
Example of an elementLocation:
<elementLocation name="elem_loc" useCurrentContext="false"> <element label="Element location"> <description>Element location description.</description> </element> </ ElementLocation>
Example of an attributeLocation:
<attributeLocation name="attr_xpath" useCurrentContext="true"> <element label="Element path"> <description>Element path description.</description> </element> <attribute label="Attribute" > <description>Attribute path description.</description> </attribute> </ AttributeLocation>
Example of an elementParameter:
<elementParameter id="elemID"> <localName label="Name" name="element_localName" allowsAny="true" useCurrentContext="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>
Example of an attributeParameter:
<attributeParameter dependsOn="elemID"> <localName label="Name" name="attribute_localName" useCurrentContext="true"> <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>