Skip to content

finish work on project-related XSD namespace resolution for XML language server #581

Open

Description

@martinlippert

Spring uses a specific lookup mechanism for XML namespace definition files that loads XSD files from projects instead of from the web using the URL. Support for this was implemented a long time ago for the (old) XML tooling in Eclipse (from the WTP project) as part of the Spring IDE and got extracted into a self-contained feature that got re-used as part of the Spring Tools 4 for Eclipse. That makes the project-based XSD namespace resolution work for the old WTP-based XML support in Eclipse.

For Spring Tools 4, we recently adopted the Wild Web Developer features to support working on modern web applications (see #354). As a side effect of adopting this new feature from Eclipse, the Eclipse-based IDEs now have two different sorts of XML support: the old one from WTP and a new one from Wild Web Developer, which is based on an XML language server (https://github.com/eclipse/lemminx).

A result of this side effect is that both tooling for XML now validates XML files by default. But the XML language server doesn't know anything about the project-related XSD namespace lookup mechanism that was implemented for the old WTP-based XML tooling, so that validation errors appear in certain cases (e.g. #447).

Therefore, we went ahead and implemented an extension to the XML language server, so that the XML language server can use the project-related XSD namespace lookup mechanism as well. In order to do that, we did:

The main implementation is at:
787aa0f

In order to make this work, a few more changes to other projects where necessary:

With that, the work is almost done. The two remaining items that need more work in order to ship this are:

  • the validation in the XML language server doesn't seem to take the specialized namespace resolver into account - or our implementation is too slow. The validation still happens super quickly after opening an XML file and shows wrong errors (based on non-project-related lookup) and that error doesn't go away.

  • content-assist works as soon as the initial lookup inside of the classpath of the project is done, but that takes way too long. Hitting content-assist for the first time typically shows wrong results (non-project-related lookup) or takes ages to populate. While this isn't a huge difference compared to the old implementation for the WTP-based XML tools, it feels way too slow for the modern world of language-server-based tooling.

This ticket tracks the work that is necessary to solve those two remaining issues.

Activity

  1. added this to the milestone on Jan 4, 2021
  2. BoykoAlex commented on Jan 18, 2021

    @BoykoAlex
    Contributor
  3. BoykoAlex commented on Jan 18, 2021

    @BoykoAlex
    Contributor

    @martinlippert I have linked my question to Angelo. He suggested to use resolveEntity(XMLResourceIdentifier resourceIdentifier) (it currently returns null, implementation can be added to https://github.com/spring-projects/sts4/blob/master/headless-services/xml-ls-extension/src/main/java/org/springframework/ide/vscode/xml/namespaces/ProjectClasspathUriResolverExtension.java)

    The XMLResourceIdentifier instance that the method takes as the parameter doesn't have the path to the file where the NS Uri has been encountered. Looks like the code gets into resolveEntity(XMLResourceIdentifier resourceIdentifier) before Uri resolver should have resolved the encountered NS Uri to projectaware:// uri already...

  4. modified the milestones: , 4.10.0.RELEASE on Feb 18, 2021
  5. removed this from the 4.13.0.RELEASE milestone on Dec 16, 2021
  6. added this to the 4.13.1.RELEASE milestone on Jan 19, 2022
  7. removed this from the 4.13.1.RELEASE milestone on Feb 2, 2022
  8. ykartsev commented on Oct 31, 2023

    @ykartsev

    Hi guys. I'm curious if this issue is still in plans or hit a serious blocker? I'm using STS 4.20 with Eclipse and still unable to work with XSD schemas from the JAR. Thank you.

    P.S.: I'm afraid to hear something like "everyone is using Java config", so this is not needed :) Hopefully, this is not the case.

  9. BoykoAlex commented on Nov 1, 2023

    @BoykoAlex
    Contributor

    I haven't looked at this for a while... but I vaguely recall hitting some kind of a problem that I wasn't able to resolve... I'd have to dig into it again to recall what the problem was exactly.

  10. BoykoAlex commented on Jan 3, 2025

    @BoykoAlex
    Contributor

    I've reanimated this work. Enabled XML LS extension and fixed a few things on our side and LSP4E to get it running again. So far looks like completion proposals are actually working now and do provide proposals specific to schema from the JAR. The validation, however, is still not working... Seems that Xerces parser needs some kind of an option to resolve the schema from NSURI or its location... The overall observation is that some ops with XML LS become very very slow at first but then once the schema is cached completion proposals becomes fast again.

  11. takeseem commented on Mar 6, 2025

    @takeseem

    非常希望能获得以前 sts3 的使用体验。虽然使用 @configuration 能做大多数事情,但是在使用第三方库时,没有复用需求,直接提供一个 common/app-3rd-components.xml 其中属性使用 ${注入属性},调用方使用@import(common/app-3rd-components.xml) 完成bean配置,比完整定义 Properties + Configuration 更加容易。

  12. martinlippert commented on Mar 6, 2025

    @martinlippert
    MemberAuthor

    @takeseem Can you elaborate in more detail what support in the tools exactly you are looking for? There is already quite some support for Spring XML config files included (don't forget to enable it in the preferences), so in case you were used to Spring Tool Suite 3, it would be good if you could describe in more detail what exactly you are missing and maybe attach a sample project that illustrates this.

  13. added
    for: eclipse
    on Mar 6, 2025
  14. takeseem commented on Mar 8, 2025

    @takeseem

    @martinlippert Thank you so much for your efforts. After giving it some thought, I realized that there isn't any essential feature I truly need—its current functionality is already sufficient for me. I sincerely appreciate the hard work of the STS team.

    Perhaps it's just nostalgia for the STS3 experience.

    The main issue is that when I installed the STS4 plugin on the Eclipse for Java edition, Spring bean XML files were opened with the default XML editor. However, yesterday I install the standard STS4 app and found that they should be opened with the generic code editor instead.

    Please forgive me for the above content from machine translation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

for: eclipsestatus: assignedtheme: xml-support

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions