How to define an XSD for an XML file with two elements having the same name

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have an XML data file with two data elements that are named the same, however there contents are distinct. Here is a sample of the data:
<br/>
<ROW><br/>
<CONTROL_BUSINESS_ENTITY_GROUP>10% Ownership</CONTROL_BUSINESS_ENTITY_GROUP><br/>
<KEY_CODE>20702</KEY_CODE><br/>
<KEY_NAME>The Company, LLC.</KEY_NAME><br/>
<KEY_CODE>123456789</KEY_CODE><br/>
<KEY_NAME>DOE, JOHN </KEY_NAME><br/>
<START_DATE>2/4/2005</START_DATE><br/>
<STOP_DATE></STOP_DATE><br/>
<CONTROL_BUSINESS_ENTITY_ROLE>Owned</CONTROL_BUSINESS_ENTITY_ROLE><br/>
<OWNERSHIP_PERCENT></OWNERSHIP_PERCENT><br/>
<OWENERSHIP_AMOUNT></OWENERSHIP_AMOUNT><br/>
</ROW>
As you can see, there are two instances of KEY CODE and KEY NAME.
My goal is to import this data via SSIS, which means I have to define an XSD. Here is the XSD file I tried:
<?xml version="1.0"?><br/>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema <br/>
<xs:element name="ROWDATA <br/>
<xs:complexType><br/>
<xs:sequence><br/>
<xs:element minOccurs="0" maxOccurs="unbounded" name="ROW <br/>
<xs:complexType><br/>
<xs:sequence><br/>
<xs:element minOccurs="0" name="CONTROL_BUSINESS_ENTITY_GROUP" type="xs:string" /><br/>
<xs:element minOccurs="0" name="KEY_CODE_1" type="xs:string" /><br/>
<xs:element minOccurs="0" name="KEY_NAME_1" type="xs:string" /><br/>
<xs:element minOccurs="0" name="KEY_CODE_2" type="xs:string" /><br/>
<xs:element minOccurs="0" name="KEY_NAME_2" type="xs:string" /><br/>
<xs:element minOccurs="0" name="START_DATE" type="xs:string" /><br/>
<xs:element minOccurs="0" name="STOP_DATE" type="xs:string" /><br/>
<xs:element minOccurs="0" name="CONTROL_BUSINESS_ENTITY_ROLE" type="xs:string" /><br/>
<xs:element minOccurs="0" name="OWNERSHIP_PERCENT" type="xs:string" /><br/>
<xs:element minOccurs="0" name="OWENERSHIP_AMOUNT" type="xs:string" /><br/>
</xs:sequence><br/>
</xs:complexType><br/>
</xs:element><br/>
</xs:sequence><br/>
</xs:complexType><br/>
</xs:element><br/>
</xs:schema>
This resulted in no data for either KEY CODE or KEY NAME. Im assuming this is because the element name from the XSD does not match the XML data. Ive tried to name the elements the same, however this creates the following error in my SSIS package:
Warning 1 Multiple definition of element KEY_CODE causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained
directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder
of the sequence.

Any suggestions on how to proceed or what to try next would be appreciated!

View the full article
 
Back
Top