JAXB嵌套元素注释

时间:2018-02-27 04:57:10

标签: java xml jaxb

我想知道如何使用JAXB在XML中注释嵌套元素。

我的XML应该喜欢这个

<?xml version='1.0' encoding='utf-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://127.0.0.1:9089/TCMBCommon-iris/TCMBCommon.svc/GB0010001/">
<title type="text">enqTcibAcctDetailss</title>
<id>http://127.0.0.1:9089/TCMBCommon-iris/TCMBCommon.svc/GB0010001/enqTcibAcctDetailss()</id>
<updated>2016-09-14T10:13:48Z</updated>
<link rel="self" title="enqTcibAcctDetailss" href="enqTcibAcctDetailss()" />
<entry>
    <id>http://127.0.0.1:9089/TCMBCommon-iris/TCMBCommon.svc/GB0010001/enqTcibAcctDetailss('')</id>
    <title type="text" />
    <updated>2016-09-14T10:13:48Z</updated>
    <author>
        <name />
    </author>
    <link rel="self" title="enqTcibAcctDetails" href="enqTcibAcctDetailss('78239')" />
    <category term="TCMBCommon-modelsModel.enqTcibAcctDetails" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
        <m:properties>
            <d:CategoryId>1001</d:CategoryId>
            <d:Type>Current Account</d:Type>
            <d:Acc>78239</d:Acc>
            <d:Ccy>GBP</d:Ccy>
            <d:OnlineActualBal>330.47</d:OnlineActualBal>
            <d:RealBalance>330.47</d:RealBalance>
            <d:Sortcode>601613</d:Sortcode>
            <d:Customer>100336</d:Customer>
            <d:ArrangementId>AA16082JD77P</d:ArrangementId>
            <d:Ac1>78239 Rolf Gerling</d:Ac1>
            <d:ProductGroup>CURRENT.ACCOUNTS</d:ProductGroup>
            <d:ProductLine>ACCOUNTS</d:ProductLine>
            <d:ProductName>CURRENT.ACCOUNT</d:ProductName>
            <d:AvailAmt>330.47</d:AvailAmt>
            <d:AvailBalWithLimit>660.94</d:AvailBalWithLimit>
            <d:IbanId>GB22DEMO60161300078239</d:IbanId>
            <d:Branch>Model Bank 201608</d:Branch>
            <d:AcctTransRights>YES</d:AcctTransRights>
            <d:enqTcibAcctDetails_PortfolioNoMvGroup m:type="Bag(TCMBCommon-modelsModel.enqTcibAcctDetails_PortfolioNoMvGroup)">
                <d:element>
                    <d:PortfolioNo></d:PortfolioNo>
                </d:element>
            </d:enqTcibAcctDetails_PortfolioNoMvGroup>
            <d:enqTcibAcctDetails_ShortTitleMvGroup m:type="Bag(TCMBCommon-modelsModel.enqTcibAcctDetails_ShortTitleMvGroup)">
                <d:element>
                    <d:Name>Rolf Gerling</d:Name>
                </d:element>
            </d:enqTcibAcctDetails_ShortTitleMvGroup>
            <d:enqTcibAcctDetails_AccountTitle1MvGroup m:type="Bag(TCMBCommon-modelsModel.enqTcibAcctDetails_AccountTitle1MvGroup)">
                <d:element>
                    <d:AcctName>Current Account</d:AcctName>
                </d:element>
            </d:enqTcibAcctDetails_AccountTitle1MvGroup>
        </m:properties>
    </content>
</entry>

我想获得嵌套元素&#34; Property&#34;直。但我无法实现。

我的POJO课程用于获取嵌套元素&#34;属性&#34;单独是

@XmlRootElement(name="properties", namespace = 
"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata")
@XmlAccessorType(XmlAccessType.FIELD)    
class AccountResource {

@XmlElement(name = "Acc", namespace = 
"http://schemas.microsoft.com/ado/2007/08/dataservices")
public String accountNumber;

@XmlElement(name = "AcctName")
public String accountName;

@XmlElement(name = "Type")
public String accountType;

@Nullable
@XmlElement(name = "OnlineActualBal")
public Float availableBalance;

@Nullable
@XmlElement(name = "Ccy")
public String currency;

@Nullable
@XmlElement(name = "Customer")
public String customerNumber;

@Nullable
@XmlElement(name = "AcctTransRights")
public Boolean transferRights;

请帮助我如何继续 1.使用命名空间注释元素的正确方法是什么,因为我有两个或更多命名空间。 2.我们是否必须使用@XMLElementWrapper来实现此类

0 个答案:

没有答案