C# 将 XSD 转换为 SQL 关系表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/403420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 02:07:13  来源:igfitidea点击:

Convert XSD into SQL relational tables

c#c++sqlvisual-studioxsd

提问by rozon

Is there something available that could help me convert a XSD into SQL relational tables? The XSD is rather big (in my world anyway) and I could save time and boring typing if something pushed me ahead rather than starting from scratch.

是否有可用的东西可以帮助我将 XSD 转换为 SQL 关系表?XSD 相当大(无论如何在我的世界中),如果有什么东西推动我前进而不是从头开始,我可以节省时间和无聊的打字。

The XSD is hereif you want to have a look. It's a standardized/localized format to exchange MSDS.

如果您想看一看,XSD 就在这里。这是交换 MSDS 的标准化/本地化格式。

采纳答案by Dillie-O

Altova's XML Spyhas a feature that will generate SQL DDL Script from an XSD file. XML Spy will cost you some money though.

Altova 的XML Spy具有从 XSD 文件生成 SQL DDL 脚本的功能。不过,XML Spy 会花费您一些钱。

Interestingly enough, a developer used a really clever trick of using an XSLT translation to create the DDL script from an XSD file. They have outlined it in two parts hereand here.

有趣的是,开发人员使用了一个非常聪明的技巧,即使用 XSLT 转换从 XSD 文件创建 DDL 脚本。他们在此处此处分两部分对其进行了概述。

I might have to try this out myself for future use...

我可能必须自己尝试一下以备将来使用...

EDIT: Just found this question asked previously here...

编辑:刚刚发现这个问题之前在这里问过......

回答by user3194532

There is a command-line tool called XSD2DB, that generates database from xsd-files, available at sourceforge.

有一个名为XSD2DB的命令行工具,它从 xsd 文件生成数据库,可在 sourceforge 获得。

For more info: please refer to this existing question How can I create database tables from XSD files?

有关更多信息:请参阅此现有问题如何从 XSD 文件创建数据库表

回答by devinbost

You can use an XSLT transform. See, for example, here: Generating SQL from XSD and XSL stylesheets with XSLT.

您可以使用 XSLT 转换。例如,请参见此处:使用 XSLT 从 XSD 和 XSL 样式表生成 SQL

Microsoft has a command-line tool for performing XSLT transformations: Microsoft Command-Line tool for XSLT.

Microsoft 有一个用于执行 XSLT 转换的命令行工具:Microsoft Command-Line tool for XSLT

It is also easy to integrate the transforms into a build process using MSBuild or Grunt.

使用 MSBuild 或 Grunt 将转换集成到构建过程中也很容易。

Here is the reference for the Microsoft documentation: XML Standards Reference, including XSD, XSLT, etc.

下面是微软文档的参考:XML Standards Reference,包括 XSD、XSLT 等。