Below is the layout of the Maven projects:
For this example, schema1 is completely stand-alone whereas schema2 depends on schema1. The requirement is to be able to build both and deploy into a Maven repository.
The parent pom.xml file will have entries like this (omitting all the boilerplate stuff)...
The schema1 pom.xml will have the following entries (again no boilerplate code shown)...
Now we need to come up with a catalog file. This requires looking into the namespace definition of schema1.xsd. Lets assume, it is something like this...
Using this information, a catalog.cat file needs to be created in the same directory as the schema1.xsd. In this case its contents will look like this...
What that does is map the namespace to the actual schema XSD file. This allows us to import the schema1.xsd into schema2.xsd without actually specifying its location. So inside schema2.xsd there will be an entry like this...
Now the schema2 pom.xml file will have entries like this...
That's it! The schema2 project will correctly reference schema1 via its catalog file and if you build the parent pom.xml file you will get two JARs, one for each schema.
-i