Reputation: 773
I've been working to create classes representing the HR-Xml 3 spec for the stand-along packages related to Screening. I've had a couple of problems, but currently I believe the main problem is the lack of support within xsd.exe for the xsd:union statement.
When Xsd.exe encounters a simple type defined by union, it ignores the definition and uses the built-in string data type in its place.
From - http://msdn.microsoft.com/en-us/library/bc57azyw%28VS.85%29.aspx
The only solution I've seen on various forums and newsgroups is to restructure the XSD to not use the union? However, even with the small subset of entities I need, the number of union statements approaches 100. Perhaps this is the only solution?
I've been stuck on this for a number of days now and haven't been able to find anything real useful, besides "nope, that doesn't work". In the end, I need to make it work somehow. Any suggestions for tools, redesigns, converters, anything that can get me these classes! I've even started to think about generating Java classes and then converting those to C#... I'm at a loss
Thanks in advance! I certainly hope there's some solution to this!
In the end, we made the decision that we wouldn't implement HR-Xml in the first phase, perhaps when we get back to it, I'll have better luck. Still, if anyone reads this and has any suggestions please leave feedback as I plan to monitor this for a while.
Upvotes: 0
Views: 2081
Reputation: 31
I also needed to gen C# code from XSD with unions
And one work solution was
Free Online XSD to C# Code Generator created by liquid-technologies
It's not MIT Licenced. If you want to use this lib for not educational purposes, you need to buy it
In my case i had no more union
in my XSD, and i just removed it from code, and xsd.exe
from
C:\Program Files (x86)\Microsoft SDKs\Windows\{version}\bin\NETFX {version} Tools\
worked
Upvotes: 0
Reputation: 754468
Two things you could try fairly easily and quicky to see if they provide any help:
use the WCF svcutil.exe utility (with the /dconly
switch) instead of xsd.exe - this will attempt to create a class based on the WCF DataContractSerializer which can handle a few things better than the standard .NET XML Serializer
try an alternate "XSD-to-code" generator, for instance something like Xsd2Code on Codeplex
Marc
Upvotes: 0