0

我的应用程序与另一个生成 XML 的应用程序集成,他们给了我 XSD 和示例 XML

我有一个关于这件作品的问题:

XSD:

<element name="IubLink">
    <complexType>
        <complexContent>
            <extension base="xn:NrmClassXmlType">
                <sequence>
                    <element name="attributes" minOccurs="0">
                        <complexType>
                            <all>
                                <element name="userLabel" minOccurs="0"/>
                                <element name="iubLinkUtranCell" minOccurs="0"/>
                                <element name="iubLinkNodeBFunction" minOccurs="0"/>
                            </all>
                        </complexType>
                    </element >
                    <choice minOccurs="0" maxOccurs="unbounded">
                        <element ref="xn:VsDataContainer"/>
                    </choice>
                </sequence>
            </extension>
        </complexContent >
    </complexType>
</element >

XML:

<un:IubLink id="Iub_RBS0087">
<un:attributes>
    <un:userLabel>Iub_RBS0087</un:userLabel>
    <un:iubLinkUtranCell>SubNetwork=ONRM_RootMo_R,SubNetwork=RNC04,MeContext=RNC04,ManagedElement=1,RncFunction=1,UtranCell=00871</un:iubLinkUtranCell>
    <un:iubLinkUtranCell>SubNetwork=ONRM_RootMo_R,SubNetwork=RNC04,MeContext=RNC04,ManagedElement=1,RncFunction=1,UtranCell=00872</un:iubLinkUtranCell>
    <un:iubLinkUtranCell>SubNetwork=ONRM_RootMo_R,SubNetwork=RNC04,MeContext=RNC04,ManagedElement=1,RncFunction=1,UtranCell=00873</un:iubLinkUtranCell>
    <un:iubLinkUtranCell>SubNetwork=ONRM_RootMo_R,SubNetwork=RNC04,MeContext=RNC04,ManagedElement=1,RncFunction=1,UtranCell=00875</un:iubLinkUtranCell>
    <un:iubLinkUtranCell>SubNetwork=ONRM_RootMo_R,SubNetwork=RNC04,MeContext=RNC04,ManagedElement=1,RncFunction=1,UtranCell=00876</un:iubLinkUtranCell>
    <un:iubLinkUtranCell>SubNetwork=ONRM_RootMo_R,SubNetwork=RNC04,MeContext=RNC04,ManagedElement=1,RncFunction=1,UtranCell=00877</un:iubLinkUtranCell>
    <un:iubLinkNodeBFunction>SubNetwork=ONRM_RootMo_R,SubNetwork=RNC04,MeContext=RBS0087,ManagedElement=1,NodeBFunction=1</un:iubLinkNodeBFunction>
</un:attributes>
<xn:VsDataContainer id="1">
    <xn:attributes>
        <xn:vsDataType>vsDataIubEdch</xn:vsDataType>
        <xn:vsDataFormatVersion>EricssonSpecificAttributes.12.26</xn:vsDataFormatVersion>
        <es:vsDataIubEdch>
            <es:edchDataFrameDelayThreshold>60</es:edchDataFrameDelayThreshold>
            <es:userLabel>1</es:userLabel>
        </es:vsDataIubEdch>
    </xn:attributes>
</xn:VsDataContainer>

在 java 中,我想获取 IubLinkUtranCell 的列表,但 JAXB 生成它的方式如下:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {

})
public static class Attributes {

    protected Object userLabel;
    protected Object iubLinkUtranCell;
    protected Object iubLinkNodeBFunction;

所以我会将所有 IubLinkUtranCell 作为一个对象!,我怎么能遍历它们?

4

1 回答 1

0

您必须在您的属性类中列出“IubLinkNodeBFunction”:

 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "", propOrder = {

 })
 public static class Attributes {

protected Object userLabel;
@XMlElement(name = "iubLinkUtranCell")
protected List<IubLinkUtranCell> iubLinkUtranCellList;
protected Object iubLinkNodeBFunction;

并且您必须创建“IubLinkUtranCell”类,如果此类中有更多属性,您可以将它们添加到类中以访问它们。

于 2013-09-27T11:57:53.933 回答