473,325 Members | 2,870 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,325 software developers and data experts.

Support for creating C# classes out of Schema or DTDs

I am reading data out of a relational database and converting the data to XML.
I after I send this data from a web service I am reading the data using
XMLTextReader calls like the following:
if(customerReader.NodeType == XmlNodeType.Element)
if (customerReader.LocalName.Equals("COLUMN1NAME"))

I hate using the colmn names like this (or in a constant).
What I want to do is specify the structure of the XML doc wiht a Schema (or
DTD) and then generate an object model from this. The Schema would have to
match my query i.e. there needs to be easy to add the data.

I would like to call something like.
row = xmldoc.readRow();
String row.COLUMN1NAME();

Any suggestiong on how I can do this?

Jul 13 '06 #1
5 8084

"plex4r" <pl****@discussions.microsoft.comwrote in message
news:B4**********************************@microsof t.com...
>I am reading data out of a relational database and converting the data to
XML.
I after I send this data from a web service I am reading the data using
XMLTextReader calls like the following:
if(customerReader.NodeType == XmlNodeType.Element)
if (customerReader.LocalName.Equals("COLUMN1NAME"))

I hate using the colmn names like this (or in a constant).
What I want to do is specify the structure of the XML doc wiht a Schema
(or
DTD) and then generate an object model from this. The Schema would have
to
match my query i.e. there needs to be easy to add the data.

I would like to call something like.
row = xmldoc.readRow();
String row.COLUMN1NAME();

Any suggestiong on how I can do this?
The .NET Framework SDK has a tool to do this:

xsd.exe
http://msdn.microsoft.com/library/de...ToolXsdexe.asp

David
Jul 13 '06 #2
Plex4r,
I suggest you consider the XSDObjectGen add-in, which can be found for
download on MSDN. This actually gives you a new project type for this in
Visual Studio .NET, and it runs rings around XSD.EXE.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"plex4r" wrote:
I am reading data out of a relational database and converting the data to XML.
I after I send this data from a web service I am reading the data using
XMLTextReader calls like the following:
if(customerReader.NodeType == XmlNodeType.Element)
if (customerReader.LocalName.Equals("COLUMN1NAME"))

I hate using the colmn names like this (or in a constant).
What I want to do is specify the structure of the XML doc wiht a Schema (or
DTD) and then generate an object model from this. The Schema would have to
match my query i.e. there needs to be easy to add the data.

I would like to call something like.
row = xmldoc.readRow();
String row.COLUMN1NAME();

Any suggestiong on how I can do this?
Jul 13 '06 #3
Peter and David, thanks for the information. Either solution sounds just
like what I need. I will investigate both and see which solution works best
for me.

Regards, Bill.

"Peter Bromberg [C# MVP]" wrote:
Plex4r,
I suggest you consider the XSDObjectGen add-in, which can be found for
download on MSDN. This actually gives you a new project type for this in
Visual Studio .NET, and it runs rings around XSD.EXE.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"plex4r" wrote:
I am reading data out of a relational database and converting the data to XML.
I after I send this data from a web service I am reading the data using
XMLTextReader calls like the following:
if(customerReader.NodeType == XmlNodeType.Element)
if (customerReader.LocalName.Equals("COLUMN1NAME"))

I hate using the colmn names like this (or in a constant).
What I want to do is specify the structure of the XML doc wiht a Schema (or
DTD) and then generate an object model from this. The Schema would have to
match my query i.e. there needs to be easy to add the data.

I would like to call something like.
row = xmldoc.readRow();
String row.COLUMN1NAME();

Any suggestiong on how I can do this?
Jul 14 '06 #4
I am using xsd.exe to create classes out of an xml file.

Can someone show me the XMLStream calls to make to populate this?. I have
the data in a String var.

System.Xml.Serialization.XmlRootAttribute(Namespac e="", IsNullable=false)]
public class NewDataSet {[
[System.Xml.Serialization.XmlElementAttribute("Cust omerXMLString",
Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public NewDataSetCustomerXMLString[] Items;
}
public class NewDataSetCustomerXMLString {

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string NAME;
....

"plex4r" wrote:
Peter and David, thanks for the information. Either solution sounds just
like what I need. I will investigate both and see which solution works best
for me.

Regards, Bill.

"Peter Bromberg [C# MVP]" wrote:
Plex4r,
I suggest you consider the XSDObjectGen add-in, which can be found for
download on MSDN. This actually gives you a new project type for this in
Visual Studio .NET, and it runs rings around XSD.EXE.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"plex4r" wrote:
I am reading data out of a relational database and converting the data to XML.
I after I send this data from a web service I am reading the data using
XMLTextReader calls like the following:
if(customerReader.NodeType == XmlNodeType.Element)
if (customerReader.LocalName.Equals("COLUMN1NAME"))
>
I hate using the colmn names like this (or in a constant).
What I want to do is specify the structure of the XML doc wiht a Schema (or
DTD) and then generate an object model from this. The Schema would have to
match my query i.e. there needs to be easy to add the data.
>
I would like to call something like.
row = xmldoc.readRow();
String row.COLUMN1NAME();
>
Any suggestiong on how I can do this?
>
Jul 14 '06 #5

"plex4r" <pl****@discussions.microsoft.comwrote in message
news:45**********************************@microsof t.com...
>I am using xsd.exe to create classes out of an xml file.

Can someone show me the XMLStream calls to make to populate this?. I have
the data in a String var.

System.Xml.Serialization.XmlRootAttribute(Namespac e="", IsNullable=false)]
public class NewDataSet {[
[System.Xml.Serialization.XmlElementAttribute("Cust omerXMLString",
Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public NewDataSetCustomerXMLString[] Items;
}
public class NewDataSetCustomerXMLString {

[System.Xml.Serialization.XmlElementAttribute(Form= System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string NAME;
....
Use the XmlSerializer class.
http://msdn.microsoft.com/library/de...classtopic.asp

David
Jul 15 '06 #6

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

Similar topics

5
by: trek | last post by:
Good evening, I am trying to locate a standard (commonly accepted) XML schema for managing documents. What want to know is if someone has already created an XML schema for describing the...
6
by: Phil Jarvis | last post by:
I have an XML Schema with regular expressions. e.g. <xsd:pattern value="{1}*"/> I have other patterns in the same schema document which share regular expression substructure, like the string...
1
by: martin | last post by:
Are inline schema (i.e a schema included in the XML document) compliant with the W3C recommendations on schema? I keep reading about them in .net articles on webservices. I don't understand how...
3
by: Razvan | last post by:
Hi After playing with XML Spy I saw that in DTDs the element of type "any" could contain text and any element that was declared in the DTD. In XML Schema an element of type anyType can...
4
by: Oskar Stuffer | last post by:
Hi! I'm using the msv tool which uses xerces to validate a XML document against a XML Schema definition. This is my XML Schema definition: <?xml version="1.0" encoding="ISO-8859-1"?>...
3
by: ceplma | last post by:
Hi, I love Kate XML plugin <http://kate.kde.org/> which understands XML document structure by reading output of dtdparse. However, DTDs seem to be kind of dying out (slowly, but sure) and...
10
by: Al Christoph | last post by:
Please forgive me if this is the wrong place to post this. The last place I posted got me a fairly rude response. I guess vb.db people just don't want to think about XML as database. At any rate,...
3
by: Kiran | last post by:
Hi, I want to back up my data in some table in SQL server and import it back using Bulk Load of SQL server 2K. I can use the following code to backup the data in XML ...
3
by: Sindarian | last post by:
I have a Schema from the folk that shows how they want the data received. I have my own database that has that data, but in a different way (they use 33 freaking tables to store what I do in 1)....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.