XSD.exe 关于包含文件和代码生成的问题

发布于 2024-09-05 10:18:07 字数 187 浏览 2 评论 0原文

如果您有包含参考的 XSD。 是否可以生成 2 个单独的类文件。 1 表示 XSD,1 表示附带的 XSD?

我的场景 4 个 XSD,每个 XSD 共享 15-20 个共同元素定义。 我不想维护,而是希望最终得到 4 个 XSD 都引用具有通用定义的第五个文件,并生成 5 个 .cs 文件以供使用的代码。

If you have an XSD with an includes reference.
Is it possible to generate 2 separate class files.
1 for the XSD, and 1 for the included XSD?

My Scenario
4 XSDs, each of which share 15-20 element definitions in common.
Rather than maintaining, I'd like to end up with the 4 XSDs all referencing a fifth file with the common definitions, and code generating 5 .cs files to use.

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

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

发布评论

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

评论(2

农村范ル 2024-09-12 10:18:07

否,XSD.exe 将为所有导入生成类
尝试 XSDObjectGen 。它支持 XML 包含(但是深一层)。

No, XSD.exe will generate classes for all imports
Try XSDObjectGen. It supports XML include (one level deep, however).

七度光 2024-09-12 10:18:07

我目前正在破解 xsd2code 来提供此功能。我认为 linqtoxsd 也可以很容易地对此进行扩展。不过,这些中的 codedom 内容让我很头疼。

如果您分别对每个文件调用 xsd,您将遇到的问题是,每个单独的输出 cs 文件将定义充实基础文件所需的所有类,因此它将具有在包含的 xsd 中找到的类。如果您对多个具有公共包含文件的 xsd 执行此操作,您将得到包含中代码的重复声明。

I'm currently hacking xsd2code to provide this functionality. I think linqtoxsd could be extended pretty easily for this as well. The codedom stuff in these makes my head hurt though..

The problem youll run into if you call xsd on each file indivdually, is that each individual output cs file will define all the classes needed to flesh out the base one, thus it will have classes found in the included xsd's. If you do this for mutiple xsd's which all have common include files, you will wind up with duplicate declarations of the code from the includes.

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