-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Schema validation in VS Code #6272
Comments
👍 |
I haven't had a chance to test this, but it should work by now. Has anyone already tested? |
I have tried (using the file association option) but can't get it to work, unfortunately. I'm pretty sure my JSON is correct (I've tested with an .xsd file) but it tells me that it can't find a Document grammar |
I've just tried now as well. And it seems to work to some degree---though not perfectly yet. E.g. this: I think that should raise errors, but it doesn't. It doesn't even complain about Also, autocompletion is sometimes a bit odd. On However, if I do the same on I need to check in Atom and Oxygen if the behavior there was better. |
Would you mind sharing how you set this up? |
Well, I've just installed the vscode-xml extension, and added this line add the top of the file: <?xml-model href="schema/schemas/styles/csl.rnc" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?> |
Does that work for you? |
Thanks. With that, I am able to get autocomplete working and I can see that vs-xml is aware of the schema, but nothing else useful works: not even non-matching tags (which are flagged in plain XML mode) are flagged anymore, and no incorrect variables or terms are flagged at. |
Yeah. It's still not totally there.
It should be possible to use a catalog file for this: https://github.com/redhat-developer/vscode-xml/blob/main/docs/Validation.md#xml-catalog-with-xsd Haven't tested this method yet. |
I think this should be the correct catalog file: <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri
name="http://purl.org/net/xbiblio/csl"
uri="~/csl/schema/csl.rnc" />
</catalog> If some detail is wrong, we basically want to associate namespace URI (can be extension also) with schema file. As I mentioned on discourse, I have no idea how to debug this to even assess whether it's a bug (so we can report it), or user error.
How can you tell this? |
I see the same thing when placing that first line. So, many months later, still not fixed. EDIT: this screenshot suggests at least some of it should work: Maybe we should look into a bug report?
This should be the easy one to solve with the catalog file. I'm just kind of confused where it goes! PS - here's an XML one: <?xml version="1.0"?>
<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
<uri pattern="*.csl" typeId="CSL"/>
<namespace ns="http://purl.org/net/xbiblio/csl" typeId="CSL"/>
<typeId id="CSL" uri="~/Code/csl/schemas/schemas/csl.rnc"/>
</locatingRules> |
Looks like it might finally be possible eclipse-lemminx/lemminx#237
@adam3smith @POBrien333
The text was updated successfully, but these errors were encountered: