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

Bind XSD, DTD with CodeLens #395

Closed
bricksdont opened this issue Jan 25, 2021 · 9 comments · Fixed by #494
Closed

Bind XSD, DTD with CodeLens #395

bricksdont opened this issue Jan 25, 2021 · 9 comments · Fixed by #494
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bricksdont
Copy link
Contributor

bricksdont commented Jan 25, 2021

A very useful feature for an XML IDE would be a button or action to associate an XML document that is currently open in VS Code with a schema file.

After clicking a button, a file dialog would open which would allow to select an XSD file from the file system. Then, your XML extension would insert into the XML document the correct attributes or processing instructions needed to make this association.

The reason why that would be useful is that there are several ways to associate an XML document with an XSD file:

https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#validation-with-xsd-grammar

all of them cumbersome, and hard to remember. Especially because you also have to pay close attention and be aware that it makes a difference whether the XML document to be associated has a namespace or not.

Oxygen has functionality like this and I find it very useful.

@angelozerr
Copy link
Contributor

Just for information, today we have a code action on the root element (if XML is not bound to a XSD/DTD) which

  • generate the XSD / DTD
  • generate the association (xsi:schemaLocation, xml-model, etc)

But I agree this code action doesn't provide the capability to bind the XML with an existing XSD, DTD.

I think the best mean should be to provide two vscode command

  • validate with XSD
  • validate with DTD

available for the current XML file. When this command is executed:

  • step1 : it should provide the binding strategy according the grammar type (ex : xsi:schemaLocation if the validation with XSD is executed.
  • step2 : it should open a file dialog to select the XSD or DTD file.

After the selected XSD, DTD file, it should generate the proper association according the binding strategy choose in the step 1.

@bricksdont
Copy link
Contributor Author

Thanks for your quick answer!

I think that "validate with XSD|DTD" would lead people to believe that the XML document itself is unchanged. "Associate with XSD|DTD" on the other hand implies that the XML document itself is changed (i.e. special attributes added to the root element).

For your extension to perform the validation is it absolutely necessary for the XML document itself to contain the association, e.g. with schemaLocation?

@angelozerr
Copy link
Contributor

Thanks for your quick answer!

You are welcome! I had this idea in my mind since several time,but I waited for user issue to know if it was relevant. Thanks for having created this issue :)

I think that "validate with XSD|DTD" would lead people to believe that the XML document itself is unchanged. "Associate with XSD|DTD" on the other hand implies that the XML document itself is changed (i.e. special attributes added to the root element).

Totally agree with you, yes command should be named with

  • Associate with XSD
  • Associate with DTD

For your extension to perform the validation is it absolutely necessary for the XML document itself to contain the association, e.g. with schemaLocation?

No, there are several binding strategy like xml-model, xsi:schemaLocation, xsi:noNamespaceLocation which are standard associations and we provide a non standard association with XML file association where you declare the association with a settings (it avoid to polluate the XML with this association) or with XML catalog.

Please read https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#validation-with-xsd-grammar

Managing XML file association or XML catalog should be very nice but I'm not sure it will be easy to implement.

@bricksdont
Copy link
Contributor Author

bricksdont commented Jan 26, 2021

Thanks,

Sorry I was not very clear: I meant does your extension need the association to be physically present either in the XML document itself, a catalog or the settings?

I was asking because if that is true, then it would be understandable that such an action would be called "Validate" instead of "associate" - because validation implies changing or creating files or settings.


Anyway, would be great to have a button / action like this.

@angelozerr
Copy link
Contributor

Sorry I was not very clear: I meant does your extension need the association to be physically present either in the XML document itself, a catalog or the settings?

Yes you need to store association somewhere. Otherwise how to know this association?

I was asking because if that is true, then it would be understandable that such an action would be called "Validate" instead of "associate" - because validation implies changing or creating files or settings.

As I said you, I'm totally agree with you and vscode commands should be called association with

Anyway, would be great to have a button / action like this.

vscode command is the standard support to do that.

@tomschr
Copy link

tomschr commented Apr 14, 2021

May I add the related issues #450 and #451? They shouldn't be forgotten when implementing this features. 😉 Thanks! 👍

@angelozerr
Copy link
Contributor

May I add the related issues #450 and #451? They shouldn't be forgotten when implementing this features. 😉 Thanks! 👍

Yes sure.

I think the best mean to support this issue is to use CodeLens when XML is not bound to a grammar like this

[Associate with XSD] [Associate with DTD] [Associate with RelaxNG] [Associate with Schematron]
<root>

</root>

@angelozerr angelozerr self-assigned this May 6, 2021
@datho7561 datho7561 added the enhancement New feature or request label May 13, 2021
@angelozerr angelozerr changed the title Feature request: buttons to associate XML documents with schema files Bind XSD, DTD with Codelens Jun 4, 2021
@angelozerr angelozerr changed the title Bind XSD, DTD with Codelens Bind XSD, DTD with CodeLens Jun 4, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 4, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 4, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 6, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 6, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 6, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 6, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 9, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 9, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 10, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 10, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 10, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
@datho7561 datho7561 added this to the 0.17.0 milestone Jun 10, 2021
datho7561 pushed a commit to eclipse-lemminx/lemminx that referenced this issue Jun 10, 2021
See redhat-developer/vscode-xml#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 11, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 11, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 11, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 11, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 12, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr
Copy link
Contributor

@bricksdont once my PR will be merge you should benefit with that:

BindWithCodeLensDemo

@bricksdont
Copy link
Contributor Author

This looks awesome! I will definitely test it once available. If the PR is merged to the main branch, can I get this version by updating inside VS Code?

angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 14, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 15, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Jun 16, 2021
Fixes redhat-developer#395

Signed-off-by: azerr <azerr@redhat.com>
datho7561 pushed a commit that referenced this issue Jun 16, 2021
Fixes #395

Signed-off-by: azerr <azerr@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants