Tony
Tony

Reputation: 221

XSD Namespace to C# Namespace

We are looking for a way to have C# autogenerate classes from an XSD and create C# namespaces using the namespace info in the XSD.

Doesnt seem like you can create a structured (xxxx.yyyy.zzzz) C# namespace from the XSD?

Is there a trick we're missing?

Thanks

Upvotes: 22

Views: 18374

Answers (2)

marc_s
marc_s

Reputation: 755013

There's a really interesting project XSD2Code on Codeplex. It basically does the same as xsd.exe - only better, on the command line, and as a Visual Studio plugin.

You just right-click on an XSD file in your solution explorer and run the tool!

alt text http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Xsd2Code&DownloadId=41336

You can set any valid .NET namespace as the target namespace for your generated code files.

Update: the XSD2Code tool has been further developed and is now offered as both a free and a paid, commercial tool - see the official home page for more details.

Upvotes: 3

John Buchanan
John Buchanan

Reputation: 5242

Would this do the trick? the /n allows you to specify a namespace to put the generated class in.

xsd.exe /classes MyXSDInput.xsd /n:MyCsharpNamespace

Upvotes: 43

Related Questions