I believe XSD2Code is the best tool currently available (in 2011).
I recently went through the same process at work of analysing the available tools out there so i thought i would provide an updated answer that relates to VS2010.
Our main driver was that xsd.exe does not generate XML doc from the XSD annotations, which we wanted as we have hundreds of type definitions. I tried all the tools listed above as well as others and most were either deprecated, unmaintained or unable to match the current functionality of xsd.exe available in VS2010.
Xsd2Code however is a superb tool and seems to be actively maintained. It provides all the functionality that was listed above and a lot more - the CodePlex page also has great examples of how the various options affect output.
It also has tight VS integration, including context menu integration and a custom build tool (which means that if you reference the XSDs in your project and specify the custom tool, it will automatically update the code as you update the XSD). All in all saved us a lot of work.
XSDCodeGen - More of a demo on how to write a custom build tool
CodeXS - Quite a good tool, but less integration, features and no longer maintained
XSDObjectGen - No longer maintained, less functionality than current xsd.exe
XSDClassGen - Could not locate it
OXM Library - Recommend looking at this project, maintained and great functionality
LINQ to XSD - Very cool project, but not what i was looking for
Addendum:
If you do decided to go ahead with XSD2Code, there are a number of issues i found working with the command-line tool. In particular, there are some bugs with the argument processing that require some arguments to be in a certain order as well as some undocumented dependencies (eg - automatic parameters & .NET version are order specific and dependent). The following are the steps i used to generate the code using XSD2Code and then cleanup the output - take the bits that apply to you as necessary:
Run the following batch file to generate the initial code, changing the paths to the correct locations:
@echo off
set XsdPath=C:\schemas
set OutPath=%XsdPath%\Code
set ExePath=C:\Progra~1\Xsd2Code
set Namespace=InsertNamespaceHere
echo.Starting processing XSD files ...
for /f %%a IN ('dir %XsdPath%\*.xsd /a-d /b /s') do call:ProcessXsd %%a
echo.Finished processing XSD files ...
echo.&pause&
goto:eof
:ProcessXsd
%ExePath%\Xsd2Code %~1 %Namespace% %XsdPath%\Code\%~n1%.cs /pl Net35 /if- /dc /sc /eit
echo.Processed %~n1
goto:eof
Perform the following steps to tidy up the generated code, as necessary:
Regex replace - current project, case, whole word - [System.Runtime.Serialization.DataContractAttribute(Name:b*=:b*:q,:bNamespace:b=:b*{:q})] with [DataContract(Namespace = \1)]
Replace - current project, case, whole word - [System.Runtime.Serialization.DataMemberAttribute()] with [DataMember]
Regex replace - current project, case, whole word - System.Nullable\<{:w}> with \1\?
Regex replace - open documents, case, whole word - {:w}TYPE with \1
Replace - open documents, case, whole word - System.DateTime with DateTime, then add missing using statements
Replace - open documents, case, whole word - [System.Xml.Serialization.XmlIgnoreAttribute()] with [XmlIgnore]
Replace - current project - System.Xml.Serialization.XmlArrayAttribute with XmlArray
Replace - current project - System.Xml.Serialization.XmlArrayItemAttribute with XmlArrayItem
Regex replace - current project - ,[:Wh]+/// \<remarks/\> with ,
The best XSD class generator I've found is
thinktecture WSCF.blue
.
It's nicer than most of the others for two reasons:
Fixes naming. That means casing and plurization of types and property names.
Creates a separate file for each class.
Or, if you're looking for a T4 solution, you can try
XsdClassGen
.
This one isn't working for me. But the good news is that it's a T4 file, so it's easy to fix!
Here is web based example of using XSLT to transform XML to C# code.
The example takes a model (XML) that describes services (basically service names, namespaces, and list of operations), it then generates WCF services (interfaces, messages, faults, tests, etc) all in C#.net.