473,800 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ 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 ><BillOfMateria l>
<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 PartLocationSte p {
public PartLocationSte pBillOfMaterial s BillOfMaterials ;
public PartLocationSte pIllustration Illustration;

[System.Xml.Seri alization.XmlEl ementAttribute( "Task")]
public PartLocationSte pTask[] Task;

[System.Xml.Seri alization.XmlAt tributeAttribut e
Form=System.Xml .Schema.XmlSche maForm.Qualifie d, DataType="integ er")]
public string sequence;
}

The syntax I am using is as follows:

partLocStep.Bil lOfMaterials = partLocStepBOM;
partLocStep.Ill ustration = partLocStepIllu stration;
partLocStep.Tas k = partLocStepTask ;
partLoc.Step = partLocStep;
part.Location = partLoc;

//Add Part Object to Parts collection
partList.Add(pa rt)

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 1601

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

Similar topics

4
1774
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 have a function called foo? What if I have 5 different objects, all descended from Ancestor? Do
38
3734
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 objects and how to implement them with c#? I would appreciate any help. Thanks.
2
2009
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 perform all my initial class object instaniations using sub new() procedures I'm using this project to learn the ins and outs of OOA and OOD, so instead of doing everything in code behind pages I have lots of objects now created
0
281
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 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...
2
1364
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 of the custom object, it only contains the variable declarations. Does the wsdl.exe that comes with WSE handle this differently? Is there some other mechanism I can use besides writing a custom decorator for wsdl.exe to generate proxy classes that...
12
5342
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 the custom employee class and have built it as a separate library (employee.dll). This employee.dll is being referenced by both the web service and the windows application. I face the following problem when I send this class to the webservice.
1
510
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 develop the webservice in and created a basic webservice which just returns my "Order" object as a string. I then added some code to my app to call my webservice and pass it an
20
7015
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 = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
1
2266
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 function () { this.x++; } obj.inc() obj.x result 2
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10035
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6813
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4149
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 we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.