1
是否有可能的模式如:解組XML模式選擇元素,以單獨的列表
<xs:complexType name="GroupType">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element type="PageType" name="Page" minOccurs="0" maxOccurs="unbounded"/>
<xs:element type="GroupType" name="Group" minOccurs="0" maxOccurs="unbounded"/>
<xs:element type="ResourcesType" name="Resources" minOccurs="0" maxOccurs="1"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
..to以這樣的方式來解組,不同的元素類型在單獨的列表? e.g:
public class GroupType {
List<PageType> page;
List<GroupType> group;
ResourcesType resources;
...
}
JAXB的默認行爲是所有choice
匹配到一個單一的泛型列表的元素結合起來。編組時,我並不在意訂購或重新創建確切的文檔,所以更好地組織數據而不是一個確切的副本會很方便。
我無法得到這個爲我工作。但是我確實意識到,沒有maxOccurs這些元素被放入它們各自的列表(不是它解決了我的問題..) – brasskazoo 2012-02-01 06:18:35