我有一个描述响应消息的通信服务的xsd。我想创建一个相关的C#类,这样我就可以序列化/反序列化并利用强类型,但是XSD.exe让我头疼不已。
XSD:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="co:core:restapi"
elementFormDefault="qualified"
xmlns="co:core:restapi"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:lpr="co:core">
<xs:import namespace="co:core" schemaLocation="Location.xsd"/>
<xs:import namespace="co:core" schemaLocation="List.xsd"/>
<xs:import namespace="co:core" schemaLocation="ListEntry.xsd"/>
<xs:import namespace="co:core" schemaLocation="Alert.xsd"/>
<xs:complexType name="superType">
<xs:choice>
<xs:sequence>
<xs:choice>
<xs:element name="location">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="site" type="lpr:location" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="list">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="list" type="lpr:list" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="listentry">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="delete" type="lpr:delete" minOccurs="0"/>
<xs:element name="entry" type="lpr:listentry" minOccurs="0"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="alert">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="alert" type="lpr:alert" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:element name="page">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="next" type="xs:anyURI">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:element name="error" type="xs:string">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:schema>
基本上,将为导入名称空间填写类型,但是不会为复杂的superType创建任何内容。