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

Invalid "schemaLocation" is not reported #1143

Closed
WolfgangHG opened this issue Jan 1, 2022 · 13 comments
Closed

Invalid "schemaLocation" is not reported #1143

WolfgangHG opened this issue Jan 1, 2022 · 13 comments
Milestone

Comments

@WolfgangHG
Copy link

WolfgangHG commented Jan 1, 2022

I first created https://bugs.eclipse.org/bugs/show_bug.cgi?id=578009 and was pointed here:

The new LanguageServer based validation in Eclipse does not report errors when a xml file has an invalid schemaLocation.

This is a valid XML file:

<application xmlns="https://jakarta.ee/xml/ns/jakartaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/application_9.xsd">
	
	<invalid>
	</invalid>
</application>

Two errors are reported in this file (missing attribute "version" on root element, the child element "invalid" is invalid).

Now, change anything in the schemaLocation URI to make it invalid:

<application xmlns="https://jakarta.ee/xml/ns/jakartaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/application_9.xsdaaaaaaaa">
	
	<invalid>
	</invalid>
</application>

Here, no error at all is shown for this file.

I would expect a message "schema location xyz could not be resolved" or similar.

@WolfgangHG
Copy link
Author

WolfgangHG commented Jan 2, 2022

The issue also arises for local paths, so that it is not a matter of the 404 error when requesting the XSD:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="https://jakarta.ee/xml/ns/jakartaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee file:///C:/Temp/wildfly-26.0.0.Final/docs/schema/application_9.xsdaaa">
	<invalid>
	</invalid>
</application>

@angelozerr
Copy link
Contributor

It should report an error but with warning severity.

@angelozerr
Copy link
Contributor

@WolfgangHG you are right, there were a bug. I have fixed in #1155 I refactor a lot of thing with the download process and now it should work:

image

We plan to do a release soon, after that WWD will adopt it.

//cc @mickaelistria

@WolfgangHG
Copy link
Author

I don't see this warning when using Eclipse 2022-6, the original problem is still present. Is the fix contained in this version?

@angelozerr
Copy link
Contributor

Which version of WWD are you using?

@angelozerr
Copy link
Contributor

I suggest that you install last version of WWD https://github.com/eclipse/wildwebdeveloper/releases/tag/0.15.0

@WolfgangHG
Copy link
Author

I downloaded the windows version from https://download.eclipse.org/wildwebdeveloper/releases/latest/IDEs/, but also here this issue still happens.
I am not sure about the version numbers, but the plugin "Eclipse Wild Web Developer project - XML support using Language Server" has version 0.15.0.202207081036.
I assume LemMinx 0.18.3 or newer is required? How can I check this version?

@angelozerr
Copy link
Contributor

angelozerr commented Aug 8, 2022

Ok let me some time to retry again with WWD 0.15 to see what it happens.

@angelozerr
Copy link
Contributor

How can I check this version?

I fear it is not possible. with UI, but you can know that if you open the git.properties from the given JAR:

image

You should see in this file:

git.build.version=0.21.0

@angelozerr
Copy link
Contributor

You need to set Enable schema based validation to Always :

image

After that you should see:

image

@mickaelistria @vrubezhny is there any reason that Enable schema based validation is not set by default to Always? In vscode-xml we have that.

@WolfgangHG
Copy link
Author

But shouldn't a warning be reported always if a schemaLocation is defined and the file cannot be resolved, in in mode "In valid schema"? This would probably be a "bug" in the declaration?

What does the setting "Always" mean? I see that an error about an undefined "jboss-web" element is reported in my sample. This error does not come if the schemaLocation is removed and the xml file is schemaless. So it tries to validate files where it cannot resolve the XSD or the XSD contains errors?

By the way (sorry, might be a new issue - I can create another one if you consider it a bug): when switching to "Always", the "system-catalog.xml" file that was generated from the "JBoss Tools" plugin entries, shows validation errors for DTD files:
catalogvalidation

cvc-pattern-valid: Value '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' is not facet-valid with respect to pattern '[a-zA-Z0-9\-'\(\)+,./:=?;!*#@$_%]*' for type 'publicIdentifier'.

It seems the space is missing in the RegEx?

@angelozerr
Copy link
Contributor

But shouldn't a warning be reported always if a schemaLocation is defined and the file cannot be resolved, in in mode "In valid schema"? This would probably be a "bug" in the declaration?

I suggest that you create an issue for that to discuss about that but I dont know if it is easy to implement your suggestion beczuse it is the behavior of xerces.

What does the setting "Always" mean? I see that an error about an undefined "jboss-web" element is reported in my sample. This error does not come if the schemaLocation is removed and the xml file is schemaless. So it tries to validate files where it cannot resolve the XSD or the XSD contains errors?

If you remove shemaLocation your xml is not validated by a xsd, (except if the xml defined à namespace which matche a catalog entry).and you have only syntax error. Always is just when you define a schemaLocation.

By the way (sorry, might be a new issue - I can create another one if you consider it a bug):

Please create an issue but it seems the problem comes from the xsd or dtd catalog.

@WolfgangHG
Copy link
Author

New issue #1272 created for the schemaLocation validation and eclipse-wildwebdeveloper/wildwebdeveloper#847 for catalog validation (don' know whether it is an lemminx or wildwebdeveloper issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants