Mrc*_*ief 7 .net xsd.exe visual-studio
出于某种原因,MS .Net(v3.5)工具 - xsd.exe在任何元素中未使用时都不会生成类型.
例如
XSD文件(我投入复杂元素以避免此警告 - "警告:无法生成类,因为找不到具有复杂类型的顶级元素."):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:simpleType name="EnumTest">
<xs:restriction base="xs:string">
<xs:enumeration value="item1" />
<xs:enumeration value="item2" />
<xs:enumeration value="item3" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="myComplexType">
<xs:attribute name="Name" use="required" type="xs:string"/>
</xs:complexType>
<xs:element name="myElem" type="myComplexType"></xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
当我通过使用xsd.exe运行此时
xsd/c xsdfile.xsd
我没有在生成的cs文件中看到EnumTest.
注意; 即使我不在这里使用枚举,但在我的实际项目中,我有这样的情况,我们发送枚举的字符串值作为输出.
如何强制xsd工具包含这些?或者我应该切换到其他工具?
我在Visual Studio 2008中工作.
我必须得出结论,这是该工具的一个愚蠢的缺点.也许给开关打开这个行为.由于没有这种行为,我不得不在xsd之外创建类型并创建碎片代码.
这是我个人的看法,我很确定还有其他人会分享同样的看法.
归档时间: |
|
查看次数: |
13323 次 |
最近记录: |