users@jaxb.java.net

Re: Bug or not: trying to use seperate schema compilation using maven-jaxb2-plugin

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Thu, 15 Aug 2013 08:07:53 +0200

Hi Rogier,

I think, your reasoning is quite correct. To note, this is not a bug
in the maven-jaxb2-plugin, it is more a problem with XJC itself.
maven-jaxb2-plugin only wraps XJC.

I'm also coming over this issue time after time. I always managed to
resolve it somehow, but I can't formulate the method at the moment.
Would you please put a sample demo project together - I'll look into
it. We'll probably have to file an issue for XJC since I don't think
this can be fixed in the Maven plugin.

Bye,
/lexi


On Wed, Aug 14, 2013 at 3:33 PM, Rogier Enders <rogier.enders_at_gmail.com> wrote:
> Hi Valikov,
>
> I'm trying to generate sources from a set of xml schemas using the
> "maven-jaxb2-plugin" version 0.8.3.
>
> The schemas refer to each other using an import with a namespace and a
> schemaLocation attibute. The schemaLocation attribute is relative.
>
> Using a catalog file (in XML format, Oasis Catalog standard version 1.1) I
> managed to change the schemaLocation using a systemSuffix to an uri
> reference resource inside a Maven artifact.
>
> First: schema A sources are generated using the plugin without any
> configuration. The jar is uploaded to the maven repository.
>
> Schema B sources are generated using the pluging. The A.jar is defined as a
> dependency and useDependenciesAsEpisode is set to true. There is also a
> catalog parameter with a systemSuffix. This jar is also uploaded to the
> maven repository.
>
> All works well for schema B which imports schema A with a relative
> schemaLocation, using episodes.
>
> Now I'm trying to generate sources for a schema C which import B and A. This
> results in the following error:
> "[ERROR] Error while parsing schema(s).Location [
> jar:file:/home/rogier/.m2/repository/nl/renders/address-rel/1.0/address-rel-1.0.jar!/address.xsd{9,13}].
> org.xml.sax.SAXParseException: 'address' is already defined"
>
> It seams like the plugin is generating sources for schema C, since this
> schema imports B and A, sources are also generated for these schemas but
> since B imports A, it tries to generate another set of sources for schema A
> which results in the error "is already defined".
>
> If I remove the schemaLocation attrinute from the XSD schema in the
> generated B.jar, it works well since the sources from schema A are only
> generated once.
>
> Is this a bug in the plugin or am I missing something here? If you like I
> can send to some sources to reproduce the problem.
>
> With regards,
>
> Rogier Enders