XSD problems? …hack it

by Jesse 12. September 2007 04:38

@ the office over the past few days, I’ve been embedding myself into the wonderful world of XML. In this happy land, things are …well, usually happy, until you get a crappy XSD file. Technically, the xsd is valid so you can use it and generate a class and what not by using XSD.exe /stuff. It was irritating, because this did not allow nulls, at all, anywhere and after we discovered that hey, guess what, we have no idea if any of the data will ever show up …soooo knowing that we have no choice, we neeeeeeed those nullables (I think in xsd land they’re called nillables or something or other)

Anyway, here’s a quick dirty snippet of code you can use to generate a cleaner xsd. And yes, its THAT easy.

System.Data.DataSet dataSet = new System.Data.DataSet();
dataSet.ReadXmlSchema(”C:\\mycrapXSD.xsd”);
dataSet.WriteXmlSchema(”C:\\myprettyXSD.xsd”);

Use your XSD.exe to generate your class, and as another “gotcha!” — you’ll probably see an array of an array, something like Item[][]; Rid yourself of one of the [] and all will be good in the world.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.Net | Visual Studio | C# | Coding

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Like the description says, at my core, I'm a scientist and engineer.  I came from humble beginnings on a 486DX2 Packard Hell playing doom2 on IPX to in a small time retail shop and got into hardware (ISO layers FTW!) and it was all downhill from there.  I'm infinitely curious about almost everything and always wanting to know.

Some of the stuff I'm currently into/researching...

Sitefinity

Ninject

Subsonic

Java

Currently working on ...
i did the hundred 
and some extra stuff

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's, their brother nor their dog's view in anyway.  At all.  Ever.

© Copyright 2007-2008