Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Importing XML feed for SQL BULK load

 
   Database Help (Home) -> XML RSS
Next:  Lookup Question  
Author Message
JohnnyW

External


Since: Apr 02, 2009
Posts: 1



(Msg. 1) Posted: Thu Apr 02, 2009 8:25 am
Post subject: Importing XML feed for SQL BULK load
Archived from groups: microsoft>public>sqlserver>xml (more info?)

Hi there, I'm very new at this, but I'm trying to import products from an XML
feed to my database. I'm having two issues, but I think I understand one of
them.

The main problem I'm having is that I keep getting the error message:
"duplicate element definition 'product'"

Looking at the XML, you can see why this might be the case:

<?xml version="1.0" encoding="UTF-8"?>
<merchandiser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:
noNamespaceSchemaLocation="merchandiser.xsd">
<header>
<merchantId>24724</merchantId>
<merchantName>UNIQLO</merchantName>
<createdOn>2009-03-30/17:26:53</createdOn>
</header>
<product product_id="233984" name="Pique polo shirt"
sku_number="2000009298826">
<category>
<primary>T-shirts & Polos</primary>
<secondary>Men</secondary>
</category>
<URL>
<product>http://click.linksynergy.com/fs-bin/click?xxxxxx</product>
<productImage>http://www.uniqlo.co.uk/blah/blah/blah.jpg</productImage>
<buy/>
</URL>
<description>
<short>Pique polo shirt</short>
<long/>
</description>
<discount currency="GBP">
<amount/>
<type>amount</type>
</discount>
<price currency="GBP">
<sale begin_date="" end_date="">12.99</sale>
<retail>12.99</retail>
</price>
<brand>Uniqlo</brand>
<shipping>
<cost currency="GBP">
<amount/>
<currency>GBP</currency>
</cost>
<information/>
<availability>In stock</availability>
</shipping>
<keywords/>
<upc/>
<m1/>
<pixel>http://ad.linksynergy.com/fs-bin/show?xxxxx</pixel>
</product>
-- snip --

My schema looks like this:
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql" >

<ElementType name="primary" dt:type="string"/>
<ElementType name="secondary" dt:type="string"/>
<ElementType name="product" dt:type="string"/>
<ElementType name="productImage" dt:type="string"/>
<ElementType name="short" dt:type="string"/>
<ElementType name="retail" dt:type="string"/>
<ElementType name="brand" dt:type="string"/>
<AttributeType name="name" dt:type="string"/>
<AttributeType name="sku_number" dt:type="string"/>
<AttributeType name="currency" dt:type="string"/>

<ElementType name="merchandiser" sql:is-constant="1">
<element type="product" />
</ElementType>

<ElementType name="product" sql:relation="AffiliatesDataLinkShare">
<attribute type="name" sql:field="ProductName" />
<attribute type="sku_number" sql:field="SKU" />
<element type="brand" sql:field="Brand"/>
<element type="category" />
<element type="URL"/>
<element type="description" />
<element type="price"/>
</ElementType>

<ElementType name="category" sql:is-constant="1">
<element type="primary" sql:field="PrimaryCategory"/>
<element type="secondary" sql:field="SecondaryCategory"/>
</ElementType>

<ElementType name="URL" sql:is-constant="1">
<element type="product" sql:field="ProductURL"/>
<element type="productImage" sql:field="ImageURL"/>
</ElementType>

<ElementType name="description" sql:is-constant="1">
<element type="short" sql:field="Description"/>
</ElementType>

<ElementType name="price" sql:is-constant="1">
<attribute type="currency" sql:field="Currency" />
<element type="retail" sql:field="Price" />
</ElementType>

</Schema>

As you can see, Product is an element within URL but also wrapping element...
I've no idea if it's something I can fix, or a limitation of BULK load, or a
violation of XML standards? Any help would be greatly appreciated!

Also, I believe I'm using XDR, which might be a bit out-dated? Is this true?

Thanks again.

 >> Stay informed about: Importing XML feed for SQL BULK load 
Back to top
Login to vote
JohnnyW via SQLMonster.co

External


Since: Apr 02, 2009
Posts: 3



(Msg. 2) Posted: Thu Apr 02, 2009 1:28 pm
Post subject: Re: Importing XML feed for SQL BULK load [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I've re-written my schema in XSD to see if it helped any... Unfortunately it
doesn't look like it has Sad

I get the error: "relationship expected on 'product'".

Any advice would be massively appreciated!

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- definition of simple elements -->
<xs:element name="primary" type="xs:string"/>
<xs:element name="secondary" type="xs:string"/>
<xs:element name="product" type="xs:string"/>
<xs:element name="productImage" type="xs:string"/>
<xs:element name="short" type="xs:string"/>
<xs:element name="retail" type="xs:string"/>

<!-- definition of attributes -->
<xs:attribute name="currency" type="xs:string"/>
<xs:attribute name="product_id" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>

<!-- definition of complex elements -->
<xs:element name="merchandiser">
<xs:complexType>
<xs:sequence>
<xs:element name="product">
<xs:complexType>
<xs:sequence>
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element ref="primary"/>
<xs:element ref="secondary"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="URL">
<xs:complexType>
<xs:sequence>
<xs:element ref="product"/>
<xs:element ref="productImage"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="description">
<xs:complexType>
<xs:sequence>
<xs:element ref="short"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="price">
<xs:complexType>
<xs:sequence>
<xs:element ref="retail"/>
</xs:sequence>
<xs:attribute ref="currency"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute ref="product_id"/>
<xs:attribute ref="name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

--
Message posted via http://www.sqlmonster.com

 >> Stay informed about: Importing XML feed for SQL BULK load 
Back to top
Login to vote
JohnnyW via SQLMonster.co

External


Since: Apr 02, 2009
Posts: 3



(Msg. 3) Posted: Thu Apr 02, 2009 2:25 pm
Post subject: Re: Importing XML feed for SQL BULK load [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Woohoo! I managed to fix that last problem quite easily... Now I've set up my
SQL bits as well and it all works apart from the BULK LOAD caveat: You can't
have an attribute within a constant element.

I've highlighted the problem line below, what can I do about it?

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-
microsoft-com:mapping-schema">
<!-- definition of simple elements -->
<xs:element name="primary" type="xs:string" sql:field="PrimaryCategory" />
<xs:element name="secondary" type="xs:string" sql:
field="SecondaryCategory"/>
<xs:element name="product" type="xs:string" sql:field="ProductURL"/>
<xs:element name="productImage" type="xs:string" sql:field="ImageURL"/>
<xs:element name="short" type="xs:string" sql:field="Description"/>
<xs:element name="retail" type="xs:string" sql:field="Price"/>
<xs:element name="brand" type="xs:string" sql:field="Brand"/>
<!-- definition of attributes -->
<xs:attribute name="currency" type="xs:string" sql:field="Currency"/>
<xs:attribute name="product_id" type="xs:string" sql:field="ProductName"/>
<xs:attribute name="name" type="xs:string" sql:field="SKU"/>
<!-- definition of complex elements -->
<xs:element name="merchandiser" sql:is-constant="1">
<xs:complexType>
<xs:sequence>
<xs:element name="product" sql:relation="AffiliatesDataLinkShare">
<xs:complexType>
<xs:sequence>
<xs:element name="category" sql:is-constant="1">
<xs:complexType>
<xs:sequence>
<xs:element ref="primary"/>
<xs:element ref="secondary"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="URL" sql:is-constant="1">
<xs:complexType>
<xs:sequence>
<xs:element ref="product"/>
<xs:element ref="productImage"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="description" sql:is-constant="1">
<xs:complexType>
<xs:sequence>
<xs:element ref="short"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="price" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element ref="retail"/>
</xs:sequence>
<xs:attribute ref="currency"/> <!-- PROBLEM!!! -->
</xs:complexType>
</xs:element>
<xs:element ref="brand" />
</xs:sequence>
<xs:attribute ref="product_id"/>
<xs:attribute ref="name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-xml/200904/1
 >> Stay informed about: Importing XML feed for SQL BULK load 
Back to top
Login to vote
JohnnyW via SQLMonster.co

External


Since: Apr 02, 2009
Posts: 3



(Msg. 4) Posted: Mon Apr 13, 2009 7:25 am
Post subject: Re: Importing XML feed for SQL BULK load [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Turns out there was nothing I could do. I simply created a fake element and
gave it a default value. Not perfect, but it worked in this particular
situation.

--
Message posted via http://www.sqlmonster.com
 >> Stay informed about: Importing XML feed for SQL BULK load 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
XML Bulk Load - I am trying to upload data from my XML file to SQL database using xsd schema file. I am doing using the XML bulkload in VB. The piece of code I have writted is as follows : Dim objXBulkLoad as object Set objXBulkLoad =..

Help - XML bulk load to M:N with attributes - Hi all. I am new to XML bulk load. I am trying to load an XML document into an M:N relation with additional attributes. The actual XML file and table structures are similar to the supplied specs. I have read about how to use the chaining relationships to...

SQL XML Bulk Load in a Windows Service - Hi, I'm trying to use the XML Bulk Load object in a Windows service. To do this i've written the following method: private void uploadXML() { try { SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class objBL = new ..

Third post of the same problem load XML file using bulk in.. - Sorry for my insistence, but his is my third post of the same problem, none can help me, i really need help ... I tried to load a file (Data.xml) into SQLServer 2000 using Schema.xml file but when i load the file i check the table and nothing was..

xsd sql schema relation problem bulk load - self join - Here is a snippet of my xml (based on the ecb daily) and with xmlns removed: <?xml version="1.0" encoding="UTF-8"?> <gesmes> <Cube> <Cube time='2006-11-01'> <Cube currency='USD' rate='1.2757'/> ...
   Database Help (Home) -> XML All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]