XSD.exe and "Circular Group references"

BENBUN Coder picture BENBUN Coder · Mar 5, 2010 · Viewed 8.1k times · Source

I am attempting to build some classes so that I can deserialise an XML file created by a third party application. Luckily the developer of the 3rd party application included a schema file with their code so that the XML file can be understood.

When I use the XSD.exe tool from Visual Studio the process fails reporting the following error

"Group 'SegGroupOrSegmentGrouping' from targetNamespace='' has invalid definition: Circular group reference."

Any help in how I can generate the class files in light of this error would be appreciated. A copy of the schema file can be found here : schema file

Answer

NKCSS picture NKCSS · Jul 8, 2015

Try using svcutil; it can handle the circular references.

In the following example, eExact-Schema.xsd is an XSD that xsd.exe cannot handle.

Example:

C:\SRC\Exact>svcutil eExact-Schema.xsd /language:C# /dataContractOnly /importxmltypes /out:exact.cs

This is always a good place to start; you can now use this class and alter to suit your style/needs, add comments, etc, and it will save you a lot of time/searching over doing it all from scratch.