I have two simpleTypes with String restrictions to specific enumeration values as follows:
Expand|Select|Wrap|Line Numbers
- <xs:simpleType name="RestDaysHandlingMode">
- <xs:restriction base="xs:string">
- <xs:enumeration value="Forward"></xs:enumeration>
- <xs:enumeration value="ForwardUnlessMonthChange"></xs:enumeration>
- <xs:enumeration value="NoShift"></xs:enumeration>
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="YearMonthMethod">
- <xs:restriction base="xs:string">
- <xs:enumeration value="30_360"></xs:enumeration>
- <xs:enumeration value="Actual_360"></xs:enumeration>
- <xs:enumeration value="Actual_365"></xs:enumeration>
- <xs:enumeration value="Actual_Actual"></xs:enumeration>
- </xs:restriction>
- </xs:simpleType>
Expand|Select|Wrap|Line Numbers
- @XmlEnum
- public enum RestDaysHandlingMode {
- @XmlEnumValue("Forward")
- FORWARD("Forward"),
- @XmlEnumValue("ForwardUnlessMonthChange")
- FORWARD_UNLESS_MONTH_CHANGE("ForwardUnlessMonthChange"),
- @XmlEnumValue("NoShift")
- NO_SHIFT("NoShift");
- private final String value;
- RestDaysHandlingMode(String v) {
- value = v;
- }
- public String value() {
- return value;
- }
- public static RestDaysHandlingMode fromValue(String v) {
- for (RestDaysHandlingMode c: RestDaysHandlingMode.values()) {
- if (c.value.equals(v)) {
- return c;
- }
- }
- throw new IllegalArgumentException(v);
- }
- }
whereas the second type is handled as a simple string (the following is taken from a class that is generated by JAXB and contains an element of the second type):
Expand|Select|Wrap|Line Numbers
- /**
- * Gets the value of the yearMonthMethod property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getYearMonthMethod() {
- return yearMonthMethod;
- }