我试图使用hyperjaxb3从三个.xsd (C14054.xsd、C14054CodeLists.xsd & C14054DataTypes.xsd) 可在这里找到创建关系模式,然后从XML <-> Java <->关系中封送数据。
hyperjaxb3在创建关系模式方面的工作已经比我评估过的一个非常昂贵的商业工具做得更好--但我无法让它用Enum来做我想做的事情。
例如,在C14054.xsd中,“Provider”元素引用“RECID”
<xs:element name="Provider">
<xs:complexType>
<xs:sequence>
<xs:element ref="RECID" minOccurs="1" maxOccurs="1" />它反过来又是“RECIDCodeType”类型
<xs:element name="RECID" type="RECIDCodeType" />来自C14054CodeLists.xsd
<xs:complexType name="RECIDCodeType">
<xs:simpleContent>
<xs:extension base="RECIDCodeContentType" />
</xs:simpleContent>
,它扩展了RECIDCodeContentType
<xs:simpleType name="RECIDCodeContentType">
<xs:restriction base="xs:string">
<xs:enumeration value="14054">
<xs:annotation>
<xs:documentation>
<Label>2014/15 AP student record</Label>
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
也就是说,进入Provider.RECID的唯一有效条目(在数据库层)(我在bindings.xjb中更改了列名)是否可以是“14054”?
也就是说,14054可以作为一行添加到数据库中的Subpurposecodetype.VALUE_列中吗?
非常感谢任何人所能散发的光芒!
发布于 2015-07-23 14:02:06
希望这能对未来的其他人有所帮助(谢谢你为我指明了正确的方向):
内联解决方案:
<xs:simpleType name="RECIDCodeContentType">
<xs:annotation>
<xs:appinfo>
<hj:id />
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="14054">
<xs:annotation>
<xs:documentation>
<Label>2014/15 AP student record</Label>
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
外部绑定文件解决方案:
<jaxb:bindings schemaLocation="C14054CodeLists.xsd" node="/xs:schema">
<!-- RECIDCodeType : Make VALUE Primary Key -->
<jaxb:bindings node="xs:simpleType[@name='RECIDCodeContentType']">
<hj:id />
</jaxb:bindings>
</jaxb:bindings>结果:
@Id
@Column(name = "VALUE_")
public String getValue() {
return value;
}https://stackoverflow.com/questions/31519715
复制相似问题