问题
I'm using Jibx maven plugin in a project to generate Java source from XML schema (xsd) files. I've configured the plugin in the pom.xml to use a customization xml. In this xml, I define a Java package per schema, as presented here:
<schema-set>
<schema name="schema1.xsd" package="com.myApp.jibxgenerated.schema.schema1"/>
<schema name="schema2.xsd" package="com.myApp.jibxgenerated.schema.schema2" includes="element1" />
<schema name="schema3.xsd" package="com.myApp.jibxgenerated.schema.schema3" includes="element1 element2" />
</schema-set>
I have namespaces defined in these schemas. The output Java source files still use the namespace defined in the schemas to create a Java package, ignoring my package attribute in the customization.xml.
I know the customization.xml is being read and used in the source code generation because there are some other customizations that work correctly.
Is this a bug or I'm doing something wrong here?
Thanks in advance for any help.
回答1:
At http://jibx.sourceforge.net/fromschema/codegen-customs.html they nest multiple schema-set
s within an outer schema-set
. Try this:
<schema-set>
<schema-set package="com.myApp.jibxgenerated.schema.schema1">
<schema name="schema1.xsd"/>
</schema-set>
<schema-set package="com.myApp.jibxgenerated.schema.schema2">
<schema name="schema2.xsd" includes="element1" />
</schema-set>
<schema-set package="com.myApp.jibxgenerated.schema.schema3">
<schema name="schema3.xsd" includes="element1 element2" />
</schema-set>
</schema-set>
来源:https://stackoverflow.com/questions/11918691/jibx-codegen-customization-file-package-per-schema