Xav*_*ica 8 java xml xsd jaxb xjc
我正在尝试从几个特定的XSD生成Java类xjc
.这些模式有一些共同的定义,因此它们导入了许多常见的XSD.特别是,它们可以包括零到所有常见的XSD.
我想生成从特定XSD到特定包的所有类,但是将公共模式的生成类保存在公共包中,因此不会对源树中的每个特定模式重复这些类.
我已经了解到,自定义绑定可用于在每个模式的基础上指定包,例如:
<jxb:bindings schemaLocation="common1.xsd" node="/xsd:schema">
<jxb:schemaBindings>
<jxb:package name="mypackage.commonclasses"/>
</jxb:schemaBindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)
我有以下结构:
schemas
| - common
| | - common1.xsd --> XSD with common types #1
| | - ...
| | - commonN.xsd --> XSD with common types #N
| | - commonBindings.xjb --> Defines package "mypackage.commons" for common*.xsd
| - specific1
| | - specific1.xsd --> Includes ../common/common{1-N}.xsd
| | - specific1.xjb --> Defines package "mypackage.specific1" for specific1.xsd
| - specificN
| | - specificN.xsd --> Includes only ../common/common1.xsd
| | - specificN.xjb --> Defines package "mypackage.specificN" for specificN.xsd
Run Code Online (Sandbox Code Playgroud)
一切正常:
xjc -b schemas/specific1
-b schemas/common
schemas/specific1/specific1.xsd
Run Code Online (Sandbox Code Playgroud)
它为specific1.xsd
in mypackage.specific1
和common公共类生成类mypackage.commons
.但是当我尝试生成类时specificN
,xjc
会抛出以下错误:
[ERROR] "file:/drive/dir/schemas/common/common1.xsd" is not a part of
this compilation. Is this a mistake for "/drive/dir/schemas/common/commonBindings.xjb"?
line 2 of file:/drive/dir/schemas/common/commonBindings.xjb
Run Code Online (Sandbox Code Playgroud)
对于未在任何特定xsd中导入的每个常见XSD,我都会重复此错误.
有什么办法可以xjc
忽略commonBindings.xjb
我在生成类的XSD中没有使用的绑定吗?
或者,我是否通过使用这种方法瞄准了错误的方向,例如,应该在特定的xsd中使用注释?如果可能的话,我想避免修改模式.
归档时间: |
|
查看次数: |
14850 次 |
最近记录: |