0

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.

Alan Evangelista
  • 2,888
  • 6
  • 35
  • 45

1 Answers1

0

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>
Nicholas Albion
  • 3,096
  • 7
  • 33
  • 56
  • According to documentation (http://jibx.sourceforge.net/fromschema/codegen-customs.html), the package attrib should work in the schema AND schema-set tags. Nevertheless, I tried your suggestion, adding a names attribute in the children schema-set to restrict the schema-set to contain the desired schemas. It did not work, strangely only 1 schema was generated in the desired package, the others were generated in packages derived from schemas namespaces. Any ideas? – Alan Evangelista Aug 12 '12 at 18:40
  • Is there any particular reason why you are using jibx rather than JAXB? – Nicholas Albion Aug 12 '12 at 22:43
  • I didn't choose the jibx framework earlier and I won't choose another xml framework now only to have this feature. – Alan Evangelista Aug 22 '12 at 04:49
  • What do you mean you "didn't choose the jibx framework earlier"? JAXB is built into the Java6 SDK and you'll find it a lot easier to get support... – Nicholas Albion Aug 22 '12 at 23:41