-
Notifications
You must be signed in to change notification settings - Fork 4
XSLT Tasks
XSLT files located within a VSCode Workspace can be compiled and run using the Saxon XSLT processor for Java from Saxonica
-
Ensure you have a Folder or Workspace Folder open in VSCode
-
In VScode, press
Shift-CMD-P
then enter 'tasks:' to see Task Commands:
Select the 'tasks: Configure Task' command, a list of tasks will be shown:
The existing tasks, plus a 'xslt: Saxon Transform (New) entry are listed, as shown above, select this last entry to create a new task.
If a new task is created the 'label' property should be edited to describe the specific task.
To run a task, press Shift-CMD-B
. If there's no default task, select the required task from the list that is shown.
Any compile-time or run-time errors/warnings are shown in the VSCode Problems panel. Select an item in the Problems panel, to see the problem highlighted in the XSLT.
Each task can be configured to set options and XSLT parameters for an XSLT Transform. VSCode Variables like ${workspaceFolder} can be used within properties in a task configuration.
Sample tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "xslt",
"label": "Basic Transform",
"saxonJar": "${config:XSLT.tasks.saxonJar}",
"xsltFile": "${workspaceFolder}/basic.xsl",
"xmlSource": "${workspaceFolder}/basic.xsl",
"resultPath": "${workspaceFolder}/xslt-out/result1.xml",
"parameters": [
{"name": "p1", "value": "p1value"},
{"name": "p2", "value": "p2value"}
],
"initialMode": "main",
"classPathEntries": ["/xrc/utilitiy.class1", "/xrc/utility.class2"],
"group": {
"kind": "build"
},
"problemMatcher": [
"$saxon-xslt"
]
},
{
"type": "xslt",
"label": "Compile Active XSLT File",
"saxonJar": "${config:XSLT.tasks.saxonJar}",
"xsltFile": "${file}",
"xmlSource": "${file}",
"resultPath": "${workspaceFolder}/xslt-out/result1.xml",
"group": {
"kind": "build"
},
"problemMatcher": [
"$saxon-xslt"
]
}
]
}
Saxon 9.9 or later must be installed on the local machine. By default, the location of the Saxon Jar should be set in User Settings for the XPath Embedded extension.
Alternatively, the saxonJar property in tasks.json can be modified to use a value other than that set in User Settings.
Setting the Saxon Jar location in VSCode User Settings: