eclipse-wildwebdeveloper / wildwebdeveloper

Simple and productive Web Development Tools in the Eclipse IDE
https://projects.eclipse.org/projects/tools.wildwebdeveloper
Eclipse Public License 2.0
189 stars 70 forks source link

XML catalog contribution from plugin #1078

Closed blasss closed 1 year ago

blasss commented 1 year ago

We develop a Eclipse plugin that contributes XML schemas to the XML catalog using the extension point org.eclipse.wst.xml.core.catalogContributions.

The XML schema documents are packaged with the plugin and thus use a relative URI to reference the files. What is special about the schema documents is that they use include-elements [https://www.w3.org/TR/xmlschema11-1/#compound-schema] to assemble multiple schema documents. The additional schema documents are as well packaged with the plugin and are referenced relative.

In contrast to the XML editor of WTP this doesn't work with the XML editor of wild web developer. The editor complains about errors in the schema document, where the number of errors correlates with the number of include-elements.

I could already track this down to the fact that the system catalog (<workspace>\.metadata\.plugins\org.eclipse.wildwebdeveloper.xml\system-catalog.xml) contains a reference to the schema document that is extracted from the plugin (somewhere like <eclipse-installation>/configuration/org.eclipse.osgi/14/0/.cp/de/foo/schema.xsd). Unfortunately the referenced schema documents are not extracted at all and therefore the relative references can't be resolved.

With further investigation it became evident that this is related to the use of FileLocator.toFileURL(URL) to resolve URIs that are not of file-scheme. The method is used in resolveURI(IConfigurationElement() of org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs, which is called by getWTPExtensionCatalog(). As denoted in JavaDoc the contents might be extracted to a cache in the file system. This seems to be the case for URIs to plugins without further resolving.

From a users perspective the use of include-elements in a schema document is perfectly fine and therefore this should be supported by the XML editor.

A possible fix I can think of might be resolving the URI to a native java protocol (FileLocator.resolve(URL)) and passing the schema document in its original location. The resolving should yield a jar-URI which should be perfectly fine for any java process.

Another more extensive option would be to scan the schema documents and include the referenced files in the cache as well.

blasss commented 1 year ago

Error in XML editor of wild web developer: ca0eb383-b170-4be5-841b-e54434f930ff

mickaelistria commented 1 year ago

Your analysis of the cause of the issue seems correct. Please consider submitting a pull request that fixes it.

vrubezhny commented 1 year ago

@blasss @mickaelistria After the commits is merged, can we consider the issue fixed?

mickaelistria commented 1 year ago

No objection to close.

vrubezhny commented 1 year ago

Closing as resolved with https://github.com/eclipse/wildwebdeveloper/commit/1d7a22329569f209479c3ddb1c0c2de192dcd6c9