473,385 Members | 1,320 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,385 software developers and data experts.

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 1569

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...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.