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

OpenQuoteExpected error for ATTLIST breaks DTD validation #943

Closed
ejgutierrez74 opened this issue Nov 11, 2023 · 24 comments · Fixed by eclipse-lemminx/lemminx#1599
Closed
Assignees
Labels
bug Something isn't working DTD validation
Milestone

Comments

@ejgutierrez74
Copy link

ejgutierrez74 commented Nov 11, 2023

Im trying to validate xml file against DTD file.
The problem is that vscode-xml only says that is an error in DTD file...no more info...and then is difficult to debug...

Captura desde 2023-11-11 13-04-23

But if you use a internet/online validator the info is much clearer ( for example https://www.xmlvalidation.com/ ):

imagen

or this:

Captura desde 2023-11-11 13-04-42

So im missing something ? is there any chance that vscode-xml should show a list of errors/warnings.like when you test if an xml file is well formed ? Would be really useful...

@angelozerr
Copy link
Contributor

Could you share your xml and ďtd files please.

@ejgutierrez74
Copy link
Author

Yes of course
For example these ones....many errors to debug...

bautistamonicaoriginal.zip

Also once corrected:

monicacorrected.zip

@ejgutierrez74
Copy link
Author

Also you can make something better with netbeans....
https://www.youtube.com/watch?v=DQpX9bns-d0

But id like to see all the errors at once generated, as vscode-xml do it when xml file is not well formed.
Seems that netbeans only shows the first error, at least is something better than this extension...

The better place i found is the online validator linked in previous post...

Thanks

@ejgutierrez74
Copy link
Author

Edited first post, because i uploaded the same image twice...No you can see at least two errors validating the xml against a DTD file...

@fbricon
Copy link
Collaborator

fbricon commented Nov 13, 2023

Testing your sample files, I found an error in the XML language server:

[Error - 14:12:17] Nov 13, 2023 02:12:17 org.eclipse.lemminx.extensions.dtd.participants.diagnostics.DTDValidator doDiagnostics()
Message: Unexpected DTDValidator error
java.lang.NullPointerException: Cannot invoke "org.eclipse.lemminx.dom.DOMAttr.getNodeAttrName()" because "attr" is null
	at org.eclipse.lemminx.utils.XMLPositionUtility.createAttrNameRange(XMLPositionUtility.java:217)
	at org.eclipse.lemminx.utils.XMLPositionUtility.selectAttributeNameAt(XMLPositionUtility.java:98)
	at org.eclipse.lemminx.extensions.contentmodel.participants.XMLSyntaxErrorCode.toLSPRange(XMLSyntaxErrorCode.java:286)
	at org.eclipse.lemminx.extensions.contentmodel.participants.diagnostics.LSPErrorReporterForXML.toLSPRange(LSPErrorReporterForXML.java:62)
	at org.eclipse.lemminx.extensions.xerces.AbstractReferencedGrammarLSPErrorReporter.toLSPRange(AbstractReferencedGrammarLSPErrorReporter.java:84)
	at org.eclipse.lemminx.extensions.xerces.AbstractLSPErrorReporter.internalToLSPRange(AbstractLSPErrorReporter.java:216)
	at org.eclipse.lemminx.extensions.xerces.AbstractLSPErrorReporter.reportError(AbstractLSPErrorReporter.java:91)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanAttDefaultDecl(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanAttlistDecl(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanDecls(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanDTDExternalSubset(Unknown Source)
	at org.apache.xerces.impl.dtd.XMLDTDLoader.loadGrammar(Unknown Source)
	at org.eclipse.lemminx.extensions.dtd.participants.diagnostics.DTDValidator.doDiagnostics(DTDValidator.java:60)
	at org.eclipse.lemminx.extensions.dtd.participants.diagnostics.DTDDiagnosticsParticipant.doDiagnostics(DTDDiagnosticsParticipant.java:53)
	at org.eclipse.lemminx.services.XMLDiagnostics.doExtensionsDiagnostics(XMLDiagnostics.java:67)
	at org.eclipse.lemminx.services.XMLDiagnostics.doDiagnostics(XMLDiagnostics.java:49)
	at org.eclipse.lemminx.services.XMLLanguageService.doDiagnostics(XMLLanguageService.java:190)
	at org.eclipse.lemminx.services.XMLLanguageService.publishDiagnostics(XMLLanguageService.java:204)
	at org.eclipse.lemminx.XMLTextDocumentService.validate(XMLTextDocumentService.java:716)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$validate$35(XMLTextDocumentService.java:691)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

@angelozerr
Copy link
Contributor

I tested now and I discover the same problem. @ejgutierrez74 vscode-xml should manage your DTD validation like you wished (show error detail instead of just 1 error) but it seems that we have a bug with your DTD

@angelozerr angelozerr added bug Something isn't working validation DTD labels Nov 13, 2023
@ejgutierrez74
Copy link
Author

Perhaps something related to #945 . vscode-xml could not detect or get the DTD file so it gives the first error....Just an idea...

Im a teacher of computer science in vocational education and this error has been reproduced by different students also

@ejgutierrez74
Copy link
Author

Testing your sample files, I found an error in the XML language server:

[Error - 14:12:17] Nov 13, 2023 02:12:17 org.eclipse.lemminx.extensions.dtd.participants.diagnostics.DTDValidator doDiagnostics()
Message: Unexpected DTDValidator error
java.lang.NullPointerException: Cannot invoke "org.eclipse.lemminx.dom.DOMAttr.getNodeAttrName()" because "attr" is null
	at org.eclipse.lemminx.utils.XMLPositionUtility.createAttrNameRange(XMLPositionUtility.java:217)
	at org.eclipse.lemminx.utils.XMLPositionUtility.selectAttributeNameAt(XMLPositionUtility.java:98)
	at org.eclipse.lemminx.extensions.contentmodel.participants.XMLSyntaxErrorCode.toLSPRange(XMLSyntaxErrorCode.java:286)
	at org.eclipse.lemminx.extensions.contentmodel.participants.diagnostics.LSPErrorReporterForXML.toLSPRange(LSPErrorReporterForXML.java:62)
	at org.eclipse.lemminx.extensions.xerces.AbstractReferencedGrammarLSPErrorReporter.toLSPRange(AbstractReferencedGrammarLSPErrorReporter.java:84)
	at org.eclipse.lemminx.extensions.xerces.AbstractLSPErrorReporter.internalToLSPRange(AbstractLSPErrorReporter.java:216)
	at org.eclipse.lemminx.extensions.xerces.AbstractLSPErrorReporter.reportError(AbstractLSPErrorReporter.java:91)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
	at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanAttDefaultDecl(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanAttlistDecl(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanDecls(Unknown Source)
	at org.apache.xerces.impl.XMLDTDScannerImpl.scanDTDExternalSubset(Unknown Source)
	at org.apache.xerces.impl.dtd.XMLDTDLoader.loadGrammar(Unknown Source)
	at org.eclipse.lemminx.extensions.dtd.participants.diagnostics.DTDValidator.doDiagnostics(DTDValidator.java:60)
	at org.eclipse.lemminx.extensions.dtd.participants.diagnostics.DTDDiagnosticsParticipant.doDiagnostics(DTDDiagnosticsParticipant.java:53)
	at org.eclipse.lemminx.services.XMLDiagnostics.doExtensionsDiagnostics(XMLDiagnostics.java:67)
	at org.eclipse.lemminx.services.XMLDiagnostics.doDiagnostics(XMLDiagnostics.java:49)
	at org.eclipse.lemminx.services.XMLLanguageService.doDiagnostics(XMLLanguageService.java:190)
	at org.eclipse.lemminx.services.XMLLanguageService.publishDiagnostics(XMLLanguageService.java:204)
	at org.eclipse.lemminx.XMLTextDocumentService.validate(XMLTextDocumentService.java:716)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$validate$35(XMLTextDocumentService.java:691)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

??What do you mean ? That the xml file is wrong ? Its well formed accorded to vs-code, xml-copy editor and netbeans....

@ejgutierrez74
Copy link
Author

I tested now and I discover the same problem. @ejgutierrez74 vscode-xml should manage your DTD validation like you wished (show error detail instead of just 1 error) but it seems that we have a bug with your DTD

Also if possible would be nice like XML Copy Editor, from Command Palette or whaever....one instruction to test if the xml file is well formed...and other to Validate XML. No seems that vs-code runs it all together.... Just a suggestion
Thanks for your work

@fbricon
Copy link
Collaborator

fbricon commented Nov 14, 2023

The NPE is a bug in the language server, we need to fix it. Hopefully, this should restore the DTD validation as you expect it.

Once the DTD bug is fixed, the validation should work OOTB, no need for a specific command. XML errors are visible in the problems view like:

Screenshot 2023-11-14 at 13 07 27

@angelozerr
Copy link
Contributor

@ejgutierrez74 indeed it is a bug from vscode xml. I plan to fix soon

@ejgutierrez74
Copy link
Author

But id

The NPE is a bug in the language server, we need to fix it. Hopefully, this should restore the DTD validation as you expect it.

Once the DTD bug is fixed, the validation should work OOTB, no need for a specific command. XML errors are visible in the problems view like:
Screenshot 2023-11-14 at 13 07 27

Thank you very much.
Would it possible or as i said make two different instructions: one to test if a xml file is well formed and other to validate it against DTD file.
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.

Hope this would be fix soon.
Thanks for your effort and work.

@angelozerr
Copy link
Contributor

Would it possible or as i said make two different instructions: one to test if a xml file is well formed and other to validate it against DTD file.
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.

I understand what you mean, please create a new issue for that and let this issue to fix your DTD bug.

Hope this would be fix soon.

I'm working on it now.

@angelozerr angelozerr changed the title Better DTD validation OpenQuoteExpected error for ATTLIST breaks DTD validation Nov 14, 2023
angelozerr added a commit to angelozerr/lemminx that referenced this issue Nov 14, 2023
angelozerr added a commit to angelozerr/lemminx that referenced this issue Nov 15, 2023
@angelozerr
Copy link
Contributor

angelozerr commented Nov 15, 2023

@ejgutierrez74 I have fied the bug and now you can see the error in XML:

image

if you click on the DTD error link bautistamonicaoriginal.dtd(5, 32), it opens the DTD file and you can see the error in the DTD file:

image

Is it the behavior that you expect?

Please note that XML syntax validation doesn't work if the DTD is not valid. I have not found a solution to fix it.

@ejgutierrez74
Copy link
Author

First of all thank you for your effort and work.

Second when can i test it ? New release ?

Third: for me not a bad solution, for me i dont know even if its possible, in the output/problems console put a list of all the validation errors, not just the first one ( just like when you test a xml file is well formed).

pd: i opened as you suggested a new issue regarding this, and i have answer you

@fbricon
Copy link
Collaborator

fbricon commented Nov 15, 2023

the DTD parser is not really fault tolerant, so you only get 1 DTD error at a time.

The fix will be available has a pre-release soon after it's merged

@angelozerr
Copy link
Contributor

We stop reporting dtd error when there are a fatal error coming from Xerces. It will avoid reporting bad errors once the first error is fixed.

angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Nov 15, 2023
@angelozerr angelozerr added this to the 0.27.0 milestone Nov 15, 2023
@angelozerr
Copy link
Contributor

@ejgutierrez74 once pre release build will be done (I think tomorrow), you will able to install pre release https://github.com/redhat-developer/vscode-xml#contributing to enjoy with the fix.

@angelozerr
Copy link
Contributor

@ejgutierrez74 is it working now with the pre release?

@ejgutierrez74
Copy link
Author

Lets say 50%:

imagen

imagen

imagen

And finally:

imagen

@angelozerr
Copy link
Contributor

angelozerr commented Nov 21, 2023

Your screenshot is about completion, we have not fixed that

This original issue was about DTD errors descriptions which was not displayed, now you can see the error (not only There is '1' error...) and click on the error to open the DTD file:

image

@ejgutierrez74
Copy link
Author

Oh sorry then its fixed...as far as i have tested these days...

@angelozerr
Copy link
Contributor

Great thanks for your feedback.

If there are no bugs you should see dtd error now in the description for other dtd écrous and you click on the link error to open the dtd file and jump to the proper location of the error.

@ejgutierrez74
Copy link
Author

Can i expect some new release with this fix near soon ?... Because in my institute we have a strict policy of manage software( students dont have admin permissions).. so one teacher have to install the software and extensions...
Would be nice that also the file detection was fixed.....just for asking i dont loose anything ;)

Thanks for your effort and work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DTD validation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants