Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

xjb multiple schema bindings with different packages

1,113 views
Skip to first unread message

Philipp Kraus

unread,
Aug 21, 2016, 3:32:28 PM8/21/16
to
Hello,

I try to build my first multible schema binding structure of a Jaxb structure. My first experience was only with one XSD, but in my current project I have got many XSD files.

I'm using the Maven plugin

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/xsd</schemaDirectory>
<schemaIncludes>
<include>**/*.xsd</include>
</schemaIncludes>
<bindingIncludes>
<include>**/*.xjb</include>
</bindingIncludes>
</configuration>
</plugin>


to translate the XSD to the Java classes and I store the XSD files like this
src/main/xsd/my/package/model.xsd
src/main/xsd/my/package/query.xsd

and the XJB file src/main/xsd/my/package/binding.xjb
The content of the is

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">


<jaxb:bindings schemaLocation="query.xsd">
<jaxb:schemaBindings>
<jaxb:package name="my.package.query"/>
</jaxb:schemaBindings>
</jaxb:bindings>

<jaxb:bindings schemaLocation="model.xsd">
<jaxb:schemaBindings>
<jaxb:package name="my.package.model"/>
</jaxb:schemaBindings>
</jaxb:bindings>

</jaxb:bindings>


but this does not not work, because of the multiple definition within the same target namespace.
If I remove one of the jaxb:bindings my XSD will be translated, but in this case one file will be translated only.

Can you please explain my, how the configuration of the XJB file must be correct, so that I can use my two XSD files?

Thanks

Phil
0 new messages