Highlighting errors in XSLT
The XSLT support can detect a range of errors in XSLT constructs, such as misspelled template names, missing template parameters, bad match-patterns, references to undeclared variables, wrong or useless embedded XPath expressions, and so on and also offers Quick Fixes to automatically fix some of those errors.
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 repository.
Where allowed, XPath function-calls, Axis names, Numbers, Strings, and so on are highlighted according to the currently active color scheme. If a different coloring is desired, those colors can be configured in the tab on the Color Scheme page of the Settings/Preferences.
XPath syntax checks
Just like the interactive XPath Expression Evaluation, the XSLT support catches any syntax error in XPath expressions used inside a Style Sheet.
XPath type checking
In XPath, almost all types are assignable to each other with certain well-defined conversion semantics. However, the conversion to NODESET isn't defined for any type and there's also no (portable) conversion function available. Such type-conversions are highlighted as an error.
A special form of XPath expression are patterns in XSLT. They are e.g. used as the value of the match-attribute in
xsl:template elements. Only a certain subset of XPath expressions is allowed here, which the XSLT support checks for.
References to variables that have not been declared or are not accessible from the current scope are detected and highlighted as an error. There are Quick Fixes available to create a variable or parameter declaration for such unresolved variables references.
In XSLT there must not be more than one variable or parameter declared on the same scope level. It's also not allowed that there is more than one template with the same name. The plugin will identify such duplicate declarations and highlight them in the editor.
Even though it is possible to have identically named variables or parameters in different nesting levels, this can be confusing and is likely to cause programming mistakes. The plugin can identify shadowed declarations and offers Quick-Fixes to either rename the local or the outer variable.
Missing template arguments
Another check that the XSLT support performs is whether all required parameters are specified with a
xsl:call-template. A parameter is considered required if there is no default value, i.e. if there's no select attribute and the paremeter's declaring element has an empty body.
Superfluous template arguments
There's also a supplemental check that flags arguments that are not declared as template parameters. There are Quick Fixes available to either remove the argument from the template-call or to add a corresponding parameter to the called template.
Function call arguments
The XSLT support does, just like the interactive XPath Expression Evaluation, check whether the number and types of function arguments match their declaration for built-in functions of XPath and XSLT.
All XPath inspections are supported for editing XSLT documents. Those inspections can also be suppressed in a way that is similar to the standard suppression-mechanism PhpStorm uses for Java code by using noinspection XML comments. The suppression is possible on different levels, either on instruction level, template-level (if applicable) or Style Sheet level.