У меня есть следующие 2 класса. Один содержит массив другого ..
@XmlType(name="category", propOrder = { "title", "description", "sdImg", "hdImg","categoryLeafDTO" } )
public class CategoryDTO implements Serializable {
@XmlElementWrapper (name="categoryleaf")
public CategoryLeafDTO[] getCategoryLeafDTO() {
return this.categoryleafdto;
}
public void setCategoryLeafDTO(CategoryLeafDTO[] categoryleafdto) {
this.categoryleafdto = categoryleafdto;
}
}
@XmlType (name = "categoryleaf" , propOrder = { "title", "description", "autoplay" })
public class CategoryLeafDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String title;
private String description;
private String autoplay;
@XmlAttribute (name="title")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@XmlAttribute (name="description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@XmlAttribute (name="autoplay")
public String getAutoplay() {
return this.autoplay;
}
public void setAutoplay(String autoplay) {
this.autoplay = autoplay;
}
}
Когда я трансформируюсь, это отображается как
<category title="Trailers" description="Just Trailers" sd_img="http://a.dolimg.com/media/en-US/m/dcom/tvapp/roku/assets/trailers_v4e_250.png" hd_img="http://a.dolimg.com/media/en-US/m/dcom/tvapp/roku/assets/trailers_v4e_250.png">
<categoryleaf>
<categoryLeafDTO title="Trailers" description="Just Trailers" autoplay="ON" />
<categoryLeafDTO title="Cars" description="cars the movie" autoplay="OFF" />
</categoryleaf>
</category>
Но мои требования это иметь как
<category title="Trailers" description="Just Trailers" sd_img="http://a.dolimg.com/media/en-US/m/dcom/tvapp/roku/assets/trailers_v4e_250.png" hd_img="http://a.dolimg.com/media/en-US/m/dcom/tvapp/roku/assets/trailers_v4e_250.png">
<categoryleaf title="Trailers" description="Just Trailers" autoplay="ON">
<categoryleaf title="Cars" description="cars the movie" autoplay="OFF">
</category>