I am using JIBX maven plugin to generate the Java classes from the XSD schema. Below are 2 different sample XML types one representing a customer and other representing an account. The address field is similar in both the schema. However codegen generates 2 separate Address classes (i.e. Address and Address1) because they belong to different namespaces. How can I make JIBX codegen generate a single class file and make them reuse across repeating structure. Provided the author of the schema does not provide a common type schema.
<customer xmlns="xyz.com/cust">
<cust_number>97767</cust_number>
<name>John Doe</name>
<address>
<street_name>1st Street</street_name>
<address_line1>Line 1</address_line1>
<address_line2>Line 2</address_line2>
<city>San Jose</city>
</address>
</customer>
<account xmlns="xyz.com/acc">
<acc_number>97767</acc_number>
<acc_type>CHK</acc_type>
<name>John Doe</name>
<address>
<street_name>1st Street</street_name>
<address_line1>Line 1</address_line1>
<address_line2>Line 2</address_line2>
<city>San Jose</city>
</address>
</account>
Technically, if a schema is in a different namespace, it is a different schema. JiBX doesn't have a way to fake a namespace using configuration. If you have an issue with a vendor's schema, run it through a transformation tool such as XSLT to correct the issue with the schema (ie., change the namespace), then you can generate the shared schema. JiBX can then use the shared schema as it does in the example here: https://github.com/jibx/maven-plugin/tree/master/test-suite/web-schema-test. You can find an explanation here: https://jibx.sourceforge.io/maven-jibx-plugin/modular-codegen.html. I use this technique successfully in my automated public schema to code scripts.