使用联合从 XSD 生成 .Net 类

发布于 2024-08-10 22:54:58 字数 746 浏览 5 评论 0 原文

我一直致力于为与筛选相关的独立包创建代表 HR-Xml 3 规范的类。我遇到了一些问题,但目前我认为主要问题是 xsd.exe 中缺乏对 xsd:union 语句的支持。

当Xsd.exe遇到简单类型时 由 union 定义,它忽略 定义并使用 其内置字符串数据类型 地方。
来自 - http://msdn.microsoft.com/ en-us/library/bc57azyw%28VS.85%29.aspx

我在各种论坛和新闻组上看到的唯一解决方案是重组 XSD 以不使用联合?然而,即使我需要的实体很小,union 语句的数量也接近 100。也许这是唯一的解决方案?

我已经坚持了很多天了,除了“不,那不起作用”之外,还没有找到任何真正有用的东西。最后,我需要让它以某种方式工作。任何有关工具、重新设计、转换器的建议,以及任何可以让我获得这些课程的东西!我什至开始考虑生成 Java 类,然后将它们转换为 C#...我不知所措 提前

致谢!我当然希望有办法解决这个问题!


最后,我们决定在第一阶段不实施HR-Xml,也许当我们回到它时,我会有更好的运气。不过,如果有人阅读本文并有任何建议,请留下反馈,因为我计划对此进行一段时间的监控。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栩栩如生 2024-08-17 22:54:58

您可以相当轻松快速地尝试以下两件事,看看它们是否提供任何帮助:

  • 使用 WCF svcutil.exe 实用程序(带有 /dconly 开关)而不是 xsd.exe - 这将尝试创建一个基于 WCF DataContractSerializer 的类,该类可以处理一些比标准 .NET XML 序列化器更好的事情

  • 尝试使用备用“XSD-to-code”生成器,例如 Xsd2Code Codeplex

马克

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

北音执念 2024-08-17 22:54:58

我还需要使用工会从 XSD 生成 C# 代码

,一种工作解决方案是

由 Liquid-technologies 创建的免费在线 XSD 到 C# 代码生成器

它未经 MIT 许可。如果您想将此库用于非教育目的,则需要购买它

在我的情况下,我的 XSD 中不再有 union,我只是将其从代码和 xsd 中删除。 exe

来自C:\Program Files (x86)\Microsoft SDKs\Windows\{version}\bin\NETFX {version} Tools\

有效

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文