Client
This repository is the VS Code extension. It activates on the xml
language and starts the server process with Node over stdio.
Setup guide
This guide shows the expected sibling-project layout, build order, VS Code launch flow, schema configuration, and the moving parts between the client, server, and service.
What runs where
This repository is the VS Code extension. It activates on the xml
language and starts the server process with Node over stdio.
xml-language-server is the Language Server Protocol wrapper. It exposes
completion, hover, diagnostics, symbols, folding, rename, definition, references, and formatting.
xml-language-service is the editor-agnostic TypeScript library. It provides
XML parsing, language features, schema association, and Xerces WASM XSD validation.
Important
Keep the three language tooling projects beside each other. The client currently launches the server from
../xml-language-server/dist/server.js, and both the client and server use the
service through file:../xml-language-service.
xml-language-workspace/
xml-language-service/
xml-language-server/
xml-language-client/
The parent folder can be named anything. What matters is that these repositories are siblings
while you are developing with local file: dependencies.
Fresh setup
Start by cloning all three repositories into the same parent folder so the local
file: dependencies and server path resolve correctly.
mkdir xml-language-workspace
cd xml-language-workspace
git clone https://github.com/harshanacz/xml-language-service.git
git clone https://github.com/harshanacz/xml-language-server.git
git clone https://github.com/harshanacz/xml-language-client.git
After cloning, continue with the build commands below from inside
xml-language-client.
Build order
Build from the bottom layer upward: service first, server second, client last. That ensures
the local file: dependencies and generated server entry point are ready before
the extension tries to start. Start from inside xml-language-workspace and run
the steps in order.
cd xml-language-service
npm install
npm run build
cd ../xml-language-server
npm install
npm run bundle
npm run bundle creates dist/server.js and copies runtime assets
such as the Xerces WASM file and default schemas.
cd ../xml-language-client
npm install
npm run build
xml-language-workspace for step 2 or 3, use
cd xml-language-server or cd xml-language-client instead of the
../ command shown for the sequential flow.
Development
xml-language-client in VS Code.Launch Extension debug configuration, or press F5..xml, .xsd, or .xsl file.../xml-language-server/dist/server.js --stdio automatically.onLanguage:xml, so the server starts only after VS Code opens a document recognized as XML.
Try it
Use the xls-test repository as a sample XML workspace for checking activation, diagnostics, completion, hover, outline, folding, rename, formatting, and schema validation.
git clone https://github.com/harshanacz/xls-test.git
code xls-test
Start the extension from xml-language-client, then open this test workspace in
the Extension Development Host window and edit its XML files.
Validation
Built-in schema associations are provided by the service for common files such as
pom.xml and web.xml. Add custom associations in VS Code settings
with xmlLanguageServer.schemas.
{
"xmlLanguageServer.schemas": [
{
"pattern": "config.xml",
"xsdPath": "schemas/config.xsd"
},
{
"pattern": "**/*.xml",
"xsdPath": "/absolute/path/to/schema.xsd"
}
]
}
Relative xsdPath values are resolved from the workspace root. For XSD files with
xs:include or xs:import, keep the imported XSD and DTD files beside
the entry schema or in subdirectories under it; the server loads sibling schema assets recursively.
Debug flow
Use Launch Extension. The configured pre-launch task runs npm run build
and loads dist/extension.js in the Extension Development Host.
Use Launch + Attach Server. The client starts Node with
--inspect=6009, and VS Code attaches to the server output in
../xml-language-server/dist.
Distribution
After building the service, server, and client, create a VSIX package from the client repo.
cd ../xml-language-client
npm run package
The package script uses vsce package from this repository's dev dependencies.
Fast fixes
| Symptom | Check | Fix |
|---|---|---|
| Extension starts but no XML features appear. | Open an XML file and check the Extension Host console. | Rebuild the client with npm run build. |
| Server module cannot be found. | Confirm ../xml-language-server/dist/server.js exists. |
Run npm install and npm run bundle in the server repo. |
| Service package cannot be resolved. | Confirm ../xml-language-service/dist/index.js exists. |
Run npm install and npm run build in the service repo, then reinstall server/client dependencies. |
| XSD diagnostics do not show. | Check xmlLanguageServer.schemas and schema paths. |
Use workspace-relative paths or absolute paths, then reload the VS Code window. |
| WASM validation fails at runtime. | Confirm xerces_validator.wasm was copied into server dist. |
Run the server npm run bundle script again. |
Verify