我有一个 CommonTypes.xsd,我使用 xs:include 将其包含在我的所有其他 XSD 中。我明白了
Multiple <schemaBindings> are defined for the target namespace ""
当我尝试使用绑定文件将其编译成不同的包时。请告诉我是否有办法将它们编译成不同的包。我正在使用 jaxb 2.1
是的,有办法。
假设:
xsd/common/common.xsd
xsd/foo/foo.xsd
在公共目录的地方common.xjb
:
<jxb:schemaBindings>
<jxb:package name="mypkg.common">
</jxb:package>
</jxb:schemaBindings>
在foo目录下的地方foo.xjb
:
<jxb:schemaBindings>
<jxb:package name="mypkg.foo">
</jxb:package>
</jxb:schemaBindings>
In the build.xml
文件中,为每个创建一个 xjc 任务:
<xjc destdir="${app.src}" readOnly="true" package="mypkg.common">
<schema dir="${app.schema}/common" includes="*.xsd" />
<binding dir="${app.schema}/common" includes="*.xjb" />
</xjc>
<xjc destdir="${app.src}" readOnly="true" package="mypkg.foo">
<schema dir="${app.schema}/foo" includes="*.xsd" />
<binding dir="${app.schema}/foo" includes="foo.xjb" />
</xjc>
你需要确保common.xsd
has a targetNameSpace
这不同于foo.xsd
's targetNameSpace
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)