0

大家好,我需要您的帮助,我正在尝试将 SharePoint 生成的 XML 导入 SQL Server 数据库。我通过 SSIS 使用 XML 源到 ADO.Net 目标来执行此操作

在此处输入图像描述

这就是我的 XML 的样子(我只为这个示例包含了 2 个项目)

<data z="#RowsetSchema">
  <z:row ows_LinkTitle="Lorem ipsum" ows_Description="Dolor sit amet, consectetur adipiscing elit. Phasellus commodo turpis quis diam dapibus volutpat. Proin auctor nulla elit, eu aliquam tellus lacinia non. Vestibulum posuere lectus id metus elementum, eget vulputate est lobortis. Morbi eu enim non lectus aliquet feugiat commodo ac diam. Nunc tempor enim leo. Mauris vitae condimentum erat. Vivamus vitae purus justo." ows_Category="Category 1" ows_Amount="150.000000000000" ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Lorem ipsum" ows_ID="1" ows_UniqueId="1;#{32A15E91-0921-496C-8389-B4A861CF63B1}" ows_owshiddenversion="2" ows_FSObjType="1;#0" ows_Created_x0020_Date="1;#2013-11-01 08:59:20" ows_Created="2013-11-01 08:59:20" ows_FileLeafRef="1;#1_.000" ows_PermMask="0x400001f04fff19ff" ows_Modified="2013-11-01 08:59:33" ows_FileRef="1;#sandbox/Lists/Test List/1_.000" xmlns:z="#RowsetSchema" />
  <z:row ows_LinkTitle="Maecenas quis" ows_Description="Felis nec nulla aliquam ullamcorper. Sed et suscipit leo. Morbi mauris nibh, feugiat at commodo eget, tincidunt et eros. Vestibulum convallis ipsum vel laoreet venenatis. Quisque mollis elit sed mattis sollicitudin. Maecenas at pretium nulla. Nullam ultricies tempus lorem ut consequat." ows_Category="Category 2" ows_Amount="89.0000000000000" ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Maecenas quis" ows_ID="2" ows_UniqueId="2;#{AC2914E0-4101-4493-B301-F27EA6F586C1}" ows_owshiddenversion="2" ows_FSObjType="2;#0" ows_Created_x0020_Date="2;#2013-11-01 08:59:27" ows_Created="2013-11-01 08:59:27" ows_FileLeafRef="2;#2_.000" ows_PermMask="0x400001f04fff19ff" ows_Modified="2013-11-01 08:59:46" ows_FileRef="2;#sandbox/Lists/Test List/2_.000" xmlns:z="#RowsetSchema" />
</data>

这就是我的 XSD 的样子

<?xml version="1.0" encoding="Windows-1252"?>
<xs:schema xmlns:tns="#RowsetSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="#RowsetSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="data">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="row">
          <xs:complexType>
              <xs:attribute name="ows_LinkTitle" type="xs:string" use="required" />
              <xs:attribute name="ows_Description" type="xs:string" use="required" />
              <xs:attribute name="ows_Category" type="xs:string" use="required" />
              <xs:attribute name="ows_Amount" type="xs:decimal" use="required" />
              <xs:attribute name="ows_MetaInfo" type="xs:string" use="required" />
              <xs:attribute name="ows__ModerationStatus" type="xs:unsignedByte" use="required" />
              <xs:attribute name="ows__Level" type="xs:unsignedByte" use="required" />
              <xs:attribute name="ows_Title" type="xs:string" use="required" />
              <xs:attribute name="ows_ID" type="xs:unsignedByte" use="required" />
              <xs:attribute name="ows_UniqueId" type="xs:string" use="required" />
              <xs:attribute name="ows_owshiddenversion" type="xs:unsignedByte" use="required" />
              <xs:attribute name="ows_FSObjType" type="xs:string" use="required" />
              <xs:attribute name="ows_Created_x0020_Date" type="xs:string" use="required" />
              <xs:attribute name="ows_Created" type="xs:string" use="required" />
              <xs:attribute name="ows_FileLeafRef" type="xs:string" use="required" />
              <xs:attribute name="ows_PermMask" type="xs:string" use="required" />
              <xs:attribute name="ows_Modified" type="xs:string" use="required" />
              <xs:attribute name="ows_FileRef" type="xs:string" use="required" />
            </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

现在 SSIS 可以正确识别 XSD,因为它显示了列/字段

在此处输入图像描述

但是那个 XSD 没有正确映射到我的 XML,我需要在我的 XSD 上进行什么更改才能正确映射?我还可以更改 XML 以仅在现有 XML 的上方和下方添加任何内容。

4

1 回答 1

1

<row>元素看起来有效,唯一不正确的是元素z上属性的存在<data>

我建议在元素上正确声明z命名空间,如下所示:<data>

<data xmlns:z="#RowsetSchema">

并将其从任何子元素中删除。

于 2013-10-31T22:44:07.693 回答