我正在使用下面列出的 XSD 和相应的 XML。一切都适用于动态 MOXy,但我不知道如何在 java 中访问枚举类型。有什么建议么?感谢帮助。
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema ...>
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="first-name" type="xs:string"/>
<xs:element name="last-name" type="xs:string"/>
<xs:element name="quadrant" type="myns:compass-direction"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="compass-direction">
<xs:restriction base="xs:string">
<xs:enumeration value="NORTH"/>
<xs:enumeration value="SOUTH"/>
<xs:enumeration value="EAST"/>
<xs:enumeration value="WEST"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
//JAVA code
DynamicEntity person = (DynamicEntity) dynamicJAXBContext.createUnmarshaller().unmarshal(instanceDoc);
String firstName = person.get("firstName");
String lastName = person.get("lastName");
//until here it works well
//but now: how to get and set the value of the "quadrant"?
// following lines do not work
String quadrant=person.get("quadrant);
person.set("quadrant","NORTH");