Editing an xsd with imported schemas from dependencies in Eclipse
Asked Answered
F

1

8

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?

Facelift answered 8/8, 2013 at 16:21 Comment(1)
Facing the same issue, but haven't found any better workaround. Also it's a PITA that you cannot even point directly to .m2 directory because of the dot.Incommunicable
A
1

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).

Ary answered 17/10, 2013 at 9:9 Comment(1)
extracting the .xsds defeats the point of having a catalog, then you wouldn't need the catalog at all. Also, even if you have a catalog for jaxb, you cannot import it to Eclipse if it contains a maven reference as Eclipse doesn't understand it.Incommunicable

© 2022 - 2024 — McMap. All rights reserved.