1

我有来自 SharePoint(getListItems)的 XML,没有 shema(使用没有 @XmlRootElement 的 JAXB)。我必须从此 XML 创建对象并使用 unmarshall(JAXB)。我看到的所有例子 - 都有shema。你能帮我或举个例子吗?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GetListItemsResult xmlns="http://schemas.microsoft.com/sharepoint/soap/">
    <listitems xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
        <rs:data ItemCount="5">
            <z:row ows_Attachments="0" ows_Created="2013-07-17 12:20:14" ows_Created_x0020_Date="1;#2013-07-17 12:20:14" ows_FSObjType="1;#0" ows_FileLeafRef="1;#1_.000" ows_FileRef="1;#Lists/000/1_.000" ows_ID="1" ows_LinkTitle="H1 2013" ows_MetaInfo="1;#" ows_Modified="2013-07-17 12:20:14" ows_PermMask="0x7fffffffffffffff" ows_Title="H1 2013" ows_UniqueId="1;#{DD5DFA68-42E1-47BC-BBE3-9921D6093EB2}" ows__Level="1" ows__ModerationStatus="0" ows_owshiddenversion="1"/>
            <z:row ows_Attachments="0" ows_Created="2013-07-17 12:20:20" ows_Created_x0020_Date="2;#2013-07-17 12:20:20" ows_FSObjType="2;#0" ows_FileLeafRef="2;#2_.000" ows_FileRef="2;#Lists/000/2_.000" ows_ID="2" ows_LinkTitle="H1 2014" ows_MetaInfo="2;#" ows_Modified="2013-07-17 12:20:20" ows_PermMask="0x7fffffffffffffff" ows_Title="H1 2014" ows_UniqueId="2;#{48F0F5E2-3DC6-4C7C-901A-5F33834DA619}" ows__Level="1" ows__ModerationStatus="0" ows_owshiddenversion="1"/>
            <z:row ows_Attachments="0" ows_Created="2013-07-17 12:20:25" ows_Created_x0020_Date="3;#2013-07-17 12:20:25" ows_FSObjType="3;#0" ows_FileLeafRef="3;#3_.000" ows_FileRef="3;#Lists/000/3_.000" ows_ID="3" ows_LinkTitle="H1 2015" ows_MetaInfo="3;#" ows_Modified="2013-07-17 12:20:25" ows_PermMask="0x7fffffffffffffff" ows_Title="H1 2015" ows_UniqueId="3;#{40136C41-B7DA-42E4-B733-1B569C0AFEEB}" ows__Level="1" ows__ModerationStatus="0" ows_owshiddenversion="1"/>
            <z:row ows_Attachments="0" ows_Created="2013-07-18 17:05:48" ows_Created_x0020_Date="7;#2013-07-18 17:05:48" ows_FSObjType="7;#0" ows_FileLeafRef="7;#7_.000" ows_FileRef="7;#Lists/000/7_.000" ows_ID="7" ows_LinkTitle="Michael Drummond" ows_MetaInfo="7;#" ows_Modified="2013-07-18 17:05:48" ows_PermMask="0x7fffffffffffffff" ows_Title="Michael Drummond" ows_UniqueId="7;#{057BB0DD-DA6F-45A4-8B85-809E09E79149}" ows__Level="1" ows__ModerationStatus="0" ows_owshiddenversion="1"/>
            <z:row ows_Attachments="0" ows_Created="2013-07-18 17:22:35" ows_Created_x0020_Date="8;#2013-07-18 17:22:35" ows_FSObjType="8;#0" ows_FileLeafRef="8;#8_.000" ows_FileRef="8;#Lists/000/8_.000" ows_ID="8" ows_LinkTitle="Michael Drummond" ows_MetaInfo="8;#" ows_Modified="2013-07-18 17:22:35" ows_PermMask="0x7fffffffffffffff" ows_Title="Michael Drummond" ows_UniqueId="8;#{8E6F9D85-E360-41E8-87F8-65D071FE39AC}" ows__Level="1" ows__ModerationStatus="0" ows_owshiddenversion="1"/>
</rs:data>
</listitems>
</GetListItemsResult>
4

1 回答 1

1

例如,您需要考虑命名空间和集合中的几件事。

命名空间

您可以使用包级别@XmlSchema注释来设置默认命名空间限定。然后,由于涉及多个命名空间,您可以使用、 和namespace上的参数@XmlType@XmlElement@XmlElementWrapper在需要时覆盖默认值。

收藏品

默认情况下,JAXB 实现不会为集合属性添加分组元素,这可以通过@XmlElementWrapper注释来完成。

于 2013-07-19T12:26:45.223 回答