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

发布于 2024-09-29 14:58:15 字数 934 浏览 0 评论 0 原文

我有一个带有引用 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 行的截图:

I have a Data Flow task with an XMLSource that references an XML Variable. The DataFlow task does recognize that there are x number of rows in the variable, but it only sees null values in every row:

The xml variable value:

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

I used this source to generate the XSD within the XMLSource Editor - here is the auto-generated 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>

The package compiles, executes, and processes all the rows in my XML, but only sees nulls rather than the actual text strings... Here is a shot of the DataViewer displaying 2 rows after reading the XML variable:

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

李白 2024-10-06 14:58:15

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

本质上,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。一旦我这样做了,包就会识别出单词值并成功完成。

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>

I discovered a way to get the values to populate... I'll post it here without giving myself points, in case anyone else encounters the same problem. This is just a "how to fix", but I'll give credit to anyone who can explain the "deeper whys".

Essentially, the XML needed to be wrapped in another root node:

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

Even though the original XML I used was valid, SSIS wanted it to be wrapped in an additional root node, which I named datarows. Once I did that the package recognized the word values and completed successfully.

alt text

The associated schema:

<?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>
神经大条 2024-10-06 14:58:15

我也遇到同样的问题,。我试图使用 Web 服务并将输出 xml 导入到 sql 2008 中的表中。

问题实际上在于 Web 服务在输出 xml 中生成的命名空间。我用过的技巧是
1. 将 Web 服务的输出存储在包级变量中
2. 添加“脚本任务”,以替换不需要的名称空间。
3. 然后使用“XMl Source Task”将数据导入到表中。

-克里斯...

I too had the same problem,. I was trying to consume a web service and import the output xml into a table in sql 2008.

The issue is really with the namespace that gets generated in the output xml by the webservice. The trick I have used was
1. Stored the output of the web service in a package level variable
2. Add a 'script task', to replace the unwanted name space.
3. Then used 'XMl Source Task' to import the data into a table.

-Kris...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文