Hi,

I am having hard time building a XML Schema used during an XML Bulk Load.

The XML file comes from an external source which means that I am not allowed to improve its structure. It contains sublevels with attributes.

My goal is to load the data once, by carrying the attributes of the first element (location) with the data from the lowest element (dollars and percent). In previous tests, I was able to load either the locations or the dollars / percent, but not them all together. I can generate one or two tables into the database, it does not matter.

I will appreciate any help.

Thank you.

1) XML File

Here is an extraction of the file.

<?xml version="1.0" encoding="utf-8" ?>
<NewDataSet>
<Location name="Chicago, IL" id = "12345" >
<houses year="2001">
<dollars>15469.412</dollars>
<percent>10.23</percent>
</houses>
<appartments year="2001">
<dollars>45872.2</dollars>
<percent>5.3</percent>
</appartments>
<houses year="2002">
<dollars>872369.154</dollars>
<percent>34.475</percent>
</houses>
<appartments year="2002">
<dollars>65748.21</dollars>
<percent>12.75</percent>
</appartments>
</Location>
<Location name="Detroit, MI" id = "45878" >
<houses year="2001">
<dollars>578945.12</dollars>
<percent>21.45</percent>
</houses>
<appartments year="2001">
<dollars>65479.0</dollars>
<percent>58.326</percent>
</appartments>
<houses year="2002">
<dollars>5471.23</dollars>
<percent>2.341</percent>
</houses>
<appartments year="2002">
<dollars>479636</dollars>
<percent>18.24</percent>
</appartments>
</Location>
</NewDataSet>

2) XML Schema

Here is the schema that I wrote

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">

<xsd:element name="NewDataSet" sql:mapped="false">
<xsd:complexType>

<xsd:sequence>

<xsd:element name="Location" sql:relation="Locations">
<xsd:complexType>
<xsd:sequence>

<xsd:element name="houses">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="dollars" sql:field="HousesDollars" type="xsd:string" />
<xsd:element name="percent" sql:field="HousesDollars" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="year" sql:field="HousesYear" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

<xsd:element name="appartments">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="dollars" sql:field="AppartmentsDollars" type="xsd:string" />
<xsd:element name="percent" sql:field="AppartmentsPercent" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="year" sql:field="AppartmentsYear" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

</xsd:sequence>
<xsd:attribute name="name" sql:field="LocationName" type="xsd:string"/>
<xsd:attribute name="id" sql:field="LocationId" type="xsd:string"/>

</xsd:complexType>
</xsd:element>

</xsd:sequence>

</xsd:complexType>
</xsd:element>

</xsd:schema>

I am not getting any error but nothing is loaded. I believe that this schema does not match the data structure.