This is a proof of concept for a Schematron extension to the LemMinX XML language server.
It uses schxslt and Saxon-HE in order to validate an XML document against a schema.
- Java 17+ (JRE or JDK) installed and set up on
PATH.
This project is available as an extension from the official marketplace and OpenVSX.
- Download the LemMinX uber
.jarfrom lemminx's maven repo. (If there is a newer version of lemminx than 0.30.0, replace the number in the URL to get it). Put it somewhere meaningful and memorable. - Build the LemMinX Schematron extension. Put the built
.jarsomewhere meaningful and memorable. See Building lemminx extension - Setup LemMinX according to the instructions of your editor. Note that you cannot use the binary build of LemMinX, since the binary cannot be extended dynamically. When you get to the part in the setup instructions where you specify the command to launch the language server, move on to step 4.
- For the launch command, you need to use Java, specify both jars as classpath entries, and specify
org.eclipse.lemminx.XMLServerLauncheras the main class. eg:
java -Xmx1G -cp /path/to/lemminx.jar:/path/to/lemminx-schematron.jar org.eclipse.lemminx.XMLServerLauncher
-Xmx1G configures the max memory Java can use; feel free to reduce or increase this number according to your needs.
Note that the editor might want the arguments supplied as a list of strings, and may have separate fields for the command and the arguments.
Neovim
local lspconfig = require('lspconfig')
-- you should probably also specify `on_attach` and `capabilities` functions; I didn't here
lspconfig['lemminx'].setup {
cmd = { 'java', '-cp', '/home/davthomp/Documents/lemminx-extensions/org.eclipse.lemminx-0.30.0-uber.jar:/home/davthomp/Documents/lemminx-extensions/lemminx-schematron-0.1.0-SNAPSHOT.jar', 'org.eclipse.lemminx.XMLServerLauncher' }
}Helix (in languages.toml)
[[language]]
name = "xml"
file-types = [ "xml", "svg", "xsd", "xslt", "xsl", "sch" ]
auto-format = true
language-servers = [ "xml" ]
[language-server.xml]
command = "java"
args = ["-cp", "/home/davthomp/Documents/lemminx-extensions/lemminx-schematron-0.1.0-SNAPSHOT.jar:/home/davthomp/Documents/lemminx-extensions/org.eclipse.lemminx-0.30.0-uber.jar", "org.eclipse.lemminx.XMLServerLauncher"]Prerequisites: git, Java 17 or newer
- Clone this repo.
cdintolemminx-schematron- Run
./mvnw clean package(Linux, macOS) or.\mvnw.cmd clean package(Windows) - The
.jarwill be created in./lemminx-schematron/target
Prerequisites: git, Java 17 or newer, NodeJS 20 or newer, macOS or Linux (the npm scripts I wrote are not cross platform)
- Clone this repo.
cdintovscode-schematron- Install
vsceglobally if you don't have it installed already:npm i -g @vscode/vsce - Run
vsce package - The
.vsixwill be created in./vscode-schematron
- You can only validate with local
.schfiles - Not tested thoroughly
- The
.jaris prohibitively large to include as a part of the standard LemMinX distribution