redhat-developer / vscode-xml

Editing XML in Visual Studio Code made easy
Eclipse Public License 2.0
253 stars 78 forks source link

Cache completion based on XML Schema/DTD #172

Closed arkceajin closed 4 years ago

arkceajin commented 5 years ago

settings.json:

{
    "xml.java.home": "C:\\Program Files\\java-1.8.0-openjdk-1.8.0.212-3.b04.redhat.windows.x86_64",
    "xml.catalogs": ["file:///C:/Users/s-jiu/Desktop/AP-R19-03/MethodologyAndManifests/AUTOSAR_MMOD_XMLSchema/AUTOSAR_00047.xsd"],
    "xml.fileAssociations": [{
        "systemId": "file:///C:/Users/s-jiu/Desktop/AP-R19-03/MethodologyAndManifests/AUTOSAR_MMOD_XMLSchema/AUTOSAR_00047.xsd",
        "pattern": "*.arxml"
    }]
}

arxml:

<?xml version="1.0" encoding="UTF-8"?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00047.xsd">
 ...
</AUTOSAR>

How to set the xsi:schemaLocation and "systemId" to making the xsd relate to the arxml?

angelozerr commented 5 years ago

You are using fileAssociation and XML catalog both. You must choose your binding kind.

I suggest you that you attach in this issue a zip of your vscode project.

arkceajin commented 5 years ago

I suggest you that you attach in this issue a zip of your vscode project.

The project only contain a arxml which I going to create by using the xsd. xsd: https://github.com/autosaros/Standards/blob/master/Adaptive%20Platform/19.03/MethodologyAndManifests/AUTOSAR_MMOD_XMLSchema/AUTOSAR_00047.xsd

I tried create the xml and put in the same folder with xsd.

<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <uri name="http://autosar.org/schema/r4.0 AUTOSAR_00047.xsd" uri="file://./AUTOSAR_00047.xsd" />
</catalog>

But still not working...

angelozerr commented 5 years ago

@arkceajin at first vscode-xml doesn't support *.arxml I suggest you to rename to .xml file.

@fbricon @NikolasKomonen @xorye do you know if it's possible to customize this file extension by user?

If it doesn't work, @arkceajin please share your vscode project. Your error could come from your settings.json for instance if the catalog path is not good.

fbricon commented 5 years ago

arxml and xsd files in the same folder, it works for me, but it's very slow, as the xsd is over 7MB. I increased the memory attributed to lsp4xml to 256MB in settings.json:

"xml.server.vmargs": "-noverify -Xmx256m -XX:+UseG1GC -XX:+UseStringDeduplication -Dlog.level=off",
Screen Shot 2019-07-19 at 12 16 03 PM
angelozerr commented 5 years ago

but it's very slow

If I remember, today when XSD file is on the local, it is parsed every time:

It should be improved by caching the XSD.

arkceajin commented 5 years ago

@fbricon Thanks, using the setting and without xml.catalogs simply put XML and XSD in the same folder could work well. So the problem is just the loading was too slow...

angelozerr commented 5 years ago

So the problem is just the loading was too slow...

You mean that completion based on XML Schema to show in completion INTRODUCTION, FORMULA, etc is slow?

arkceajin commented 5 years ago

@angelozerr Yes, after specific "xml.server.vmargs": "-noverify -Xmx256m -XX:+UseG1GC -XX:+UseStringDeduplication -Dlog.level=off", the completion popup almost immediately.

angelozerr commented 5 years ago

@arkceajin just to clarify this issue:

Is that?

arkceajin commented 5 years ago

Not nothing but sometimes popup Loading or sometimes popup dialog doesn't contain the completions as below: err

Correct completions: image

angelozerr commented 5 years ago

Thanks @adelasofia for your feedback. I'm working on this issue https://github.com/angelozerr/lsp4xml/issues/547

angelozerr commented 4 years ago

@arkceajin I fixed this issue in https://github.com/angelozerr/lsp4xml/issues/547 Now completion should be slow the first time and quick after. This feature is available for 0.9.0