WebVize's WebLog

An independent C# Developer in the Netherlands

{HELP}How to create an empty XML from XSD

I know I have asked this before but I haven't had any clear answers. If Gabe Halsmer might read this I haven't found any way to contact you.. My email is webvize.nl">mh@<Nospam>webvize.nl (remove the <Nospam>) and yes I am interested in your solution!.

I still am in the need to create an empty XML from XSD. This is not just an XML with <XmlElement/> but with all mandatory elements as specified in the XML and if possible filled with some default values (if needed).
I know that in .Net 2.0 it will be possible but how do I approach this with 1.1??

I need this to create a transparent editor with the use of XOPUS but it needs a valid XML as input.. And I don't want to remove the mandatory elements ( this might be the easiest way)..

Comments

Steven said:

We needed to do this as well. We ended up creating a pretty complicated library that loaded an XSD using the XmlSchema namespace, walked the object model and built a default XML instance. It wasn't easy, especially when you get into groups, replacements, enumerations. We also integrated localization features.

Unfortunately, since it's my company's code, I don't think I can share it, but may be able to provide some pointers.

Now, we've been using .NET 2.0 for a while and I haven't found anything in there that does this. Do you have a reference I might be able to read?

I asked this same question here:

http://weblogs.asp.net/stevencohn/archive/2004/02/16/73826.aspx

back in February. I didn't get any responses. If you do, please let me know! Send me a message through my weblogs.asp.net site. Thanks.


# January 15, 2005 8:32 AM

Steven said:

Hey, I just ran across this. I'm not sure if it will help, but it looks interesting:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/xmlgen.asp

\Steven

# January 15, 2005 9:09 AM

Michael Hensen said:

Thats the solution I mentioned for 2.0 .. but it won't work in 1.1.. Too bad..
# January 15, 2005 1:16 PM

Steven said:

Yes, we had 1.1 version that just parsed and interpereted the XSD as (as an XML document) and generated the XML directly.

The latter version I wrote was actually quite similar to that posed in the referenced article.
# January 15, 2005 1:20 PM

TrackBack said:

^_^,Pretty Good!
# April 9, 2005 11:42 PM

ysm79 said:

Hi WebVize

I want to do same in .net framework 2.0. Can you send me some info as to how to do it?

Please contact me via email shang@inbox.com

Thanks.

# June 29, 2007 12:59 PM

Erwin said:

Hi, eager to see the 2.0 solution.. the link ...xmlgen.asp is no longer available.. anyone to toss me in the right direction?

All the best

# July 18, 2007 11:10 AM

junglefreak said:

This worked for me.  I just used the command line utility because I didn't need to include it in an application.

msdn2.microsoft.com/.../aa302296.aspx

# August 6, 2007 5:48 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)