在 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 Source [79]] Error: The XML Source was unable to process the XML
data. 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 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>
在你的真实数据中搜索xsi:nil="true"
XML。
为空或 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>
我正在尝试通过 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 Source [79]] Error: The XML Source was unable to process the XML data. 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 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>
在你的真实数据中搜索xsi:nil="true"
XML。
为空或 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>