XSLT Refactoring Actions
Oxygen XML Developer plugin offers a set of actions that allow you to change the structure of an XSLT stylesheet without changing the results of running it in an XSLT transformation. Depending on the selected text, the following XSLT refactoring actions are available from the Refactoring submenu of the contextual menu:
 Extract
                  template (Active only when the selection contains well-formed elements) - Extracts the selected XSLT instructions sequence into a
                  new template. It 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 Extract
                  template (Active only when the selection contains well-formed elements) - Extracts the selected XSLT instructions sequence into a
                  new template. It 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.- NoteThe newly created template is indented and its name is highlighted in the- <xsl:call-template>element.
 Extract function -
               Extracts the selected XSLT instructions sequence into a new function. It opens a dialog
               box
               that allows you to specify the name of the new function. It then moves the selected
               lines to
               a newly created XSLT function and inserts a function call in the place of the selected
               lines. Extract function -
               Extracts the selected XSLT instructions sequence into a new function. It opens a dialog
               box
               that allows you to specify the name of the new function. It then moves the selected
               lines to
               a newly created XSLT function and inserts a function call in the place of the selected
               lines.
 Create local
                  variable - Creates an XSLT variable, wrapped around the selection. It opens a
               dialog box that allows you to specify the name of the new variable. It then wraps
               the
               selection in the variable and you can reference it at anytime in the code. Create local
                  variable - Creates an XSLT variable, wrapped around the selection. It opens a
               dialog box that allows you to specify the name of the new variable. It then wraps
               the
               selection in the variable and you can reference it at anytime in the code.
 Move to
                  another stylesheet (Active only when entire components are selected) - Allows you to move one or more XSLT global
                  components (templates, functions, or parameters) to another stylesheet. It opens a
               dialog box that allows you to specify where the selected components will be moved
               to. Follow
               these steps when using the dialog box: Move to
                  another stylesheet (Active only when entire components are selected) - Allows you to move one or more XSLT global
                  components (templates, functions, or parameters) to another stylesheet. It opens a
               dialog box that allows you to specify where the selected components will be moved
               to. Follow
               these steps when using the dialog box:- Choose whether you want to move the selected components to a new stylesheet or an existing one.
- If you choose to move the components to an existing one, select the destination
                     stylesheet. Press the Choose button to select the destination
                     stylesheet file. Oxygen XML Developer plugin 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:includeinstruction to reference the destination stylesheet.
- Import - The current stylesheet will use an
                           xsl:importinstruction to reference the destination stylesheet.
- None - There will be created no relation between the current and destination stylesheets.
 
- Include - The current stylesheet will use an
                           
- Press the Move button to move the components to the destination. 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, the following element:<person id="Big{test}Boss"/>is converted to: <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:ifblock to anxsl:whenblock surrounded by anxsl:chooseelement. For example, the following block:<xsl:if test="a"> <!-- XSLT code --> </xsl:if> is converted to: <xsl:choose> <xsl:when test="a"> <!-- XSLT code --> </xsl:when> <xsl:otherwise> | </xsl:otherwise> </xsl:choose>(where the |character is the current cursor position)
 Extract local variable
               (Active on a selection made inside an attribute that contains an XPath expression)
               - 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 Developer plugin allows you to edit the
               name of the variable. Extract local variable
               (Active on a selection made inside an attribute that contains an XPath expression)
               - 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 Developer plugin allows you to edit the
               name of the variable.
 Extract global variable
               (Active on a selection made inside an attribute that contains an XPath expression)
               - Allows you to create a new global variable by extracting
                  the selected XPath expression. After creating the
               new global variable, Oxygen XML Developer plugin allows you to edit the name of the
               variable. Extract global variable
               (Active on a selection made inside an attribute that contains an XPath expression)
               - Allows you to create a new global variable by extracting
                  the selected XPath expression. After creating the
               new global variable, Oxygen XML Developer plugin allows you to edit the name of the
               variable.- NoteOxygen XML Developer plugin 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 (Active on a selection made inside an attribute that contains an
               XPath expression) - Allows you to create a new template parameter by
                  extracting the selected XPath expression. After creating the new parameter, Oxygen XML Developer plugin allows you to edit the name of
               the parameter. Extract template
                  parameter (Active on a selection made inside an attribute that contains an
               XPath expression) - Allows you to create a new template parameter by
                  extracting the selected XPath expression. After creating the new parameter, Oxygen XML Developer plugin allows you to edit the name of
               the parameter.
 Extract global parameter
               (Active on a selection made inside an attribute that contains an XPath expression)
               - Allows you to create a new global parameter by
                  extracting the selected XPath expression. After creating the
               new parameter, Oxygen XML Developer plugin allows you to edit the name of the parameter. Extract global parameter
               (Active on a selection made inside an attribute that contains an XPath expression)
               - Allows you to create a new global parameter by
                  extracting the selected XPath expression. After creating the
               new parameter, Oxygen XML Developer plugin allows you to edit the name of the parameter.- NoteOxygen XML Developer plugin 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 the in-place editing, press the Esc or Enter key on your keyboard.
 Rename Component in - Opens a 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 to be affected by the action. Rename Component in - Opens a 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 to be affected by the action.
Note
To watch our video demonstration about XSLT refactoring, go to https://www.oxygenxml.com/demo/XSL_Refactoring.html.
 
          