I am converting java class into XML file using JAXB library. I dont want to create parent class tag Example My Main Class is ComponentDTO.java
@XmlRootElement(name = "flow")
@AllArgsConstructor
@Getter
@Setter
public class ComponentDto {
@XmlElements({
@XmlElement(name = "input", type = ActivityDto.class),
@XmlElement(name = "action", type = ActivityAction.class),
@XmlElement(name = "dropdown", type = Dropdown.class),
@XmlElement(name = "alert", type = ActivityAlert.class),
@XmlElement(name = "windows", type = ActivityWindow.class),
@XmlElement(name = "script", type = Javascript.class),
})
List<ChildDto> dtos;
public interface ChildDto {}
@AllArgsConstructor
@XmlRootElement(name = "input")
@NoArgsConstructor
@Getter @Setter
public static class ActivityDto implements ChildDto {
@XmlAttribute(name = "name")
private String name;
}
@AllArgsConstructor
@XmlRootElement(name = "action")
@NoArgsConstructor
@Getter @Setter
public static class ActivityAction implements ChildDto {
@XmlAttribute(name = "name")
private String name;
}
@AllArgsConstructor
@XmlRootElement(name = "dropdown")
@NoArgsConstructor
@Getter @Setter
public static class Dropdown implements ChildDto {
@XmlAttribute(name = "name")
private String name;
}
@AllArgsConstructor
@XmlRootElement(name = "alert")
@NoArgsConstructor
@Getter @Setter
public static class ActivityAlert implements ChildDto {
@XmlAttribute(name = "name")
private String name;
}
@AllArgsConstructor
@XmlRootElement(name = "windows")
@NoArgsConstructor
@Getter @Setter
public static class ActivityWindow implements ChildDto {
@XmlAttribute(name = "name")
private String name;
}
@AllArgsConstructor
@XmlRootElement(name = "script")
@NoArgsConstructor
@Getter @Setter
public static class Javascript implements ChildDto {
@XmlAttribute(name = "name")
private String name;
}
}
and when i create object for ComponentDTO and then generate xml for this class then it will generate like this
<flow>
<dtos>
<input name="test"/>
</dtos>
<dtos>
<action name="test"/>
</dtos>
<dtos>
<dropdown name="test"/>
</dtos>
<dtos>
<alert name="test"/>
</dtos>
<dtos>
<windows name="test"/>
</dtos>
<dtos>
<script name="test"/>
</dtos>
</flow>
but i want result like this
<flow>
<input name="test"/>
<action name="test"/>
<dropdown name="test"/>
<alert name="test"/>
<windows name="test"/>
<script name="test"/>
</flow>
How can i do that?