XSD.EXE Bug-Generated code will not serialize.

dmvprof

Member
Joined
Dec 9, 2010
Messages
12
Programming Experience
Beginner
This is a continuation of my first thread that I started, but I've boiled the issue down to what appears to be a well known behavior of XmlSerializer class.

microsoft.public.dotnet.xml | Google Groups

Apparently it is unable to serialize Jagged Arrays properly even though the XSD.EXE generated the code.

There have been a few solutions floated around the web, but they involved tinkering with the generated code. I'm averse to going that route because the schema I have to adhere to will be validated by the agency I'm sending my XML to. So I don't have the flexibility of modifying the XSD to make it easier to manipulate.

Is anyone aware of a more elegant way to generate this code from a schema and then serialize it into XML?

Is there an alternative to XSD.EXE?
 
The suggestion in that thread is to make a minor modification to the generated class (ie change the XmlArrayItemAttribute to read array type), not to change the xsd schema. From the response apparently this was successful in regard to serialization. Did you try it? Generating the class is something you do only once, there's no problem changing that before you compile the app.
 
I though that was the whole point of the fix, to fix what the generator did wrong, it's not like you're changing the class (ie the schema).
 
I understand. From what I've been reading, I think that the issue is more with the serializer than the generator.

But maybe it's worth a try. I'll pick a small sample and modify the class and see what it spits out.

I've found another generator "xsd2code" that used an array of lists instead of a jagged array.

XSD Version
VB.NET:
Partial Public Class SubmissionDocument
Private documentDescriptiveMetadataField()() As SubmissionDocumentDocumentDescriptiveMetadataDocumentID


XSD2CODE version
VB.NET:
Partial Public Class SubmissionDocument
Private documentDescriptiveMetadataField As List(Of SubmissionDocumentDocumentDescriptiveMetadataDocumentID)

Still have a problem serializing.

"Inconsistent sequencing: if used on one of the class's members, the 'Order' property is required on all particle-like members, please explicitly set 'Order' using XmlElement, XmlAnyElement or XmlArray custom attribute on class member 'SubmissionDocument'."
 
Back
Top