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

Separate instructions for testing well formed XML files and validation against DTD #947

Open
ejgutierrez74 opened this issue Nov 15, 2023 · 17 comments · May be fixed by #950
Open

Separate instructions for testing well formed XML files and validation against DTD #947

ejgutierrez74 opened this issue Nov 15, 2023 · 17 comments · May be fixed by #950
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ejgutierrez74
Copy link

Related to #943 , #945

Would it possible to make two different instructions: one to test if a xml file is well formed and other to validate it against DTD file. Thats the way XML copy editor works, and many online validators.

Or at least in problems output, make a clear difference ( ideally separated by horizontal line or something like that ) between the xml file ( errors of not well formed file) and errors that came from DTD ( from validation of the xml file against DTD). Because mixing the two diferent source of errors, would be some kind of mess....specially to my students.

As @angelozerr asked me, i open a issue to separate, the bug from this feature request or enchancement.

The validation check is performed against any XML schema or DTD declared inside the XML document.
If neither an XML schema nor a DTD is declared, only a syntax check is performed.

Another example:
https://www.liquid-technologies.com/online-xml-validator

But in this case it misses the XML vs DTD validator...

My students and me were very grateful.... ;)

@angelozerr
Copy link
Contributor

Would it possible to make two different instructions: one to test if a xml file is well formed and other to validate it against DTD file.

If I understand your need you would like to validate:

  • only XML syntax
  • XML syntax + errors coming from DTD rules
  • XML syntax + errors coming from XSD rules

with separate commands?

To learn XML I can understand the need but it requires some work.

I think the thing that you want is to distinguish the erros (Syntax, errors coming from DTD rules, etc). A thing that we can try is to use the source information of the reported diagnostic. Today source is xml:

image

which is not relevant. We could have:

  • XML.Syntax: XML errors syntax
  • XML.DTD : XML errors coming from DTD rules
  • DTD.Syntax: DTD errors syntax (when you open the DTD)
  • ...

After that you could use filter from the Problems vscode view

image

You can click on view as table

image

you could see better the code:

image

What do you think about this idea?

@angelozerr
Copy link
Contributor

My students and me were very grateful.... ;)

Glad vscode-xml please you :)

@ejgutierrez74
Copy link
Author

F

Would it possible to make two different instructions: one to test if a xml file is well formed and other to validate it against DTD file.

If I understand your need you would like to validate:

* only XML syntax

* XML syntax + errors coming from DTD rules

* XML syntax + errors coming from XSD rules

with separate commands?

To learn XML I can understand the need but it requires some work.

For example XML Copy Editor has two instructions/commands : one to test if an xml file is well formed and other to test if is valid against a DTD.

This is an example:
imagen

As you can see, is in spanish but dont difficult to understand:
F2 Check xml file is well formed
F5 Check if is valid against DTD

Also there is the online resource i told you https://www.xmlvalidation.com/ that does the work this way...separating things.

About checking if a DTD file is correct, i havent seen any place to test it. I found the DTD language grammar, but dont know any online or software resource that checks it ( i havent tested any payment software have to say). So If its included ok, but for me/students not strictly necessary.

@ejgutierrez74
Copy link
Author

I think the thing that you want is to distinguish the erros (Syntax, errors coming from DTD rules, etc). A thing that we can try is to use the source information of the reported diagnostic. Today source is xml:

image

which is not relevant. We could have:

* XML.Syntax: XML errors syntax

* XML.DTD : XML errors coming from DTD rules

* DTD.Syntax: DTD errors syntax (when you open the DTD)

* ...

After that you could use filter from the Problems vscode view

image

You can click on view as table

image

you could see better the code:

image

What do you think about this idea?

Id have to try when new pre-release is out with my students..but as said in previous post, not the best solution for me, but better than the one we have now.

Dont know the work it requires, but many resources do this way, so i suppose is not a very complicated solution.

@angelozerr
Copy link
Contributor

F5 Check if is valid against DTD

This command exists with Revalidate current XML file command.

F2 Check xml file is well formed

We should provides a new command Revalidate only XML syntax from the current XML file

About checking if a DTD file is correct, i havent seen any place to test it.

vscode-xml provides a DTD validator, no?

Id have to try when new pre-release is out with my students..but as said in previous post, not the best solution for me, but better than the one we have now

For the moment there are nothing about that, the screenshot is the current version. My idea is to replace xml with XML.Syntax, XML.DTD and after that you could use filter. This problem view comes from vscode and there are no way to customize it.

@angelozerr angelozerr self-assigned this Nov 17, 2023
@angelozerr angelozerr added the enhancement New feature or request label Nov 17, 2023
@angelozerr angelozerr added this to the 0.27.0 milestone Nov 17, 2023
angelozerr added a commit to angelozerr/lemminx that referenced this issue Nov 17, 2023
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Nov 17, 2023
angelozerr added a commit to angelozerr/vscode-xml that referenced this issue Nov 17, 2023
@ejgutierrez74
Copy link
Author

ejgutierrez74 commented Nov 17, 2023

F5 Check if is valid against DTD

This command exists with Revalidate current XML file command.

Then id suggest to change the name of the command because its a little confusing. Term revalidate is confusing and "xml file" suggests that you are validating again a file against whatever ( dont know) but xml file suggests some xml file validation...
So id feel more comfortable with something like Check valid against DTD and other order or command Check valid against XSD.

F2 Check xml file is well formed

We should provides a new command Revalidate only XML syntax from the current XML file

Then id suggest to change the name of the command because its a little confusing....i suppose for people with other mother language different than english. In my opinion should be Check xml file is well-formed ( as XML Copy Editor and other validators has). It confuses with validation against a DTD or XSD file. Id put Check well formed or Check XML file is well formed.

About checking if a DTD file is correct, i havent seen any place to test it.

vscode-xml provides a DTD validator, no?

If it has i dont know...how can you test if a DTD file syntax is correct or not ?
As said i dont know any software or online application that does that.

Id have to try when new pre-release is out with my students..but as said in previous post, not the best solution for me, but better than the one we have now

For the moment there are nothing about that, the screenshot is the current version. My idea is to replace xml with XML.Syntax, XML.DTD and after that you could use filter. This problem view comes from vscode and there are no way to customize it.

Perhaps if we divide into different commands as mentioned would be easier for me/my students and general people. And dont get a mixed problems console.

If I understand your need you would like to validate:

only XML syntax
XML syntax + errors coming from DTD rules
XML syntax + errors coming from XSD rules

with separate commands?

Yes if not would be confusing specially with noobs or people beginning to learn xml, dtd, xsd...
Then in the future would come to check against XSLT ;)

@angelozerr
Copy link
Contributor

angelozerr commented Nov 17, 2023

Then id suggest to change the name of the command because its a little confusing. Term revalidate is confusing and "xml file" suggests that you are validating again a file against whatever ( dont know) but xml file suggests some xml file validation...
So id feel more comfortable with something like Check valid against DTD and other order or command Check valid against XSD.

Having several command will be hard (or require some more work) because vscode doesn't know that XML is bound to an XSD, DTD, etc, so we should keep one command like Check valid against DTD/XSD/RelaxNG.

@fbricon @datho7561 what do you think about this suggestion?

Then id suggest to change the name of the command because its a little confusing....i suppose for people with other mother language different than english. In my opinion should be Check xml file is well-formed ( as XML Copy Editor and other validators has). It confuses with validation against a DTD or XSD file. Id put Check well formed or Check XML file is well formed.

@fbricon @datho7561 what do you think about this suggestion?

If it has i dont know...how can you test if a DTD file syntax is correct or not ?

Open DTD file and you will see errors (or the first error).

Perhaps if we divide into different commands as mentioned would be easier for me/my students and general people. And dont get a mixed problems console.

Ok

angelozerr added a commit to angelozerr/lemminx that referenced this issue Nov 17, 2023
@datho7561
Copy link
Contributor

We should provides a new command Revalidate only XML syntax from the current XML file

In my opinion should be Check xml file is well-formed

I don't think we should add a command to check if the XML document is well formed. We check whether the current file is well-formed when you first open it, and check again whenever it changes. There should be no reason to manually retrigger the syntax validation.

we should keep one command like Check valid against DTD/XSD/RelaxNG.

yes, I agree with this. Maybe we could rename the command something like "Revalidate current XML file against schema (DTD, XSD, RelaxNG)"

And dont get a mixed problems console.

Using the command to run schema (DTD, XSD, RelaxNG) validation won't prevent mixing errors in the error panel. This is because schema validation is run when you first open the file and whenever you change the file. I believe that filtering the errors based on the error code as Angelo described in this comment is the best way to separate the errors related to the document being malformed and the errors related to the document not repecting the schema.

@ejgutierrez74
Copy link
Author

We should provides a new command Revalidate only XML syntax from the current XML file

In my opinion should be Check xml file is well-formed

I don't think we should add a command to check if the XML document is well formed. We check whether the current file is well-formed when you first open it, and check again whenever it changes. There should be no reason to manually retrigger the syntax validation.

we should keep one command like Check valid against DTD/XSD/RelaxNG.

yes, I agree with this. Maybe we could rename the command something like "Revalidate current XML file against schema (DTD, XSD, RelaxNG)"

And dont get a mixed problems console.

Using the command to run schema (DTD, XSD, RelaxNG) validation won't prevent mixing errors in the error panel. This is because schema validation is run when you first open the file and whenever you change the file. I believe that filtering the errors based on the error code as Angelo described in this comment is the best way to separate the errors related to the document being malformed and the errors related to the document not repecting the schema.

Please change the syntax:

  • Document that you only have to open the xml file with vscode-xml extension enabled to check if an xml file is well formed.
  • Also assume that the same happens with DTD files. You open it and it tells you if there is some error (or at least first one, would be great to show all the errors).
  • Validate against DTD/XSD perhaps XSLT in the future...no revalidate... revalidate is a word only read here.
  • As said most of software like XMLCopyEditor, online validators, separates the well formed docuement vs valid ( not revalid) against DTD or XSD file.

Using the command to run schema (DTD, XSD, RelaxNG) validation won't prevent mixing errors in the error panel.

Usually you first check if xml file is well formed, and then check if its valid. Thats the reason why i asked for two different instructions. As most other validators does.

Thank for your work and effort

@angelozerr
Copy link
Contributor

@ejgutierrez74 we dont control the validation process. Xerces load the DTD and the XML syntax is done in same time than the check XML follows DTD rules.

It seems that your invalid DTD sample crashes this process because it seems that there is à bug in Xerces himself and in this case XML syntax cannot be done but it should. We cannot do nothing except reporting this bug to Xerces project which seems not be very activate.

@ejgutierrez74
Copy link
Author

@ejgutierrez74 we dont control the validation process. Xerces load the DTD and the XML syntax is done in same time than the check XML follows DTD rules.

It seems that your invalid DTD sample crashes this process because it seems that there is à bug in Xerces himself and in this case XML syntax cannot be done but it should. We cannot do nothing except reporting this bug to Xerces project which seems not be very activate.

dont want to critic your work, just want to understand, why as said xml validators online and xmlcopy editor, and think notepadd++ can separate the instructions and vscode-xml not...Suppose all works in a similar way...

@ejgutierrez74
Copy link
Author

Open DTD file and you will see errors (or the first error).

Perhaps if we divide into different commands as mentioned would be easier for me/my students and general people. And dont get a mixed problems console.

I tried it seems it works....is possible to show all errors or only the first one ?
This should be documented or put in README, just to notice to noobies that when you open xml or dtd file, are tested by default ( xml file that is well formed and dtd that the syntax is correct)

Thanks

@angelozerr
Copy link
Contributor

I tried it seems it works....is possible to show all errors or only the first one ?

It depends if it is a fatal error or not. Your sample with your invalid DTD report a fatal error and in this case the validation stops. We could avoid stopping the validation process when a fatal error occurs to have several errors but the main problem with this strategy is that Xerces can reports a lot of errors which are not relevant because errors depends from the fatal error. Once the fatal error is fixed, the other errors could disapear.

IMHO I think this strategy is annoying because you could try to fix some errors after the fatal error but the fix could not be corrected when you will fix the fatal error.

@angelozerr
Copy link
Contributor

A thing that we could do is to provide a settings like xml.validation.stopOnFatalError which could be set to true by default (to have the current behavior) and you could set to false to report several errors (which could be not relevant).

@ejgutierrez74
Copy link
Author

In my opinion is not important, but again has to be documented and noticed...that there is that option, but DTD validation stops with the first fatal error....perhpas print fatal error in a some kind of highlighting or remark.

Thanks for your work

@angelozerr
Copy link
Contributor

In my opinion is not important, but again has to be documented and noticed...that there is that option

This option doesn't exists, we need to implement it.

@ejgutierrez74
Copy link
Author

Sorry for my bad english...id try to explain myself better. In my opinion is not important but again has to be documented and noticed. Be clear that only shows one error in case its Fatal one, and once is fixed you can continue fixing other possible errors...

...if finally you implement this option, also should be clear that this option exists and what is by default.

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
3 participants