我在Visual 2010中使用XSD2CODE。我知道我可以右键单击一个模式(XSD)文件并从它生成c#类。
我想知道的是,当我为单个XML文件拥有两个模式文件时,如何生成C#类?
更多信息:
也许我在原来的问题中没有提供足够的细节。
在提到Why does XSD.EXE Create Two .XSD Files, and How to Use Them?问题时,我基本上是对XSD2CODE而不是XSD提出同样的问题。
对于XSD,我将使用以下命令:
D:\>xsd response.xsd response_app1.xsd /classes
如何在VS 2010 GUI和/或命令行中使用XSD2CODE完成此操作?
发布于 2012-02-22 01:01:30
编辑:
为了回答更新的问题,Xsd2Code似乎不是一次处理多个.xsd文件。
我从以下几个方面收集到:
Xsd2Code.exe <XSD File> [Namespace] [Output file name] [Options]
Trunk\Xsd2Code.Console\EntryPoint.cs.)
Pascal似乎在Xsd2Code的CodePlex站点上非常活跃。考虑与他联系,得到一个明确的答案:http://www.codeplex.com/site/users/view/pcabanel
,
为了自动创建支持的Xsd2CodeCustomTool类文件,您可以在解决方案资源管理器和属性窗口中单击.xsd文件,将xsd2Code写入/粘贴到“自定义工具”属性中。
为了“查看”另一个.xsd文件中的数据类型,可以使用include语句。
下面是一个包含数据定义和Employees.xsd include-ing Person.xsd并使用Person数据类型的Person的示例。
注意,由于Employees.xsd.已经包含了Person.xsd,所以只需为Person.xsd生成Xsd2Code即可
Person.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="CommonNamespace"
xmlns="CommonNamespace"
>
<xs:complexType name="Person">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>Employees.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="CommonNamespace"
xmlns="CommonNamespace"
>
<xs:include schemaLocation="Person.xsd"/>
<xs:element name="Employees">
<xs:complexType>
<xs:sequence>
<xs:element name="Employee" type="Person" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>https://stackoverflow.com/questions/9386754
复制相似问题