Since JiBX allows generation of code into different java packages, JiBX is the best choice if you want to split a large schema into smaller OSGi modules.
Here is a sample pom.xml for a base schema:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jibx.test.simplewebschema</groupId>
<artifactId>simple-web-schema-test</artifactId>
<version>1.4.2</version>
</parent>
<artifactId>org.jibx.schema.person</artifactId>
<packaging>bundle</packaging>
<name>simple-web-schema-person</name>
<build>
<plugins>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.4.2</version>
<executions>
<execution>
<id>generate-java-code-from-schema</id>
<goals>
<goal>schema-codegen</goal>
</goals>
</execution>
<execution>
<id>compile-binding</id>
<goals>
<goal>bind</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLocation>http://www.jibx.org/sampleschema/</schemaLocation>
<includeSchemas>
<includeSchema>person.xsd</includeSchema>
</includeSchemas>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>META-INF/binding.xml=${basedir}/target/generated-sources/binding.xml</Include-Resource>
<Export-Package>org.jibx.schema.jibx-maven-plugin.*;version=1.4.2</Export-Package> <!-- Override jibxPackage or jibxPackageExport with actual packages -->
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>Here is the sample:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jibx.test.simplewebschema</groupId>
<artifactId>simple-web-schema-test</artifactId>
<version>1.4.2</version>
</parent>
<artifactId>org.jibx.schema.address</artifactId>
<packaging>bundle</packaging>
<name>simple-web-schema-address</name>
<build>
<plugins>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.4.2</version>
<executions>
<execution>
<id>generate-java-code-from-schema</id>
<goals>
<goal>schema-codegen</goal>
</goals>
</execution>
<execution>
<id>compile-binding</id>
<goals>
<goal>bind</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLocation>http://www.jibx.org/sampleschema/</schemaLocation>
<includeSchemas>
<includeSchema>address.xsd</includeSchema>
</includeSchemas>
<includeBaseBindings>
<includeBaseBinding>
<groupId>org.jibx</groupId>
<artifactId>org.jibx.schema.person</artifactId>
<directory>META-INF</directory>
<includes>
<include>binding.xml</include>
</includes>
</includeBaseBinding>
</includeBaseBindings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>META-INF/binding.xml=${basedir}/target/generated-sources/binding.xml</Include-Resource>
<Export-Package>org.jibx.schema.jibx-maven-plugin.*;version=1.4.2</Export-Package> <!-- Override jibxPackage or jibxPackageExport with actual packages -->
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>org.jibx.schema.person</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-run</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-extras</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
</project>Note: This module includes the base module as a dependency AND the schema-codegen goal points to the base binding file.