开发者

Convert an ASP.NET XSD (Dataset) to Windows Forms

Is there a way to conver开发者_运维技巧t an XSD ASP.NET file to a Windows Forms XSD? Is there a tool for this? I am sure it can be done if you went through each file, but is there an easy conversion (maybe in Visual Studio)?


I've created two datasets in a Windows Forms project and in ASP.NET project and compared them (with Visual Studio 2010). They were almost identical, except of two points:

  1. Windows Forms generated SQL statements with optimistic concurrency while ASP.NET didn't
  2. Connection elements differed (because of setting source)

I think it's possible to write a simple XSLT to change the Connection element and leave everything else as is.

Also, when you adding an existing .xsd dataset file, you should set Custom Tool to MSDataSetGenerator in file properties in Visual Studio, or Visual Studiowon't refresh the .Designer.cs file.

(UPDATE) Here's a simple example (unfinished) of such an 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜