sql-server - SSIS XMLSource 只看到 XML 变量中的空值

标签 sql-server ssis package dts

我有一个数据流任务,其中的 XMLSource 引用了一个 XML 变量。 DataFlow 任务确实识别出变量中有 x 行,但它只会在每一行中看到空值:

xml变量值:

<?xml version="1.0" encoding="utf-8"?>
<words>
   <word>butter</word>
   <word>crispy</word>
</words>

我使用此源在 XMLSource 编辑器中生成 XSD - 这是自动生成的 XSD:

<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="words">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="word" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

该包编译、执行和处理我的 XML 中的所有行,但只看到空值而不是实际的文本字符串...这是 DataViewer 在读取 XML 变量后显示 2 行的截图:

alt text

最佳答案

我发现了一种获取填充值的方法...我会在此处发布它而不给自己加分,以防其他人遇到同样的问题。这只是一个“如何解决”,但我会感谢任何可以解释“更深层原因”的人。

本质上,XML 需要包装在另一个根节点中:

<?xml version="1.0" encoding="utf-8"?>
<datarows>
   <words>
      <word>bacon</word>
      <word>roasted</word>
      <word>pork</word>
      <word>edamame</word>
   </words>
</datarows>

尽管我使用的原始 XML 是有效的,但 SSIS 希望将其包装在一个额外的根节点中,我将其命名为 datarows。一旦我这样做了,包就会识别出 word 值并成功完成。

alt text

相关架构:

<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="datarows">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="words">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="word" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

关于sql-server - SSIS XMLSource 只看到 XML 变量中的空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4028373/

相关文章:

sql-server - SSIS条件分割多个真实路径

package - 如何找到函数所属的包

sql-server - 提高 SQL Server 数据库性能

java - Win2k3服务器64位与JDBC的连接问题

sql-server - 阻止 SQL Server Management Studio 向存储过程添加注释

sql-server - SSAS 多维数据集使用了错误的数据库

ssis - 将 csv 文件写入 Azure Blob 存储时,是否可以将 SSIS 配置为将 NULL 表示为 BLANK 而不是\N?

npm - package.json 中的 phantomChildren 是什么?

java - 包含相同包或不同包的类的文件夹

sql - 巨大表的 MSSQL 游标无法分配空间