SSIS XMLSource 在 XML 变量中仅看到空值

2023-12-03

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

xml变量值:

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

我使用此源在 XMLSource Editor 中生成 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SSIS XMLSource 在 XML 变量中仅看到空值 的相关文章

随机推荐