users@jaxb.java.net

Common Type in xs:include

From: Martin Lemanski <Martin.Lemanski_at_gmx.at>
Date: Wed, 26 Jun 2013 16:36:11 +0200 (CEST)

Hi,

I’m having multiple xsd with different namespaces. For each xsd a seperate package and class is generated. There is another xsd which is referenced and reused by the previous ones. This xsd's doesn’t have a namespace. So the class is generated multiple times into each namespace package.
Now my problem is that I’m having mutiple classes representing the same datastructure and I can’t reuse it in my Java code as I do in the xml and xsd files. But it should be generated just once and the package name doesn't matter for me.

I already searched google and your mailing list archive, but I couldn't find anything that could help me.
 
My requirements are:
1.) I can’t change the existing XSD Schema files, because they used by an external legacy system. (changes are expensive, need to be testet, ...)
2.) I want to generate the Java classes continuously via our build process I’m using Maven.
3.) Each Object type has it's own different namespace e.g. Article.xsd has the namespace "urn:someurl:XSD:Article/1", Order.xsd has the namespace "urn:someurl:XSD:Order/1":
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:someurl:XSD:Order/1" targetNamespace="urn:someurl:XSD:Order/1" elementFormDefault="qualified" version="01.00.00">
<xs:include schemaLocation="CurrencyAmount_Type.xsd"/>
...
4.) The Type Objects should be generated just once.

Currently the types don’t have a namespace and are referenced in multiple other XSDs i.e. Currency. XJB generates for each <xs:include schemalocation="CurrencyAmount_Type.xsd"> a CurrencyAmount_Type.java in each subpackage.
 
Is there a solution to solve this problem just by configuring my bindings.xjb file? Or do you have any other suggestions?


Cheers, Martin