问题: 如何让xjc/Jaxb为包含重复的elementdefinitions的几个模式在相同的命名空间中生成propper javaclasses?使用JAXB编译几个包含同一元素的重复定义
信息: 我有三个.xsd模式:A,B和C.都具有相同的目标名空间。 他们都是给我的3种shemas,我不可能以任何方式改变它们。
它们A具有一些元件,其也于B或C中发现(但A具有许多自声明的元素为好) 实施例:这是相同的“代码”为A和C:
<xs:simpleType name="y_ym_ymdDatoType">
<xs:union memberTypes="arcgYearType arcgYearMonthType arcDateType"/>
</xs:simpleType>
<xs:simpleType name="arcgYearType">
<xs:restriction base="xs:gYear">
<xs:minInclusive value="1700"/>
<xs:maxInclusive value="2100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="arcgYearMonthType">
<xs:restriction base="xs:gYearMonth">
<xs:minInclusive value="1700-01"/>
<xs:maxInclusive value="2100-12"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="arcDateType">
<xs:restriction base="xs:date">
<xs:minInclusive value="1700-01-01"/>
<xs:maxInclusive value="2100-12-31"/>
</xs:restriction>
</xs:simpleType>
当使用XJC将它们汇编成javaclasses,我得到下面的异常:
[ERROR] 'y_ym_ymdDatoType' is already defined
line 297 of file:../c.xsd
[ERROR] (related to above error) the first definition appears here
line 309 of file:../a.xsd
和同样发生在其他元素:arcgYearType,arcgYearMonthType和arcDateType。
我已阅读关于可能可以解决这个问题的绑定文件,但我不知道如何做到这一点,所以示例将是高度优先的。
这是不是在它们出来时不会轻易地重命名XML元素,还是只是重命名生成的javaclasses? – 2012-03-13 14:15:28
它重命名生成的java类。默认情况下,你会得到'FixedIncomeBook.java',并且通过这个绑定你可以得到'PartyFixedIncomeBook.java' – 2012-03-13 14:21:11
我得到:[ERROR]不受支持的绑定命名空间“”。也许你的意思是“http://java.sun.com/xml/ns/jaxb/xjc”?文件第4行:/../ C.xsd 第4行是模式定义: 你可以说出了什么问题吗? –
2012-03-13 15:05:10