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

Completion doesn't use file cache for included XML schema. #570

Merged
merged 1 commit into from
Oct 11, 2019

Conversation

angelozerr
Copy link
Contributor

Completion doesn't use file cache for included XML schema.

Signed-off-by: azerr [email protected]

@fbricon
Copy link
Contributor

fbricon commented Oct 8, 2019

any tests?

@angelozerr
Copy link
Contributor Author

angelozerr commented Oct 8, 2019

The PR fix is to check if the resolved uri (and not the uri) is an http uri to use the cache. See https://github.com/angelozerr/lsp4xml/pull/570/files#diff-3560eeb4e3d41113ab9ad5a099e6de95L139

This bug was introduced in 0.9.0 and problem comes from when XML schema include other XML schema (writing test is hard). I notice this problem when I try to understand the problem with redhat-developer/vscode-xml#183

To test this PR remove the .lsp4xml cache at hand and write a XML file like this:

<IODevice xmlns="http://www.io-link.com/IODD/2010/10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.io-link.com/IODD/2010/10 http://www.io-link.com/IODD/2010/10/IODD1.1.xsd">
</IODevice>

It will download the XML Schema http://www.io-link.com/IODD/2010/10/IODD1.1.xsd and some included XML schema but there will have an error with xml.xsd file to download

It's because the included XML schema https://io-link.com/IODD/2010/10/IODD-Primitives1.1.xsd include xml.xsd like this:

<xsd:schema xmlns="http://www.io-link.com/IODD/2010/10" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:iodd="http://www.io-link.com/IODD/2010/10" targetNamespace="http://www.io-link.com/IODD/2010/10" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.1">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>

It tries to download https://io-link.com/IODD/2010/10/xml.xsd although it doesn't exists. After that try to copy/paste https://github.com/angelozerr/lsp4xml/blob/master/org.eclipse.lsp4xml/src/main/resources/schemas/xsd/xml.xsd in the cache folder where IODD1.1.xsd was downloaded and relaunch the completion. Without this PR it continues to fail, with this PR it should download other XML Schema and have none error.

@angelozerr
Copy link
Contributor Author

any tests?

It's very hard to write tests. See the usecases that I explained below.

@angelozerr angelozerr added this to the v0.9.1 milestone Oct 9, 2019
@angelozerr angelozerr merged commit 8fff1ce into master Oct 11, 2019
@angelozerr angelozerr deleted the completion-cache branch October 17, 2019 13:20
@angelozerr angelozerr restored the completion-cache branch February 7, 2020 20:47
@angelozerr angelozerr deleted the completion-cache branch March 12, 2020 09:18
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

Successfully merging this pull request may close these issues.

2 participants