5

I have XSD Schema with the following structure: ElementA has only one ElementB and that has zero to infinite of ElementC

ElementA -> ElementB -> ElementC[]

When I generate classes with this schema and xsd.exe it generates multidimensional arrays: Everywhere ElementA is used it puts ElementC[][][]. For each depth one dimension. Is there way to stop xsd.exe doing this?

For example the XSD defines an element called carList that contains only the car-tags (zero to infinite "car"). The xsd.exe should then create a class called carList that contains only an one-dimensional array or an list of car. Instead wherever a carList would be used it puts an car[][]. Don't like that.

One more question, is there a way to generate a XML that fits an given XSD besides generating classes that will be filled and serialized?

Michał Powaga
  • 22,561
  • 8
  • 51
  • 62
matthias
  • 199
  • 2
  • 10
  • 1
    [How to generate sample XML documents from their DTD or XSD?](http://stackoverflow.com/questions/17106/how-to-generate-sample-xml-documents-from-their-dtd-or-xsd) – Michał Powaga Nov 15 '11 at 17:48

1 Answers1

2

I use xsd.exe as well and I don't know a better way, at least for .NET platform.

After generating XSD schema file from XML, you need to modify the dimension ranges in XSD file then generate the Class. Because, dimensions in XML are unclear. You may have a single node at the moment but maybe you can add more in the future. Rules are not certain. Because of that reason, you need to edit XSD manually before generating the code files.

Emir Akaydın
  • 5,708
  • 1
  • 29
  • 57