可以将多个 XSD 文件合二为一的工具? [英] Tool that can combine many XSD files into one?

查看:37
本文介绍了可以将多个 XSD 文件合二为一的工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为大约 65 个 XSD 文件创建 XML 序列化程序类,为此我使用了 Microsoft 的 XSD.EXE 生成 C# 代码...

I need to create XML serializer classes for approximately 65 XSD files, for which I am using Microsoft's XSD.EXE to generate the C# code...

但是,我一直在结果输出文件中遇到 Window CMD 的字符限制(其中 XSD.EXE 结合了包含的每个 XSD 的名称):指定的路径、文件名或两者都太长.完全限定文件名必须小于260个字符,目录名必须小于248个字符."

However, I keep running into Window CMD's character limit in the resulting output file (in which XSD.EXE combines the name of every XSD included): "The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."

长话短说,似乎我可以让所有这些一起验证和生成的唯一方法是我是否可以合并所有 XSD(取消引用包含/导入,XSD.EXE 没有无论如何将 schemaLocation 解析为一个大的.

To make a long story short, it seems that the only way I can get all these to validate and generate together is if I can merge all the XSDs (de-referencing the includes/imports, which XSD.EXE doesn't resolve the schemaLocation anyway) into one big one.

请告诉我有一个工具可以做到这一点...

Please tell me that there exists a tool to do this...

推荐答案

您可以做的是创建另一个名为 file.xsd 的新文件,其中包含其中的所有架构名称,然后诀窍是将最后一个架构文件命名为. 作为前缀.

What you can do is to create another new file called file.xsd containing all the schema names in it and then the trick is to name the last schema file with . as prefix.

<xsd xmlns='http://microsoft.com/dotnet/tools/xsd/'>
    <generateClasses language='CS' namespace='MyNamespace'>
        <schema>First.xsd</schema>
        <schema>Second.xsd</schema>
        <!-- more schema files here -->
        <schema>.Third.xsd</schema>
    </generateClasses>
</xsd>

现在运行命令xsd.exe/p:file.xsd/classes",你会得到生成的类文件:)

Now run the command "xsd.exe /p:file.xsd /classes" and you get the class file generated :)

这篇关于可以将多个 XSD 文件合二为一的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆