简体   繁体   English

在SSIS中使用“标题,详细信息和尾部”部分导入XML文件

[英]Import XML file with Header, Detail, and Trailer section in SSIS

I am attempting to load an XML file through SSIS. 我正在尝试通过SSIS加载XML文件。 I want to note that I did generate the XSD through SSIS. 我想指出的是我确实通过SSIS生成了XSD。 Here is the sample file which I was able to load successfully: 这是我能够成功加载的示例文件:

<?xml version="1.0" encoding="UTF-8"?>
<ACOParticipantData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Header>
    <HeaderCode>HDR_PRVDR</HeaderCode>
    <FileCreationDate>20160101</FileCreationDate>
    <ACOProgCode>21</ACOProgCode>
  </Header>
  <Participants>
    <Participant>
      <ACO_ID>V199</ACO_ID>
     <TIN>123456789</TIN>
      <Old_TIN>987654321</Old_TIN>
      <Org_NPI>1234567890</Org_NPI>
      <Ind_NPI>1234567890</Ind_NPI>
      <CCN>123456</CCN>
      <PRG_Eff_Dt>20160101</PRG_Eff_Dt>
      <PRG_Term_Dt>20161231</PRG_Term_Dt>
      <ErrorCode>44</ErrorCode>
    </Participant>
  </Participants>
  <Trailer>
    <TrailerCode>TRL_PRVDR</TrailerCode>
    <FileCreationDate>20160101</FileCreationDate>
    <RecordCount>1</RecordCount>
  </Trailer>
</ACOParticipantData>

The production file has the same format but I am now receiving the below error in SSIS: 生产文件具有相同的格式,但是我现在在SSIS中收到以下错误:

[XML Source [79]] Error: The XML Source was unable to process the XML data. [XML源[79]]错误:XML源无法处理XML数据。 The Xml source document contains the "xsi:nil" attribute with a value of true on the "Old_TIN" element, therefore the element must be empty. Xml源文档包含“ xsi:nil”属性,在“ Old_TIN”元素上的值为true,因此该元素必须为空。

However, there doesn't seem to be anything erroneous about the source file. 但是,源文件似乎没有任何错误。 How would one go about debugging and ingesting this file successfully? 如何调试和成功摄取此文件?

EDIT: Out of the two production files, I've altered the smaller one slightly but it will look like this: 编辑:在两个生产文件中,我已略微更改了较小的文件,但它看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<ACOParticipantData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
    <HeaderCode>HDR_PRVDR</HeaderCode>
    <FileCreationDate>20160602</FileCreationDate>
    <ACOProgCode>21</ACOProgCode>
</Header>
<Participants xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Participant>
        <ACO_ID>V130</ACO_ID>
        <TIN>123456789</TIN>
        <Old_TIN xsi:nil="true">
        </Old_TIN>
        <Org_NPI xsi:nil="true">
        </Org_NPI>
        <Ind_NPI>0987654321</Ind_NPI>
        <CCN xsi:nil="true">
        </CCN>
        <PRG_Eff_Dt>20160101</PRG_Eff_Dt>
        <PRG_Term_Dt>20160601</PRG_Term_Dt>
        <ErrorCode>00</ErrorCode>
    </Participant>
    <Participant>
        <ACO_ID>V130</ACO_ID>
        <TIN>111222333</TIN>
        <Old_TIN xsi:nil="true">
        </Old_TIN>
        <Org_NPI xsi:nil="true">
        </Org_NPI>
        <Ind_NPI>4445556667</Ind_NPI>
        <CCN xsi:nil="true">
        </CCN>
        <PRG_Eff_Dt>20160101</PRG_Eff_Dt>
        <PRG_Term_Dt>20160601</PRG_Term_Dt>
        <ErrorCode>00</ErrorCode>
    </Participant>
</Participants>
<Trailer>
    <TrailerCode>TRL_PRVDR</TrailerCode>
    <FileCreationDate>20160602</FileCreationDate>
    <RecordCount>2</RecordCount>
</Trailer>
</ACOParticipantData>

Search for xsi:nil="true" in your real data XML . 实际数据XML中搜索xsi:nil="true"

Being empty or being NULL is close but not exactly the same. 空或为NULL接近,但不完全相同。 In some cases this is needed to be distinguished. 在某些情况下,需要对此进行区分。

If an element is marked as NULL like - in your case probably: <Old_TIN xsi:nil="true"> there should be no value for this element. 如果一个元素被标记为NULL例如-在您的情况下,可能是: <Old_TIN xsi:nil="true"> ,该元素不应有任何值。

If there is the xsi:nil flag and a value it's a contradiction... 如果有xsi:nil标志一个值,这是一个矛盾...

UPDATE 更新

According to your edits you find this there (reduced) 根据您的编辑,您可以在此找到(减少)

<Participant>
    <Old_TIN xsi:nil="true">
    </Old_TIN>
    <Org_NPI xsi:nil="true">
    </Org_NPI>
    <CCN xsi:nil="true">
    </CCN>
</Participant>

These elements are not NULL , they contain a line break and spaces... Try change this to 这些元素不是NULL ,它们包含换行符和空格。尝试将其更改为

<Participant>
    <Old_TIN xsi:nil="true"/>
    <Org_NPI xsi:nil="true"/>
    <CCN xsi:nil="true"/>
</Participant>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM