Alternative to xsd.exe in Visual Studio 2010
Looks like XS开发者_开发技巧D.exe is not delivered as a part of Visual Studio 2010.
what is the alternative being offered in VS2010?
It's available from the VS 2010 command prompt. Open up the VS 2010 command prompt and type "xsd /?".
Start -> All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt
You can use xsd.exe from here.
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\xsd.exe
I believe xsd.exe is not available with Visual Studio * 2010 Express
XML Schema Definition Tool is available in the menu "Start":
Start-> All Programs-> Microsoft Visual Studio 2010-> Visual Studio Command Prompt(2010)
You'll see the welcome message a command line:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
D:\Program Files\Microsoft Visual Studio 10.0\VC>
You can, for example, create an XML scheme from the XML-file.
example.xml:
<?xml version="1.0" encoding="utf-8"?>
<country>
<country_name>France</country_name>
<population>59.7</population>
</country>
To do this, enter the following:
I:\example.xml /outputdir:D:\xml2xsd
In my system, i see the following:
...
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'D:\xml2xsd\example.xsd'.
D:\Program Files\Microsoft Visual Studio 10.0\VC>
In the catalog D:\xml2xsd\
came a such a scheme:
example.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="country">
<xs:complexType>
<xs:sequence>
<xs:element name="country_name" type="xs:string" minOccurs="0" />
<xs:element name="population" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="country" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
A full list of options here - http://msdn.microsoft.com/en-us/library/x6c1kb0s.aspx
As for alternatives, you can search converters for operations that allows xsd.exe:
XDR to XSD
XML to XSD
XSD to DataSet
XSD to Classes
Classes to XSD
Good luck.
I had to add this to my path:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\
(Start > Edit the system environment variables > Environment Variables > Edit 'Path' under 'System variables')
Then I could start the Visual Studio command prompt (2010) and type
xsd.exe /?
Generally speaking DTD is an alternative to XSD and DTD is fully supported in Visual Studio. However, DTD is a weaker language, as some things can not be expressed in it. For example, it does not support as many data types as XSD does, nor does it have assertions. Anyways, if you're not too picky about it, you can give it a try.
精彩评论