473,471 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Assigning objects to object properties of XSD generated classes

I have generated classes based on an Xml schema file (xsd) using the XSD.exe tool.

My goal is to:

- write an application that can parse XML documents
- fill objects (based on the generated classes) with the XML data in element nodes or attributes
- assemble the objects so they are contained in their parent
- add the resulting object to an arrayList

The problem I’m having is that I am not sure how to go about assigning an object to an object variable in the base class. I keep getting conversion errors when I compile indicating "Cannot implicitly convert type Part.[Object variable] to [Object of Same Type as Object Variable]"

The hierarchy of the xml schema is as follows:

<Part nbr=”73894” rev=”9847”>
<Location fac=”Detroit” station=”9782”>
<Step seq=”09”>
<BillOfMaterial><BillOfMaterial>
<Task></Task>
<Illustration></Illustration>
</Step>
</Location>
</Part>

For each element/node in the xml doc,

- I instantiate the corresponding XSD generated object
- assign attribute values to corresponding class property/field
- Next, I attempt to assign child objects to the parent object variables
- LASTLY, I add the object to an arraylist

The syntax/code for one of the generated classes is as follows:

public class PartLocationStep {
public PartLocationStepBillOfMaterials BillOfMaterials;
public PartLocationStepIllustration Illustration;

[System.Xml.Serialization.XmlElementAttribute("Task ")]
public PartLocationStepTask[] Task;

[System.Xml.Serialization.XmlAttributeAttribute
Form=System.Xml.Schema.XmlSchemaForm.Qualified, DataType="integer")]
public string sequence;
}

The syntax I am using is as follows:

partLocStep.BillOfMaterials = partLocStepBOM;
partLocStep.Illustration = partLocStepIllustration;
partLocStep.Task = partLocStepTask;
partLoc.Step = partLocStep;
part.Location = partLoc;

//Add Part Object to Parts collection
partList.Add(part)

Is it my syntax for assigning the individual objects back to the parent object property/variable? Do I need to modify code inside the generated classes? Is there an easier way to do what I am trying to do?

I am fishing for answers? Hopefully, someone out there can help me or point me in the right direction.

Thanks
Jul 21 '05 #1
0 1573

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: lkrubner | last post by:
I'm reading an essay, I think one of Crockford's, and it has this example in it: function Demo() { } Demo.prototype = new Ancestor(); Demo.prototype.foo = function () { } ; Does Ancestor now...
38
by: Radi Radichev | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
2
by: Chris | last post by:
Hi, I am building a single webform/webpage asp.net application using VB.NET. I have created lots of classes for this web application. On page load I use a facade controller pattern class to...
0
by: vanGogh | last post by:
I have generated classes based on an Xml schema file (xsd) using the XSD.exe tool. My goal is to: - write an application that can parse XML documents - fill objects (based on the generated...
2
by: Sumit | last post by:
Hi All... What is the best way of binding a custom object that is returned via a Web Service? From what Ive seen, the proxy class generated by wsdl.exe doesnt include properties for the members...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
1
by: Nick Gilbert | last post by:
Hi, I'm trying to create a system whereby my desktop application submits it's order to an online server using a webservice (pretty standard!). So, I added a new project to my solution to...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
1
by: weston | last post by:
So, the following apparently works as a method of grafting a method onto an object (using the squarefree JS shell): obj = { x: 1, inc: null } result obj.inc = function () { this.x++ } result...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.