JAXB를 통해 상응하는 JAVA 클래스를 생성하기 위해 사전 정의 된 xsd 스키마 (불행히도 수정할 수 없음)가 있습니다. 현재 다음과 같이 정의 된 복잡한 유형으로 고민하고 있습니다. 상기 결합없이 xjc를 프로세스를 실행할 때JAXB anyType에서 문자열 컨텐츠에 액세스하기
<attribute id="address">
<example:Address xmlns:example="http://example.com/ns">
<Street>100 Nowhere Street</Street>
<City>Fancy</City>
<State>DC</State>
<Zip>99999</Zip>
</example:Address>
</attribute>
이 추천
<attribute id="myValue">201</attribute>
뿐만 아니라 임베디드 XML : 구비
<xsd:complexType name="AttributeType">
<xsd:complexContent>
<xsd:extension base="xsd:anyType">
<xsd:attribute name="id" type="xsd:anyURI" use="required"/>
<xsd:anyAttribute processContents="lax"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
는 XML 예는, 이와 같은 직접 캐릭터 컨텐츠를 허용 수정하면 다음과 같은 수업을 받게됩니다.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AttributeType", propOrder = {
"any"
})
public class AttributeType {
@XmlAnyElement
protected List<Element> any;
@XmlAttribute(name = "id", required = true)
@XmlSchemaType(name = "anyURI")
protected String id;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
// getter setter omitted
}
이 문제는 첫 번째 예제의 문자열 내용을 가져올 수 없다는 것입니다. 이것은 XSD anytype and JAXB을 참조 할 수도 있지만 실제로 XSD를 수정하지 않고이를 달성 할 수 있는지는 알 수 없습니다. 그렇다면 어떻게 문자열 내용을 얻을 수 있습니까? Btw. 소스를 생성하기 위해 maven cxf-codegen-plugin을 사용하고 있습니다.
문제를 해결할 수 있었습니까? 참조 된 링크 [link] (https://stackoverflow.com/questions/3488141/xsd-anytype-and-jaxb)는 내가 가지고있는 문제와 완전히 똑같습니다.이를 극복하는 방법을 찾으려고합니다. 그곳에서 해답을 찾지 못했습니다. – JGlass