-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I use XML schemas? #10
Comments
It works pretty much the same way like jsonschema. I guess jsonschema even copied the methodology from xml. In order to validate an XML file against a scheme constraints need to be added to the XML document, pointing to the scheme. Variant 1 (DTD)The first way to do that is a doctype definition such as In case of tmPreferences, which is a property list, a valid SGML head would need to look like:
LemMinX downloads the scheme file to cache and uses that for validation then. To support validation for files without that DOCTYPE defintion LSP-lemminx allows to create a mapping for file extensions -> schemes pretty much like LSP-json. That's what LSP-lemminx uses to assign ST's preferences file the PropertyList-1.0.dtd scheme to. The result is pretty much the same.
Variant 2 (XSD)An XML file may contain tags of several namespaces. The xmlscheme namespace
This is the more modern and flexibal approach of defining constraints in a xml file, which was created when limitations of DTD approach came up. That's why you might find both definition types for some xml file types. The xmlscheme for instance may be validated using a xmlschema.dtd or xmlschema.xsd The rest is the same. LemMinX tries to resolve the URL and download the scheme behind to cache directory and uses it for validation and completions etc. Catalogs (Local Scheme Definitions)Creating our own schemes and assign them to Means we could create an XSD or DTD for The files look different, but it's the same as with jsonscheme. I started playing with such a local catalog definition which includes the most basic schemes. A main catalog in Catalogs/ sub directory
pointing to the different schemes organized in sub directores e.g.: Catalogs/xml/
I symlinked the Catalog from Packages/LSP-lemminx/Catalog to Package Storage/LSP-lemminx/Catalog as it will need to be extracted from a sublime-package file to be readable by the language server. The location is specified in LSP-lemminx.sublime-settings .
|
Thanks for this great explanation. This could perhaps go into the readme? |
As a relative noob with respect to XML schemas (DTD files?), how do I set up this language server to recognize, for instance, tmPreferences files?
The text was updated successfully, but these errors were encountered: