XSLT/XPath for Visual Studio CodeThe XSLT/XPath extension for VSCode provides comprehensive language support for XSLT 3.0 and XPath 3.1, and for the XSLT 4.0 and XPath 4.0 features implemented in Saxon 13. This ReadMe is merely a 'quick start' guide, see the XSLT/XPath User Guide for more comprehensive help.
XSLT 4.0 with a documentation note, its hover help where the function is called, and the XSLT Imports view:
FeaturesThis release adds full support for XSLT 4.0 in Saxon 13 - see Release 2.0 Highlights.
* Problem-reporting currently depends on the VSCode symbol-provider. To ensure problems are always reported in VSCode, use the following VSCode setting: XML CommandsThe XML selection commands are also in the XML Selection submenu of the editor's context menu (right-click), and in the XML: Select Element... quick pick (
IntroductionFor lexical analysis, this extension processes code character-by-character. This analysis is exploited for all features including all syntax highlighting. Avoiding the much more common use of regular expressions on a line-by-line basis brings significant benefits. These benefits include improved responsiveness, lower CPU load, improved code maintainability and greater integrity for syntax highlighting. Auto-completion is provided for XSLT and XPath. This includes context-aware completion items for all code symbol names. XSLT and XPATH function signatures and descriptions are shown in the description alongside function completion items. The last active non-XSLT file is used as the source to compute available node names for XPath location steps. This extension's linter performs a comprehensive set of checks on the code. The linter ensures that any code symbols within XSLT or XPath with problems are accurately identified at the symbol-level. Asynchronous processing for xsl:include/xsl:import dependencies allows checking of references to symbol definitions regardless of the location of the definition. Running XSLT
(1) XSLT in active editor, (2) the Saxon processor, (3) the XML context file - click the play button to run The quickest way to run the stylesheet in the active editor is Quick Run ( XSLT transforms for SaxonJava, SaxonJS and SaxonC are configured and run as special VSCode Tasks. XSLT task JSON properties can reference special commands. The special commands allow file-selection via a File Explorer or 'Recent Files' list, an example using:
For more a full description on using VSCode tasks to run XSLT, see Running XSLT. Release NotesThe project changelog is maintained on the project wiki. See Release Notes. Extension SettingsTo benefit from this extension, it's essential to make a few updates to VS Code's User or Workspace settings to your specific needs and environment. This section outlines the main settings associated with XSLT features. For more details on how these settings are managed within VS Code see: VSCode Settings XSLT TasksTo use the task-provider for the Java Saxon XSLT Processor, the following setting is required (alter path to suit actual jar location):
To use the task-provider for SaxonC, set the path of the folder containing the SaxonC command-line
XSLT 4.0 TasksXSLT 4.0 requires Saxon-PE or Saxon-EE (or the equivalent SaxonC edition). The task property When the
XSLT PackagesIf your XSLT contains xsl:use-package instructions, XSLT package names are resolved to lookup symbols to support the following features:
To allow XSLT package names to be resolved to file paths, package details should be added to the setting:
An example of XSLT package name settings:
If file paths are relative they are resolved from the first Visual Studio Code Workspace folder Note: Currently, XSLT Package versions are not used in package-name lookup FormattingThis extension supports special XSLT code formatting. This can be invoked with a VS Code command and/or as you type, depending on your settings. VSCode Formatting Command Keyboard Shortcuts
Recommended Editor Settings For Formatting etc.You should start with something like the following in the
RefactoringA range of code refactoring features are supported, including Rename Symbol, Extract Function and, for XSLT 4.0, Extract record type. When XSLT code is refactored, instructions and expressions are revised when necessary to ensure the code behaviour remains unchanged. For example, the Extract Function refactor revises all expressions requiring the context-item so the code compiles and runs as before. Editor Settings for Highlighting in Color Theme ExtensionsSyntax 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. A set of dark color themes, specially enhanced for XSLT, are provided by the XSLT Dark Themes extension. You can also customize XSLT token colors. For example, to enable syntax highlighting for XSLT and add some customizations in the Gruvbox Material Dark theme you could use:
Or, to enable syntax highlighting for all themes:
Editor Settings For Word Selection/NavigationFor word selection/navigation, by default, names like $two-parts are treated as two words for selection purposes and $ is also excluded from the name. This behaviour can be altered using the VSCode setting:
See: VSCode Documentation on Settings Code FoldingCode-folding currently works by indentation indicating the nesting level. So, if code-folding does not work as expected, try reformatting using (for MacOS) - Region code-folding is also supported. This can be useful, for example, for blocks of templates for a specific mode. To set a region code-folding block, surround it with
XSLT/XPath User GuideThe XSLT/XPath User Guide provides an introduction to features supported by this extension for XSLT and XPath developers. The main documentation pages are linked below:
Support for other languages with embedded XPathIn addition to XSLT, other XML-based languages/vocabularies with embedded XPath will be supported in future in this extension. Currently, DeltaXignia's Document Comparison Pipeline (DCP) format is supported, acting as a pilot for other languages. Project Sponsor Message:
|



