I am trying to use hyperjaxb3 to create a relational schema from the three .xsd (C14054.xsd, C14054CodeLists.xsd & C14054DataTypes.xsd) available here and then marshal data from XML <-> Java <-> Relational.
hyperjaxb3 has already done a better job of creating the relational schema than a very expensive commercial tool I evaluated - but I can't quite get it to do what I want with Enums.
e.g. in C14054.xsd, the 'Provider' element references 'RECID'
<xs:element name="Provider">
<xs:complexType>
<xs:sequence>
<xs:element ref="RECID" minOccurs="1" maxOccurs="1" />
which in turn is of TYPE 'RECIDCodeType'
<xs:element name="RECID" type="RECIDCodeType" />
from C14054CodeLists.xsd
<xs:complexType name="RECIDCodeType">
<xs:simpleContent>
<xs:extension base="RECIDCodeContentType" />
</xs:simpleContent>
which extends 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>
I.e. can the only valid entry (at the database tier) into Provider.RECID (I changed the column name in bindings.xjb) be '14054'?
I.e. can 14054 be added as a row to the Subpurposecodetype.VALUE_ column in the database?
Many thanks for any light anybody can shed!
Hopefully, this will help some other people in the future (thanks lexicore for pointing me in the right direction!):
Inline solution:
<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>
External bindings file solution:
<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>
Result:
@Id
@Column(name = "VALUE_")
public String getValue() {
return value;
}