我在解组嵌套的复杂对象时遇到问题。在下面的 xml 示例中,“Racing”有一个 RacingTicket obj。这可以通过 rdf:about 链接访问,这是一个获取 RacingTicket 的宁静服务调用。
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:hl="http://racing.com/horses/holding-location">
<title type="text">Create Racing Event</title>
<id>http://www.racing.com/</id>
<content type="application/xml">
<racing xmlns="http://racing.com/schema/horses">
<racingTicket rdf:about="https://racing.com/fast/racingTicket/asdf-asfd-asdf-asdf-asdf" />
<tracks>
<track>
<title>ABX</title>
<amount>560</amount>
</track>
</tracks>
<racingId>001</racingId>
</racing>
</content>
</entry>
Java class
@XmlRootElement
public class Racing implements Serializable {
@AtomId( prefixUrl = "http://racing.com/fast/racingTicket/" )
private String id;
private RacingTicket racingTicket;
private Tracks tracks;
private BigDecimal racingId;
public RacingTicket getRacingTicket() {
return racingTicket;
}
@XmlElement
public void setRacingTicket( RacingTicket racingTicket ) {
this.racingTicket = racingTicket;
}
jaxb unmarshaler 返回的对象包含所有值为空的竞速票类。请告知,任何帮助表示赞赏。