Skip to content

XSLT 3.0 in Visual Studio Code

Phil Fearon edited this page Jan 24, 2021 · 16 revisions

Visual Studio Code with DeltaXML’s XSLT provides a comprehensive set of language features for XSLT 3.0. This page outlines how these language features can be used to help you work with XSLT more effectively.

Syntax Highlighting

Accurate and responsive syntax highlighting for XSLT and XPath expressions is provided by a hand-crafted semantic token provider. Code is processed character by character, avoiding the unpredictable behaviour of line by line regex based tokenisers on the most complex expressions.

Syntax highlighting is currently only enabled by default in VSCode's built-in themes. This is because some extension themes may not yet have specific language support for VSCode's 'Semantic Highlighting' as used by this extension.

To enable syntax highighting for a custom theme you need to change User Settings. For example, to enable syntax highlighting for XSLT in the City Lights theme use:

{
    "editor.semanticTokenColorCustomizations":{
      "[City +Lights]": {"enabled": true}
    },
}

Or, to enable syntax highlighting for all themes:

{
    "editor.semanticTokenColorCustomizations":{
      "enabled": true
    },
}

Auto-Completion

Auto-complete combines built in XSLT symbols (depending on context) along with symbols from the current XSLT and included/imported XSLT.

Symbols include names for:

  • accumulators
  • attribute name tests
  • attribute sets
  • anonymous function parameters
  • element name tests
  • functions
  • function parameters
  • xsl:iterate parameters
  • xsl:key names
  • XSLT instructions
  • template modes
  • template names
  • XSLT variables
  • XPATH range variables for 'let', 'every','for' and 'some'

For XSLT/XPATH functions, help text is also shown. XSLT instructions are auto completed with suitable attributes where relevant.

Problem Reporting

XML and XSLT/XPATH Problems are highlighted in the source code and listed in the VSCode problems tab.

The extension itself checks all symbol names are valid and in-scope for the context, it also performs basic XPATH expression checking. This allows more granular reporting than most XSLT editors report using just an XSLT compiler or processor.

More subtle static or runtime problems reported by the Saxon processor and shown in the terminal, in most cases these should also result in the problem source code being highlighted, there are known exceptions however where the Saxon error message is not properly parsed by the extension.

Unlike many other XSLT editors, this extension shows all problems not just the first one (which may not be the most significant).

Clone this wiki locally