Oxygen XML Editor offers a set of actions that allow changing the structure of an XSLT
stylesheet without changing the results of running it in an XSLT transformation. Depending on
the selected text, the following refactoring actions are available from
Refactoring submenu from the contextual menu of the current editor and the menu:
Extract
template... - Opens a dialog that allows you to specify
the name of the new template to be created. The possible changes to perform on the document
can be previewed before altering the document. After pressing OK, the template is created
and the selection is replaced with a <xsl:call-template> instruction
referencing the newly created template.Note: This action is available only when the
selection contains well-formed elements.
Note: The newly created template is
indented and its name is highlighted in the <xsl:call-template>
element.
Move to
another stylesheet... - Allows
you to move one or more XSLT global components (templates, functions or parameters) to
another stylesheet. Active only when these components are selected. Follow these
steps:
- execute the Move to another stylesheet action. You will be
prompted to select the destination stylesheet, which can be: a new stylesheet or an
already existing one.
- press the Choose button to navigate to the destination
stylesheet file. Oxygen XML Editor will automatically check if the destination
stylesheet is already contained by the hierarchy of the current stylesheet. If it is not
contained, choose if the destination stylesheet will be referenced (imported or
included) or not from the current stylesheet. The following options are available:
- Include - the current stylesheet will use an
xsl:include instruction to reference the destination
stylesheet.
- Import - the current stylesheet will use an
xsl:import instruction to reference the destination
stylesheet.
- None - there will be created no relation between the
current and destination stylesheets.
- press the Move button to move the components to the destination
stylesheet. After the action's execution, the moved components are highlighted in the
destination stylesheet.
- Convert attributes to xsl:attributes - Converts the attributes from
the selected element and represents each of them with an
<xsl:attribute> instruction. For example, from the following
element:
<person id="Big{test}Boss"/>
you
obtain:
<person>
<xsl:attribute name="id">
<xsl:text>Big</xsl:text>
<xsl:value-of select="test"/>
<xsl:text>Boss</xsl:text>
</xsl:attribute>
</person>
- Convert xsl:if into xsl:choose/xsl:when - Converts an
xsl:if block to an xsl:when block surrounded by an
xsl:choose element. For example, the following
block:
<xsl:if test="a">
</xsl:if>
is
converted
to:
<xsl:choose>
<xsl:when test="a">
</xsl:when>
<xsl:otherwise>
|
</xsl:otherwise>
</xsl:choose>
where
the | character is the current caret position.
- Extract local variable - After
creating the new local variable before the current element, Oxygen XML Editor allows
you to edit in-place the variable's name.
Note: The action is active on a selection made
inside an attribute that contains an XPath expression.
- Extract global variable - After creating the new global variable, Oxygen XML Editor allows you
to edit in-place the variable's name.
Note: The action is active on a selection made inside
an attribute that contains an XPath expression.
Note: Oxygen XML Editor checks
if the selected expression depends on local variables or parameters that are not available
in the global context where the new variable is created.
- Extract template parameter - After creating the new parameter, Oxygen XML Editor allows you to
edit in-place its name.
Note: The action is active on a selection made inside an attribute
that contains an XPath expression.
- Extract global parameter - After creating the new parameter, Oxygen XML Editor allows you to
edit in-place its name.
Note: The action is active on a selection made inside an attribute
that contains an XPath expression.
Note: Oxygen XML Editor checks if the
selected expression depends on local variables or parameters that are not available in the
global context where the new parameter is created.
- Rename Component - Allows you to rename
the current component in-place. The component and all its references in the document are
highlighted with a thin border and the changes you make to the component at the caret
position are updated in real time to all occurrences of the component. To exit in-place
editing, press the Esc or
Enter key on your keyboard.
Rename Component in... - Opens the Rename
component_type dialog box that allows you to rename the
selected component by specifying the new component name and the files to be affected by the
modification. If you click the Preview button, you can view the files
affected by the Rename Component action.
Figure: Rename Identity Constraint Dialog Box
To watch our video demonstration about XSLT refactoring, go to http://oxygenxml.com/demo/XSL_Refactoring.html.