Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing an xsd with imported schemas from dependencies in Eclipse

I have a maven project A with an /xsd/a.xsd in it's classpath. I also have the project B with an /xsd/b.xsd that refers to /xsd/a.xsd through a catalog entry. The catalog entry looks like this:

PUBLIC "http://foo.org/a" "maven:org.foo:a:jar::!/xsd/a.xsd"

Note the maven protocol in the url. The catalog is used by the org.jvnet.jaxb2.maven2:maven-jaxb22-plugin to generate the JAXB annotated Java classes with episodes from dependencies.

Everything is good so far.

Now I would like to edit /xsd/b.xsd in Eclipse. Eclipse report a warning on:

<xsd:import namespace="http://foo.org/a" />

as it cannot find the /xsd/a.xsd without a schemaLocation attribute. Eclipse does not recognize the catalog entry defined above.

The workaround found is to add a catalog entry in Eclipse / Window / Preferences / XML / XML Catalog:

PUBLIC "http://foo.org/a" "jar:file:/home/alain/maven/repository/org/foo/a/1.0-SNAPSHOT/a-1.0-SNAPSHOT.jar!/xsd/a.xsd"

Note the reference to my local repository (maven is a link to .m2) and to a specific version of the dependent project a.

Anyone having faced this issue and found a better workaround?

like image 247
agilbert Avatar asked Aug 08 '13 16:08

agilbert


1 Answers

The Best I can come up with is :

  • extract the xsds of the jar in the project with maven-dependency-plugin:unpack

  • reference the xsds from here in Eclipse / Window / Preferences / XML / XML Catalog.

At least there will be no reference to local path/version.

Note that if you have already a catalog for jaxb, it is possible to import it directly in eclipse, without having to edit one by one (Via import menu, not in XML Catalog).

like image 137
user2189998 Avatar answered Oct 19 '22 15:10

user2189998