Would be better if you ask these questions separately.
First question - just use multiple jaxb:schemaBindings
.
<jaxb:bindings schemaLocation="a.xsd" node="/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.a"/>
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="b.xsd" node="/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.b"/>
</jaxb:schemaBindings>
</jaxb:bindings>
Second question - multiple executions or do some file-moving postprocessing on your own. Why do multiple executions not work for you?
Update: You say you're interested in a per-namespace, not per-file solution.
First, it doesn't really matter that much, at the end it's a per-namespace solution in any case. If you bind via schemaLocation
, XJC associates schemaBindings
with the target namespace of that schema. You don't have to customize every file of that schema and you can't define two packages for one namespace.
Second, you can use SCD bindings instead:
<jaxb:bindings scd="x-schema::tns" xmlns:tns="http://a.com">
<jaxb:schemaBindings>
<jaxb:package name="com.a"/>
</jaxb:schemaBindings>
</jaxb:bindings>