JetBrains Rider 2024.1 Help

Refactoring XSLT

  • Rename and Safe Delete for XSLT items such as templates, variables and parameters.

  • Introduce Variable for creating XSLT variables from selected XPath expressions.

  • Inline for variables.

Before you start

Install and enable the XPathView + XSLT plugin on the Settings/Preferences | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains Marketplace.

Renaming templates

Refactor | Rename

Named templates can be renamed in JetBrains Rider just like any other symbol. All xsl:call-template invocations that refer to this template will be updated accordingly.

Rename variables and parameters

Refactor | Rename

Just as named templates, it is possible to rename XSLT variables and template parameters, either at a point of their use or at their declaration.

Safe delete

Refactor | Safe Delete

Named templates, parameters and variables can be deleted using JetBrains Rider Safe Delete feature. In other words, the item will be removed if there aren't any references left to it in other Style Sheets across the project.

This is especially useful if the Style Sheet may be included in other ones via xsl:include or xsl:import to make sure that nothing will be deleted that is still used somewhere else.

Introduce variable

Refactor | Extract

It is possible to extract XPath-Expressions and turn them into an xsl:variable declaration. Check the Replace all occurrences checkbox to replace all other occurrences of the same expression.

Introduce parameter

Refactor | Extract

This is similar to Introduce Variable, but it creates a new parameter instead of a variable. It also has an additional option Create with default value that determines if the selected expression should be added as the introduced parameter's default value or if all calls to the template should be updated to pass the selected expression. That option is only available when introducing parameters to named templates.

Inline variable

Refactor | Inline

This is just the opposite of Introduce Variable, it replaces all usages of a variable with the expression that is specified in the variable's select-attribute. Variables that don't have such an attribute cannot be inlined. Inlining variable references that resolve to parameters is not possible as well.

Last modified: 26 May 2024