Jibx Codegen: customization file - package per schema

℡╲_俬逩灬. 提交于 2019-12-25 01:39:00

问题


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-sets 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!