RE: SQLXMLBulkLoad and Keys

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




In the XML, Sales_Price is a child of Sales_Price_Key_Info, which is in turn
a child of Sales_Prices, and this hierarchy is not represented in the schema.
For me it is easier to see it with all the indentations:
<PAW_Item xsi:type="paw:item">
<ID xsi:type="paw:id">#114-11</ID>
<Description>14 GAUGE BLACK WIRE</Description>
<Description_for_Sales>14 GAUGE BLACK WIRE</Description_for_Sales>
<Sales_Prices>
<Sales_Price_Info Key="1">
<Sales_Price>0.14000</Sales_Price>
</Sales_Price_Info>
</Sales_Prices>
<Type>70</Type>
</PAW_Item>
So it looks like there would/could be multiple Sales_Prices per item - which
would imply a second table with a foreign key on the temp_Inventory ID. To
get that, the prices part of the xsd would have to include the 2 other
levels, more like this - which does not include the annotations:
<xsd:element name="Sales_Prices" sql:is-constant="1" />
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Sales_Price_Info"
sql:relation="temp_Some_Table_Name">
<xsd:annotation><!-- xsd:appinfo keys relationship to the id info
would be here--></xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Sales_Price" type="xsd:float"
sql:field="PriceLevel1" />
</xsd:sequence>
<xsd:attribute name="Key" type="xsd:integer" sql:field="Key"
sql:datatype="int" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

But it looks like you are trying to put it all into one table - maybe with
different column names for each Key? I have done that in past by creating
the two tables for the bulkload, then updating the separate "many" columns
with update queries...


"somuch" wrote:

> I've created a DTS package to bulk import an XML file into SQL Server
> using SQLXMLBulkLoad.SQLXMLBulkLoad.3.0. The first 4 fields (ItemID,
> ItemDescription, DescriptionforSales, ItemType) import but PriceLevel1
> doesn't and is just set to null. I admit I don't know much about XML
> and this is my first attempt at importing it. I know the problem lies
> in the XSD file having something to do with the Sales_Price_Info key
> but can't figure out how to go about it. Any help would be appreciated.
>
> thanks,
>
>
> Below is part of the XML file
> -----------------------------
>
> <PAW_Item xsi:type="paw:item">
> <ID xsi:type="paw:id">#114-11</ID>
> <Description>14 GAUGE BLACK WIRE</Description>
> <Description_for_Sales>14 GAUGE BLACK WIRE</Description_for_Sales>
> <Sales_Prices>
> <Sales_Price_Info Key="1">
> <Sales_Price>0.14000</Sales_Price>
> </Sales_Price_Info>
> </Sales_Prices> <Type>70</Type>
> </PAW_Item>
>
>
> Below is the XSD File
> ---------------------
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
> <xsd:element name="PAW_Item" sql:relation="temp_Inventory" >
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="ID" type="xsd:string" sql:field="ItemID" />
> <xsd:element name="Description" type="xsd:string"
> sql:field="ItemDescription" />
> <xsd:element name="Description_for_Sales" type="xsd:string"
> sql:field="DescriptionforSales" />
> <xsd:element name="Type" type="xsd:string" sql:field="ItemType" />
> <xsd:element name="Sales_Price" type="xsd:float"
> sql:field="PriceLevel1" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
>
.



Relevant Pages

  • RE: ReadXML and data types
    ... If I want to put the schema in a separate XSD file, ... with my XML file for ReadXml to use? ... > Kevin Yu ...
    (microsoft.public.dotnet.xml)
  • Re: How to associate XML with XSD
    ... "MyDefaultNamespace" is usually a string that looks like a ... that my XML file has an associated XSD file? ... the schema of app.config files even though the text of the app.config file ...
    (microsoft.public.dotnet.xml)
  • Re: Importing existing XSD schema file into Visual Studio 2005
    ... XML file based on that schema? ... I've been given an XSD file by a 3rd party. ... there are tools in VS.NET to generate the typed DataSet classes ...
    (microsoft.public.dotnet.xml)
  • Xerces-C++ Schema validation
    ... I'm looking for a way of validating/parsing the xsd file (schema), ... only been able of validating the xml file with the corresponding ... schema, but what i want is only validate the xsd file, to check if the ...
    (comp.text.xml)
  • Re: Deserialize from SelectSingleNode
    ... I thought it was talking about the namespace for XXX, ... my class name was generated from an XSD file for the ... XML file I'm working with. ... The class name has the form AAABBBCCC, ...
    (microsoft.public.dotnet.xml)