나는 Parent
과 Child
클래스를 가지고있다.JaxB, Eclipse Moxy, polymorhpic mapping
House
클래스는 Child
개체를 참조 할 수있는 Parent
유형의 필드가 있습니다. Eclipse Moxy를 사용하여 XML에 매핑해야한다. 같은
그것의 XSD가 될 것이다 일 :
<xs:complexType name="Parent" abstract="true"> ...other fields...
<xs:complexType name="Child" > <xs:extension base="Parent"> ...other fields...
<xs:element name="child" type="Child" substitutionGroup="parent" /> <xs:element name="parent" type="Parent" abstract="true" />
<xs:complexType name="House"> <xs:element ref="parent"/>
하우스 클래스는 부모를 가리 키도록 JAXBElement 첨부를 포함 : @XmlElementRef(name = "parent", namespace = "abc", type = JAXBElement.class) protected JAXBElement<? extends Parent> parent;
House
클래스를 House.oxm.xml 파일에 매핑하면 어떻게 다형 매핑이 올바르게 작동합니까?
<java-type name="House" xml-accessor-type="NONE"> <java-attributes> <xml-element-ref java-attribute="?????????"/>