JPL-IMCE / gov.nasa.jpl.imce.oml

Ontology Modeling Language (OML) Workbench
14 stars 1 forks source link

Define an Eclipse UI validator to prevent building a project with multiple 'oml.catalog.xml' files #264

Open NicolasRouquette opened 6 years ago

NicolasRouquette commented 6 years ago

For the EMF-based OML API, OML defines an OASIS XML Catalog, oml.catalog.xml, for mapping OML IRIs to EMF Resource URIs (see EMF's URIConverter). With multiple oml.catalog.xml files, it is possible to break an important EMF invariant; specifically, that all EMF Resources in an EMF ResourceSet must have distinct URIs.

For example, consider an Eclipse project with the following folders and files:

./.project
./A
./A/oml.catalog.xml
./A/example.org/
./A/example.org/vocabulary.oml
./B
./B/oml.catalog.xml
./B/example.org/
./B/example.org/vocabulary.oml

where ./A/oml.catalog.xml and ./B/oml.catalog.xml have the same content:

<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
    <rewriteURI
            rewritePrefix="file:./"
            uriStartString="http://"/>
</catalog>

and where ./A/example.org/vocabulary.oml and ./B/example.org/vocabulary.oml have the same content:

open terminology <http://example.org/vocabulary> {
  // ... some OML terminology content ...
}

Outside of Eclipse, this situation is not a problem because OML APIs use a single catalog.

Inside of Eclipse, this situation can be problematic, particularly with the Eclipse UI where the nature of the project (in ./.project) includes 'Modeling' and 'Xtext'. When building this project, Eclipse will recognize the *.oml files and may load them in an EMF ResourceSet. If these files are loaded in the same ResourceSet, the invariant about EMF Resource URIs will be broken.

The effect of breaking this invariant manifests in strange errors like #261 and #262.