Converting an XSD to .NET Classes  
Author Message
NP Rudra





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

I tried to export a Data Model using ERWIN into a XSD File. Now I am trying to convert the XSD file into C# Classes using XSD.exe from VS2005. It failed giving me this message:

Schema validation warning: Invalid 'name' attribute value '10XXR_identifier': 'The '1' character, hexadecimal value 0x31, at posit
ion 0 within the name, cannot be included in a name.'. Line 210, position 2.
Schema validation warning: Invalid 'name' attribute value '10XXR_status_identifier': 'The '1' character, hexadecimal value 0x31, a
t position 0 within the name, cannot be included in a name.'. Line 245, position 2.
Schema validation warning: Invalid 'name' attribute value '10XXR_status_identifier': 'The '1' character, hexadecimal value 0x31, a
t position 0 within the name, cannot be included in a name.'. Line 299, position 2.
Schema validation warning: Invalid 'name' attribute value '10XXR_type_identifier': 'The '1' character, hexadecimal value 0x31, at
position 0 within the name, cannot be included in a name.'. Line 333, position 2.

Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.

Error: Error generating classes for schema 'MPAS1'.
- Schema with targetNamespace='' has invalid syntax. Invalid 'name' attribute value '1099R_identifier': 'The '1' character, hexa
decimal value 0x31, at position 0 within the name, cannot be included in a name.'. Line 210, position 2.
- Invalid 'name' attribute value '1099R_identifier': 'The '1' character, hexadecimal value 0x31, at position 0 within the name,
cannot be included in a name.'.

Might be I didn't really pay attention while exporting the Data Model but, did I do something wrong while importing the Data Model My main motto is convert a existing Data Model into .NET Classes, integrated with all relations and preconditions as defined in the Data Model.

Any suggestions, or comments




.NET Development33  
 
 
Martin Honnen





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

I don't know what ERWIN is but as for XML, element or attribute names need to start with a Unicode letter, not with a digit (e.g. '1'). If you have element or attribute names starting with a digit then you need to correct that.

 
 
SaravanaKumar_1977





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

Is your schema refers any schemas internally if you are trying to generate class out of an xsd, you have to specify all related schemas in xsd.exe.

The syntax is given below

xsd.exe. [therequiredschema] [related schemas....] /c


 
 
Nave





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

FYI Erwin is a Data Modelling tool.
But I think you were right. I might have to check with the digit issue.



 
 
Nave





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

I tried to use the same command (xsd.exe) with the same formats. I am quite confused about the Internal Schemas!!! Could you tell me more about what you are refering to.

 
 
Priya Lakshminarayanan





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

To convert XmlSchema to C# classes, you can also try the newly released LINQ to XSD alpha. The download location is:

http://www.microsoft.com/downloads/details.aspx FamilyID=f83e69dd-ef73-49c5-9b3a-ee0c61e68a20&DisplayLang=en

You can read more about the technology at:

http://blogs.msdn.com/xmlteam/archive/2006/11/27/typed-xml-programmer-welcome-to-linq.aspx

Thanks,

Priya


 
 
-Anton Lapounov





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

Do you see any errors in the Errors window when you load the generated schema in VS2005 editor If not, you may send the schema to me at this address, and I will try to investigate it.

Thanks,
Anton


 
 
Nave





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

I would really like to send the complete schema, but all the data is confidential and I am not supposed to put it out. But, to answer your question, I didn't see any errors when I load the schema into VS2005.

But, I did find a custom code in VB which can do my work. The code reads all the tables in the database and creates the class names as table names and members and properties of the class as the fields in the database.

Let me know if you guys are interested in the code..



 
 
Mosbah ELssaedi





PostPosted: XML and the .NET Framework, Converting an XSD to .NET Classes Top

Hi,

Please could you tell me how to generate C# classes from my XML file.

I am doing an application using MS visual studio 2005, C#. The project
accept some variables, events and controls and at the end, I save all
the data in XML file. I would like to generate some classes from the
XML file to C# classes.

Any help will be appreciated.

Thanks,
Mosbah