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.
<xs:element name="PersonType">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="Address" type="xs:string" />
</xs:complexType>
</xs:element>
private person as PersonType
Sub New()
person= new PersonType()
person.Name="Anoop"
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?
5 comments:
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.
There is an open source application located at http://www.bw-a-tects.com/default.htm?http://www.bw-a-tects.com/DotNet/Development/CodeXS/Article/Article_web.htm
That takes an XSD Schema and converts it to A Class Based modes for loading and working with XML documents including serialization.
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
Are you able to publish a fully object oriented vb.net database application prototype if you are good at patterns and stuffs? (Like a simple student registration software) Thanks in advance!
Mr. Anup...
Any reply to my query?
-Marshell
Post a Comment