XSDObjectGen.exe vs XSD.exe
Asked Answered
E

4

19

Can anyone tell me what is the difference between XSDObjectGen.exe & XSD.exe?

Is there any way to make XSDObjectGen.exe work in dot net 2.0?

Enthusiasm answered 14/11, 2008 at 5:52 Comment(0)
R
30

As an alternative, there's Xsd2Code. Some features:

  • Generate partial class.
  • Support generic and custom collection (List, ObservableCollection, MyCustomCollection).
  • Support automatic properties when no special get or set is required.
  • Can generate WCF attributes (DataContract/DataMember).
  • Support nillable type.
  • Mask private field in IDE (use EditorBrowsableState.Never attribute).
  • Generate object allocation in constructor.
  • Implement INotifyPropertyChanged for enable DataBinding for wpf or Silverlight.
  • Improves productivity with visual studio add-in.
  • Generate summary documentation from xsd annotation.
  • Check if the new and old values int setter are the same before raising property changed event.
  • backup options generation in cs or vb header.
  • Save and load Xml document into isolated file storage for silverlight app (new in 3.0).
  • Generate CS, VB or CPP code.
  • Serialize/deserialize object.
  • Save into file and load from file.
  • Include Xsd2CodeCustomTool.
Ruddle answered 9/6, 2010 at 10:17 Comment(6)
I was looking for a way to get xsd.exe to generate shorthand properties. Although that's not possible, Xsd2Code will do it piece-meal (use xsd.exe to turn .xml into .xsd, then Xsd2Code to generate the C# class). Thanks.Lubricate
This is great information, but it is not clear to me how it answers the question. (Maybe the question should be modified).Hag
@Kirk It is a (far) better solution to creating classes from an XSD than either of the tools mentioned in the question.Ruddle
What if two XSDs MyClass1.xsd and MyClass2.xsd. Both objects MyClass1 and MyClass2 both reference MyClass3. Does it create a MyClass3 objects for each type or does it detect the type already exists?Jaclin
@Jaclin MyClass1.xsd and MyClass2.xsd need a reference to MyClass3.xsd (otherwise the xsd is incorrect). You run xsd2code on each xsd individually (i.e. MyClass1.xsd and MyClass2.xsd). It then creates a single file (in each run) with a class for each type/element found in the xsd, as well as any required types in the referenced XSDs. So to answer your question: It will create the MyClass3 class twice (once in each generated file). If the XSDs are in the same place, then the namespace will be the same => delete one of the generated MyClass3.Ruddle
@Jaclin If you have a MyClasses.xsd, which include and reference MyClass1 and MyClass2, then the generated file (when running xsd2code on MyClasses.xsd) should have only one definition of MyClass3.Ruddle
Q
8

The difference is:

To give you some idea, here is a summary feature list for XSDObjectGen.exe:

  • Support for the most popular XML schema constructs
  • Enumerator and Collection behavior for repeating elements
  • Programming model that matches schema
  • Automatic sub-class construction
  • Name collision avoidance
  • Visual Studio IDE integration
  • Special handling logic for DateTime types
  • Multipart schema support
  • XML namespace serialization
  • Optional and Sequence support
  • Choice Support
  • Substitution group
  • MakeSchemaCompliant method
  • Non-optional reference-type handling
  • WS-I.org basic profile compliance
  • Multi-programming language support
  • Depth-wise Traversal Events

For more details on these features see the XSDObjectGen.doc documentation file (available in C:\Program Files\XSDObjectGenerator after you install the tool).

Quacksalver answered 9/6, 2010 at 10:13 Comment(0)
S
5

Looks like you can use it with VS2005 at least (according to this article, anyway)

Just add it to your External Tools collection of VS2005 under "Tools>>External Tools...".

Set your parameters as the following

  • For VB: $(ItemPath) /l:vb /f:$(ItemFileName).vb /c /d /t
  • For C#: $(ItemPath) /l:cs /f:$(ItemFileName).vb /c /d /t

It does appear that XSD and XSDObjectGen will yield different classes. In fact, comments in this Rick Strahl article say "they yield very different classes" in the article here.

Sondra answered 14/11, 2008 at 22:54 Comment(1)
How interesting ... a downvote? Please provide an explanation if my answer was confusing or misleading. I'm sure other readers would like to benefit.Sondra
H
3

At a purely technical level:

XSD.exe uses Arrays
XSDObjectGen takes a tiny step ahead and uses ArrayLists.
XSD2Code leaps ahead with usage of Generics.

If you're using .NET 2.0 and above using XSD2Code is most preferred.

Heirdom answered 18/2, 2011 at 17:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.