问题描述
||
有没有一种方法可以将XSD ASP.NET文件转换为Windows Forms XSD?有这个工具吗?我确定如果您浏览每个文件都可以完成此操作,但是是否可以轻松进行转换(也许在Visual Studio中)?
解决方法
我已经在Windows Forms项目和ASP.NET项目中创建了两个数据集,并进行了比较(使用Visual Studio 2010)。它们几乎相同,除了两点:
Windows窗体生成具有乐观并发性的SQL语句,而ASP.NET没有
Connection
个元素不同(由于设定来源)
我认为可以编写一个简单的XSLT来更改Connection
元素,并保留其他所有内容。
另外,添加现有的.xsd数据集文件时,应在Visual Studio的文件属性中将“ 2”设置为“ 3”,否则Visual Studio不会刷新“ 4”文件。
(更新)这是此类XSLT的简单示例(未完成):
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<xsl:stylesheet version=\"1.0\"
xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"
xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\"
exclude-result-prefixes=\"msxsl\"
xmlns=\"http://tempuri.org/DataSet1.xsd\"
xmlns:mstns=\"http://tempuri.org/DataSet1.xsd\"
xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"
xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\"
xmlns:msprop=\"urn:schemas-microsoft-com:xml-msprop\"
xmlns:msds=\"urn:schemas-microsoft-com:xml-msdatasource\">
<xsl:output method=\"xml\" indent=\"yes\"/>
<xsl:template match=\"@* | node()\">
<xsl:copy>
<xsl:apply-templates select=\"@* | node()\"/>
</xsl:copy>
</xsl:template>
<xsl:template match=\"msds:Connection\">
<xsl:copy>
<xsl:attribute name=\"AppSettingsObjectName\">Settings</xsl:attribute>
<xsl:attribute name=\"AppSettingsPropertyName\">
<xsl:value-of select=\"@AppSettingsPropertyName\" />
</xsl:attribute>
<!-- TODO: add other attributes... -->
</xsl:copy>
</xsl:template>
</xsl:stylesheet>