I have a CommonTypes.xsd which I'm including in my all other XSDs using xs:include. I get
Multiple <schemaBindings> are defined for the target namespace ""
when I try to compile it into different packages using binding files. Please tell me whether there is a way to compile them into different packages. I'm using jaxb 2.1
I know it is an old post, but, as there is no answer for the exact question, here is my proposal:
As mmoossen explained, the trick is to specify different namespaces for the XSDs. But, adding a
namespace
attribute in thejxb:bindings
tag doesn't work:Instead of that, you need to add a
targetNamespace
attribute to thexs:schema
tags of your XSDs:Once done, you will be able to have 1 external customization file (.xjb) declaring different
schemaBindings
, each of them possibly using a different package:I've meet the same problem and haven't solve it yet, but I'm afraid that it can't be possible to generate XSD into differents packages :
from Compiler Restrictions at the end of this page
but if some one find some work around, just inform us please
As stated already by Ben there is no way to do that if they have the same namespace. But how to do it if you do have different namespaces?
but be sure you do not use the command line parameter -p, since that will override your config.
Can be done as mentioned in jaxb maven plugin usage page in case of having Multiple schemas with different configuration.
Separate packages can be configured for each schema.
complete example configuration below:
Yeah, there is a way.
Assuming:
In the common directory place
common.xjb
:In the foo directory place
foo.xjb
:In the
build.xml
file, create one xjc task for each:You need to make sure that
common.xsd
has atargetNameSpace
that is different fromfoo.xsd
'stargetNameSpace
.