Skip to content
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

Open
bwiernik opened this issue Oct 13, 2022 · 11 comments
Open

Schema validation in VS Code #6272

bwiernik opened this issue Oct 13, 2022 · 11 comments
Labels
waiting-for-response-from-contributor The ticket/pull request is awaiting input from the contributor/depositor

Comments

@bwiernik
Copy link
Member

Looks like it might finally be possible eclipse-lemminx/lemminx#237

@adam3smith @POBrien333

@denismaier
Copy link
Member

👍

@github-actions github-actions bot added the waiting-for-response-from-contributor The ticket/pull request is awaiting input from the contributor/depositor label Oct 13, 2022
@denismaier
Copy link
Member

I haven't had a chance to test this, but it should work by now. Has anyone already tested?

@adam3smith
Copy link
Member

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

@denismaier
Copy link
Member

I've just tried now as well. And it seems to work to some degree---though not perfectly yet. E.g. this:

grafik

I think that should raise errors, but it doesn't. It doesn't even complain about <asdf>asdf</asdf>...

Also, autocompletion is sometimes a bit odd. On text variable=""/> autocompletion works just fine.

grafik

However, if I do the same on cs:if, I don't get the same result:

grafik

I need to check in Atom and Oxygen if the behavior there was better.

@adam3smith
Copy link
Member

Would you mind sharing how you set this up?

@denismaier
Copy link
Member

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"?>

@denismaier
Copy link
Member

Does that work for you?

@adam3smith
Copy link
Member

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.
Also, of course, adding and deleting that line is a hassle -- I need this to work based on file extension to be really worthwhile.

@denismaier
Copy link
Member

Yeah. It's still not totally there.

Also, of course, adding and deleting that line is a hassle -- I need this to work based on file extension to be really worthwhile.

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.

@bdarcus
Copy link
Member

bdarcus commented Apr 1, 2023

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.

@adam3smith

I am able to get autocomplete working and I can see that vs-xml is aware of the schema ...

How can you tell this?

@bdarcus
Copy link
Member

bdarcus commented Apr 1, 2023

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.

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?

Also, of course, adding and deleting that line is a hassle -- I need this to work based on file extension to be really worthwhile.

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-response-from-contributor The ticket/pull request is awaiting input from the contributor/depositor
Projects
None yet
Development

No branches or pull requests

4 participants