在C#类中使用xsd.exe,有没有办法用嵌套类型生成xsd文件,而不是全局类型?使用xsd.exe生成嵌套类型而不是全局类型
我想使用这个xsd文件,SSIS - Sql服务器集成服务,看看SSIS是不是很好的读我的xsd。
我想产生这样的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:element name="Country">
<xs:complexType>
<xs:sequence>
<xs:element name="City">
<xs:complexType>
<xs:sequence>
<xs:element name="CityName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CoutryName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
但XSD.EXE产生这种与全球类型和SSIS不读它。我需要手动将此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:element name="Country">
<xs:complexType>
<xs:sequence>
<xs:element name="City" type="City">
</xs:element>
<xs:element name="CoutryName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="City">
<xs:sequence>
<xs:element name="CityName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
有什么建议吗?或者我可以使用的其他工具。
非常感谢。
您能否更具体地指出哪些“非常好”意味着什么,以及您尝试这种情况的环境?我假设它是一个数据流中的XML源;我已经尝试过2008 R2,并且我获得了两个XSD的相同结果。 –
好的。 @PetruGardea就像你所设想的那样。数据流中的XML源。我认为SSIS没有将XSD与我的C#类生成的XML映射。我创建了一个WebService。 –