473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Mapping XSD to DB via C#

I have a XML file as shown below.

Expand|Select|Wrap|Line Numbers
  1. <HouseInfo>
  2.     <HouseNumber>1</HouseNumber>
  3.     <HouseLog>
  4.         <RoomInfo>
  5.             <RoomNumber>1</RoomNumber>
  6.             <Timestamp>2017-12-29T12:16:51</Timestamp>
  7.             <Furnitures>
  8.                 <Table>
  9.                     <Color>Blue</Color>
  10.                     <Height>23</Height>
  11.                 </Table>
  12.             </Furnitures>
  13.             <ToolCounts>
  14.                 <Scope>1</Scope>
  15.             </ToolCounts>
  16.         </RoomInfo>
  17.  
  18.         <RoomInfo>
  19.             <RoomNumber>2</RoomNumber>
  20.             <Timestamp>2017-12-29T15:43:23</Timestamp>
  21.             <Furnitures>
  22.                 <Table>
  23.                     <Color>Black</Color>
  24.                     <Height>35.2</Height>
  25.                 </Table>
  26.             </Furnitures>
  27.             <ToolCounts>
  28.                 <Scope>1</Scope>
  29.             </ToolCounts>
  30.             <Bathroom>
  31.                 <Code>1234</Code>
  32.                 <Faucets>3></Faucets>
  33.             </Bathroom>
  34.         </RoomInfo>
  35.  
  36.         <RoomInfo>
  37.             <RoomNumber>2</RoomNumber>
  38.             <Timestamp>2017-12-29T15:45:48</Timestamp>
  39.             <Furnitures>
  40.                 <Table>
  41.                     <Color>Red</Color>
  42.                     <Height>98.56</Height>
  43.                 </Table>
  44.             </Furnitures>
  45.             <ToolCounts>
  46.                 <Scope>1</Scope>
  47.             </ToolCounts>
  48.             <Bathroom>
  49.                 <Code>1234</Code>
  50.                 <Faucets>2></Faucets>
  51.             </Bathroom>
  52.         </RoomInfo>
  53.     </HouseLog>
  54. </HouseInfo>
  55.  
And i created a XSD from this XML.

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->
  3. <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  4.   <xs:element name="HouseInfo">
  5.     <xs:complexType>
  6.       <xs:sequence>
  7.         <xs:element name="HouseNumber" type="xs:unsignedByte" />
  8.         <xs:element name="HouseLog">
  9.           <xs:complexType>
  10.             <xs:sequence>
  11.               <xs:element maxOccurs="unbounded" name="RoomInfo">
  12.                 <xs:complexType>
  13.                   <xs:sequence>
  14.                     <xs:element name="RoomNumber" type="xs:unsignedByte" />
  15.                     <xs:element name="Timestamp" type="xs:dateTime" />
  16.                     <xs:element name="Furnitures">
  17.                       <xs:complexType>
  18.                         <xs:sequence>
  19.                           <xs:element name="Table">
  20.                             <xs:complexType>
  21.                               <xs:sequence>
  22.                                 <xs:element name="Color" type="xs:string" />
  23.                                 <xs:element name="Height" type="xs:decimal" />
  24.                               </xs:sequence>
  25.                             </xs:complexType>
  26.                           </xs:element>
  27.                         </xs:sequence>
  28.                       </xs:complexType>
  29.                     </xs:element>
  30.                     <xs:element name="ToolCounts">
  31.                       <xs:complexType>
  32.                         <xs:sequence>
  33.                           <xs:element name="Scope" type="xs:unsignedByte" />
  34.                         </xs:sequence>
  35.                       </xs:complexType>
  36.                     </xs:element>
  37.                     <xs:element minOccurs="0" name="Bathroom">
  38.                       <xs:complexType>
  39.                         <xs:sequence>
  40.                           <xs:element name="Code" type="xs:unsignedShort" />
  41.                           <xs:element name="Faucets" type="xs:string" />
  42.                         </xs:sequence>
  43.                       </xs:complexType>
  44.                     </xs:element>
  45.                   </xs:sequence>
  46.                 </xs:complexType>
  47.               </xs:element>
  48.             </xs:sequence>
  49.           </xs:complexType>
  50.         </xs:element>
  51.       </xs:sequence>
  52.     </xs:complexType>
  53.   </xs:element>
  54. </xs:schema>
After creating the XSD file i used the XSD2DB.exe to create all the tables in the MS SQL Server.

I have a C# application and in that SQLXMLBulkLoad library is being used to load the XML content to DB. I pass the XSD and XML as parameters to the Execute function. Now am getting below error.

relationship expected on 'HouseLog'.


What I have tried:

I tried adding- sql:is-constant="1"
to HouseLog and some other tags and that removes the above error, but brings up another error saying that it cannot find specific columns in DB even though they exist.

So i guess, the problem is - i need to define relationships properly in the XSD and i have no idea how to do it. Hope someone can suggest some solutions.

Please give me some samples as am quite new to this schema to DB conversation and have ran out of ideas. Thanks in advance.
Jan 13 '18 #1
0 2039

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Pierre Fortin | last post by:
Hi! "Python Essential Reference" - 2nd Ed, on P. 47 states that a string format can include "*" for a field width (no restrictions noted); yet... >>> "%*d" % (6,2) # works as expected ' ...
6
by: naruto | last post by:
Hi all, I have the following being defined in a A.cxx file. // define in source file. Not exported to the outside world (this cannot be // moved to the header file ) #define CHANNEL_0 0...
10
by: mike | last post by:
regards: Where to find tag mapping-table of HTML translated to XHTML1.0 Any positive suggestion is welcome. thank you May goodness be with you all
1
by: Tamas Hegedus | last post by:
Hi! I am looking for an xml-object mapping tool ('XML Data Binding-design time product') where I can define the mapping rules in 'binding files' and the parser is generated automatically. ...
3
by: Elder Hyde | last post by:
I was reading this interview with Hejlsberg, when suddenly the conversation turned to O/R mapping. Hejlsberg talked as if he had had to design an O/R mapping for .NET (he said ".NET had each one of...
4
by: BentleyInc | last post by:
I'm trying to find a way to add a whildcard application mapping to aspnet_isapi.dll in IIS programmatically.... been looking into IIS administrator reference but didn't find the right function to...
1
by: none | last post by:
Hi, I'm trying to establish table mappings, and I've hit a snag. At the point to where I try to fill the schema (DB_adapter.FillSchema), I get an exception, and the message is as follows:...
1
by: Ram | last post by:
Hey, I'm having a trouble mapping a connecting between 2 of my tables. We have 2 tables - the simplest "dept", "emp" tables which are mapped to 2 classes. Class Dept contains 2 properties for...
6
by: Jan Kucera | last post by:
Hi, does anybody know about wildcard mapping ASP.NET 2 in IIS6? Any tutorial? Thanks, Jan
0
by: edurazee | last post by:
I am trying to create a Unidirectional one-to-one relationship using NHibernate. Example: An Order is given by a Customer. Customer{ID, Name, Address} OrderN{ID, Customer, OrderDate} Here,...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.