Using XSD.EXE to generate class with instiated members RRS feed

  • Question

  • Hi,
     i am using XSD.exe to generate a serializable class from a rather large schema.  One problem i am running into is that it appears that XSD.EXE does not seem to honor the "minOccurs" attribute in the xsd.  The classes created have all there members uninstaniated initially...which means i have either modify the class after generation to initialize ALL (and there are many) those members..or i have to make sure i do it in the code that is using that class.

    is there a way around this? i don't see a command line option that would do this..is there another tool that can generate a class that will initialize all members?

    Saturday, August 16, 2008 8:13 AM


  • Yes, this is how XSD works -- properties of the generated classes are not initialized.

    It would be nice if there were more control over this.  It is one of a few areas of XmlSerializer that I would like to see improved (actually, I'd like to see XmlSerializer superseded with something new).  Unfortunately, Microsoft apparently has given up interest in XmlSerializer and has not come up with anything new that provides serialization with high-fidelity support for XML schemas.  This is really unfortunate because, in my opinion, XML schema is important to many integration scenarios.
    • Marked as answer by Zhi-Xin Ye Wednesday, August 20, 2008 11:33 AM
    Saturday, August 16, 2008 1:59 PM