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 - Extracts the selected XSLT instructions sequence into a
new template. Opens a dialog box
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 entire components are selected. Follow these steps:
- Choose whether you want to move the selected components to a new stylesheet or an
existing one.
- Select the destination stylesheet. Press the Choose button to
select 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 whether or not the destination stylesheet
will be referenced (imported or included) 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. 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 cursor position.
- Extract local variable - Allows you to create a new local variable by extracting
the selected XPath expression. 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 - Allows you to create a new global variable by extracting
the selected XPath expression. 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 - Allows you to create a new template parameter by
extracting the selected XPath expression. 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 - Allows you to create a new global parameter by
extracting the selected XPath expression. 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 cursor
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.