XSD.EXE和"循环组引用"XSD、EXE、QUOT

2023-09-03 00:08:25 作者:唐僧不过就是一个耍猴旳

我试图建立一些类,这样我可以deserialise由第三方应用程序创建一个XML文件。幸运的是,第三方应用程序的开发者包括其code模式文件,使XML文件可以理解。

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.

当我使用xsd.exe工具从Visual Studio进程失败报告以下错误

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

从目标名称集团SegGroupOrSegmentGrouping'=''有无效的定义:循环组引用

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

任何帮助我如何能产生光这个错误的类文件将AP preciated。 架构文件的副本可以在这里找到:模式文件

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

推荐答案

我有同样的问题,最近,

I had this same problem recently,

我得到了来自谁是从一个web服务返回XML结构的第三方公司的模式。那么我想deserialise的响应和存储信息与NHibernate的数据库。

I was given a Schema from a third party company who were returning an xml structure from a webservice. I then wanted to deserialise the response and store the information into a database with NHibernate.

没有问题,我想我就用XSD.EXE和我有我的课。不幸的是,这是不可能的。 XSD.EXE失败,正是你所得到的同样的错误。这是因为它无法解决循环引用。

No problem I thought I'll just use xsd.exe and I'll have my classes. Unfortunately this was not to be. Xsd.exe failed with exactly the same error you are getting. This is because it is unable to resolve circular references.

我花了好几天的寻找替代品,直到最后我写我自己的阶级结构的架构,并能够deserialise完美。这里的答案是写自己的C#类,然后用适当的属​​性进行装饰。

I spent a good few days looking at alternatives until in the end I wrote my own class structure to the schema and was able to deserialise perfectly. The answer here is to write your own C# classes and decorate them with the appropriate attributes.

保存自己一些时间和心痛,不要继续尝试并生成你到底需要自动虽然费时你写不会做出妥协,大多数的工具(不很好地工作)班的班会让你赚钱。

Save yourself some time and heartache and don't continue to try and generate the classes you need automatically in the end although time consuming the classes you write won't make the compromises that most tools (which don't work perfectly) will make you make.

我花了大约3天写的类结构(这是大的),但我结束了一个优质的解决方案。

Took me about 3 days to write the class structure (it was large) but I ended up with a quality solution.

有一件事是可以肯定的,你将无法使用XSD.EXE和大多数其他工具,我试着在Google上搜寻这要么没有正常工作后或有车。

One thing is certain you will not be able to use xsd.exe and most other tools I tried after googling this either did not work properly or were buggy.