-
Notifications
You must be signed in to change notification settings - Fork 6
XSLT 3.0 in Visual Studio Code
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.
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-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
- xmlns declarations - for supported namespaces
- 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. Use the tab key to jump between pre-filled values.
Note that to filter auto-complete suggestions you don't need to always type the start of the name like in some other editors. For example, don't type 'xsl:' for an XSLT 'for-each' instruction
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).
Indentation for XML and for multi line nested XPATH expressions is provided by the extension.
To work most effectively, as-you-type and format-on-save formatting should be enabled in the VSCode settings.
The symbol outline view shows a tree view of the XSLT structure with symbol names added. The order of items in the tree view can be set to show document order. The tree view can also be set to be synchronised with the currently selected item.
Shown at the top of the editor, the Breadcrumbs control shows the nesting information of the currently selected element. This control can also be clicked on to navigate up the document tree.
To navigate to the location where a symbol is defined, hold down the CMD button and click on the symbol name. This feature is also available from the right-click context menu.