The Component “XML Source” Was unable to process the XML data. ambiguous complextype definition. The Element '%' has multiple members named '%'

情到浓时终转凉″ 提交于 2021-02-20 02:52:46

问题


I am trying to load the XMl file using SSIS. I have My Sample XML and corresponding XSD.

In my SSIS package XML Soruce, provided the Input XML File path and XSD path and when i am tryng to see the columns then i was getting the below error

The Component "XML Source" Was unable to process the XML data. ambiguous complextype definition. The Element 'childusages' has multiple members named 'usages'

And i tried validating the XML and corresponding XSD with .Net(C# or VB) and it passed the validation.

Sample XML File:

<gmx-rcc>
 <statement>
  <summaryAccountName>test test</summaryAccountName>
  <accounts>
   <account>
    <accountnumber>abcdefghijk</accountnumber>
    <meters>
     <meter>
      <mnumber>a123456</mnumber>
      <usages>
       <usage>
       <actualUsage>1234</actualUsage>
       <childUsages>
        <usage><actualUsage>1234</actualUsage></usage>
        <usage><actualUsage>1234</actualUsage></usage>
        <usage><actualUsage>1234</actualUsage></usage>
       </childUsages>
       </usage>
      </usages>
     </meter>
    </meters>
   </account>
  </accounts>
 </statement>
 </gmx-rcc>

Corresponding XSD:

<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="gmx-rcc">
  <xsd:complexType >
   <xsd:sequence maxOccurs="unbounded" minOccurs="0">
    <xsd:element type="statement" name="statement"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 <xsd:complexType name="statement" >
  <xsd:choice maxOccurs="unbounded" minOccurs="0">
   <xsd:element name="summaryAccountName" type="xsd:string"/>
   <xsd:element ref="accounts"/>
  </xsd:choice>
 </xsd:complexType>
 <xsd:element name="accounts">
  <xsd:complexType>
   <xsd:sequence maxOccurs="unbounded" minOccurs="0">
    <xsd:element name="account" type="account"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 <xsd:complexType name="account" >
  <xsd:choice maxOccurs="unbounded" minOccurs="0">
   <xsd:element name="accountnumber" type="xsd:string"/>
   <xsd:element ref="meters"/>
  </xsd:choice>
 </xsd:complexType>
 <xsd:element name="meters">
  <xsd:complexType>
   <xsd:sequence maxOccurs="unbounded" minOccurs="0">
    <xsd:element name="meter" type="meter"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 <xsd:complexType name="meter" >
  <xsd:choice maxOccurs="unbounded" minOccurs="0">
   <xsd:element name="mnumber" type="xsd:string"/>
   <xsd:element ref="usages"/>
  </xsd:choice>
 </xsd:complexType>
 <xsd:element name="usages">
  <xsd:complexType>
   <xsd:sequence maxOccurs="unbounded" minOccurs="0">
    <xsd:element name="usage" type="usage"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 <xsd:complexType name="usage" >
  <xsd:choice maxOccurs="unbounded" minOccurs="0">
   <xsd:element name="actualUsage" type="xsd:decimal"/>
   <xsd:element ref="childUsages"/>
  </xsd:choice>
 </xsd:complexType>
 <xsd:element name="childUsages">
  <xsd:complexType >
   <xsd:sequence maxOccurs="unbounded" minOccurs="0">
    <xsd:element name="usage" type="usage"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 </xsd:schema>

回答1:


I think SSIS Source component can'tunderstand if the XSD contains custom Type( in this case name="account" type="account").

But stil we can parse the XML using XSLT with the simple steps

  1. use XML Task to validate XML and XSD
  2. XSLT operation to simplify xml data and then pass it to xml source .

See example:

http://www.rad.pasfu.com/index.php?/archives/21-XML-Task-Changing-Style-of-Data-XSLT.html

-Vinay



来源:https://stackoverflow.com/questions/12377361/the-component-xml-source-was-unable-to-process-the-xml-data-ambiguous-complex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!