Monday, June 05, 2006

Dreaming About An XML Based Pre-Processor for Dotnet

A good concept I had in my mind is developing a pre-processor for .NET compilers, to convert an XSD data structure definition in a VB or C# source code file to equivalent code. Right now, if I need to specify and use a data structure in XSD,

  • First of all, I have to create an XSD schema
  • Use xsd tool or xsdobjectgen to map it to a set of classes or the Document Object Model.
  • Use the DOM in my project

I suggest, Microsoft may soon think about allowing developers to embed XSD definitions with in the source code, so that we can create objects of the XSD schema definition with out going through the above processes. Some kind of embedded XSD?

This will allow developers to define data structures using XSD, directly in their source files, and create and use instances of the same. I dream about writing something like this in a VB.NET source file in the near future.

public class FutureClass

<xs:element name="PersonType">
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="Address" type="xs:string" />

private person as PersonType

Sub New()

        person= new PersonType()


End Sub

End Class

Probably I am a little bit over ambitious, but I hope you got my point. But anyway, I'll consider developing a .NET pre-processor which can parse the code above, when I get some time. Err.. Who Knows? Whether something like this is already available?


Anonymous said...

Why would you want to be able to define an attribute using XML in this manner since there is already a mechanism for doing this in C#?

This question probably shows my naivety, but that's OK. I'm in the learning phase.

Anonymous said...

There is an open source application located at

That takes an XSD Schema and converts it to A Class Based modes for loading and working with XML documents including serialization.

amazedsaint said...

Using XSD defined objects from the code, with out converting it to an object model using another tool, will be great. It has a lot of applications.. like creating data structures corresponds to data definitions in remote web services

Hash said...

Are you able to publish a fully object oriented database application prototype if you are good at patterns and stuffs? (Like a simple student registration software) Thanks in advance!

Hash Marshell said...

Mr. Anup...

Any reply to my query?


Articles - Design Patterns, Neural Networks, C#, Programming