[英]JAXB unmarshalling, guarantee order of elements
I'm unmarshalling a sequence of elements with JAXB in a list, see below. 我将在列表中使用JAXB解组一系列元素,请参见下文。
XML-File XML文件
<stroke>
<textPoint x="81.0" y="457.0" p="0.0" e="90.0" a="0.0" />
<textPoint x="80.0" y="457.0" p="0.0" e="89.0" a="135.0" />
<textPoint x="81.0" y="455.0" p="0.0" e="86.0" a="135.0" />
....
<textPoint x="228.0" y="475.0" p="0.0" e="57.0" a="122.0" />
<textPoint x="213.0" y="456.0" p="0.0" e="57.0" a="121.0" />
<textPoint x="233.0" y="476.0" p="0.0" e="57.0" a="122.0" />
</stroke>
Java-Code Java代码
private List<TextPoint> textPointList;
@XmlElement(name = "textPoint")
public List<TextPoint> getTextPointList() {
return textPointList;
}
public void setTextPointList(List<TextPoint> textPointList) {
this.textPointList = textPointList;
}
However, I'm a bit worried about the inherent order of the textPoint-elements, as they are ordered fine in the XML-file, but there is no element (eg ID) I could sort them via propOrder
. 但是,我有点担心textPoint-elements的固有顺序,因为它们在XML文件中的排序很好,但是没有元素(例如ID)可以通过
propOrder
对其进行propOrder
。 Nevertheless, it seems to unmarshal them fine in the same order as in the XML-file, so is there no need to worry about that? 但是,似乎可以按照与XML文件中相同的顺序将其解组,所以不必担心吗?
The List
will be populated based on the order the elements appear in the XML on an unmarshal. 该
List
将根据元素在XML中的出现顺序进行填充。 When marshalling the order of the elements in the XML will be based on the order of the corresponding objects in the List
. 编组XML时,元素的顺序将基于
List
相应对象的顺序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.