>我正在尝试通过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 源文档包含带有 "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>