Java 将xml模式选择元素解组为单独的列表
是否可以使用以下模式:Java 将xml模式选择元素解组为单独的列表,java,jaxb,xsd,unmarshalling,choice,Java,Jaxb,Xsd,Unmarshalling,Choice,是否可以使用以下模式: <xs:complexType name="GroupType"> <xs:sequence> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element type="PageType" name="Page" minOccurs="0" maxOccurs="unbounded"/>
<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>
..以不同元素类型在单独列表中的方式进行解组?
e、 g:
公共类GroupType{
列表页;
列表组;
资源体育资源;
...
}
JAXB的默认行为是将与
选项
匹配的所有元素组合到一个通用列表中。在编组时,我不关心如何排序或重新创建精确的文档,因此更好地组织数据而不是将其作为精确的副本将非常方便。从POJO开始,您可以如下注释您的类:
@XmlAccessorType(XmlAccessType.FIELD)
public class GroupType {
@XmlElement(name="Page")
List<PageType> page;
@XmlElement(name="Group)
List<GroupType> group;
@XmlElement(name="Resources")
ResourcesType resources;
...
}
@xmlacessortype(xmlacesstype.FIELD)
公共类GroupType{
@xmlement(name=“Page”)
列表页;
@xmlement(name=“组)
列表组;
@xmlement(name=“Resources”)
资源体育资源;
...
}
如果您是从XML模式生成类,那么可以使用外部绑定文件来指定为GroupType
了解更多信息
@XmlAccessorType(XmlAccessType.FIELD)
public class GroupType {
@XmlElement(name="Page")
List<PageType> page;
@XmlElement(name="Group)
List<GroupType> group;
@XmlElement(name="Resources")
ResourcesType resources;
...
}
@xmlacessortype(xmlacesstype.FIELD)
公共类GroupType{
@xmlement(name=“Page”)
列表页;
@xmlement(name=“组)
列表组;
@xmlement(name=“Resources”)
资源体育资源;
...
}
如果您是从XML模式生成类,那么可以使用外部绑定文件来指定为GroupType
了解更多信息