簡體   English   中英

在SSIS中使用“標題,詳細信息和尾部”部分導入XML文件

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

我正在嘗試通過SSIS加載XML文件。 我想指出的是我確實通過SSIS生成了XSD。 這是我能夠成功加載的示例文件:

<?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>

生產文件具有相同的格式,但是我現在在SSIS中收到以下錯誤:

[XML源[79]]錯誤:XML源無法處理XML數據。 Xml源文檔包含“ xsi:nil”屬性,在“ Old_TIN”元素上的值為true,因此該元素必須為空。

但是,源文件似乎沒有任何錯誤。 如何調試和成功攝取此文件?

編輯:在兩個生產文件中,我已略微更改了較小的文件,但它看起來像這樣:

<?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>

實際數據XML中搜索xsi:nil="true"

空或為NULL接近,但不完全相同。 在某些情況下,需要對此進行區分。

如果一個元素被標記為NULL例如-在您的情況下,可能是: <Old_TIN xsi:nil="true"> ,該元素不應有任何值。

如果有xsi:nil標志一個值,這是一個矛盾...

更新

根據您的編輯,您可以在此找到(減少)

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

這些元素不是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