我使用的JiBX Maven插件一些的XSD到Java源代码的转换。 在一个模式的,还有就是在架构B.定义之前的类型的引用,我用这个pom.xml的配置,一切都工作得很好:
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.3</version>
<configuration>
<schemaLocation>${basedir}/resources/oxm/schemas</schemaLocation>
<schemaBindingDirectory>${basedir}/src/java</schemaBindingDirectory>
<includeSchemas>
<includeSchema>schemaA.xsd</includeSchema>
<includeSchema>schemaB.xsd</includeSchema>
<includeSchema>schemaC.xsd</includeSchema>
</includeSchemas>
<verbose>true</verbose>
</configuration>
</plugin>
输入模式A是这样的:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="myApp.com/schema/schemaA"targetNamespace="http://myApp.com/schema/schemaA" xmlns:rsType="http://myApp.com/schema/schemaB">
<xs:import schemaLocation="schemaB.xsd" namespace="http://myApp.com/schema/schemaB" />
<xs:complexType name="classAType">
<xs:sequence>
<xs:element name="objB" type="rsType:classBType" />
</xs:sequence>
<xs:attribute name="foo" type="xs:int" />
</xs:complexType>
输入模式B具有与classBType的定义类似的代码。
前者Java源代码的输出是这样的:
class classA
{
classB objB;
int foo;
}
最近,我在分离在pom.xml不同的构建执行模式转化为能够为它们定义不同的目标包。 我的新pom.xml的是:
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.3</version>
<configuration>
<schemaLocation>${basedir}/resources/oxm/schemas</schemaLocation>
<schemaBindingDirectory>${basedir}/src/java</schemaBindingDirectory>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<id>schemaCodegenA</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<includeSchemas>
<includeSchema>schemaA.xsd</includeSchema>
</includeSchemas>
<options>
<package>com.myApp.jibxgenerated.schema.resource</package>
</options>
</configuration>
</execution>
(...一个执行每个模式集)
Java源代码的输出是现在:
class classA
{
// all properties of class B here
int classBattrib1;
int classBattrib2;
int classBattribN;
int foo;
}
这是预期的行为? 我想有CLASSB参考回到了A类的源代码,有没有什么办法来实现这一目标?
在此先感谢您的帮助。