我想TSFType在以下XML架构转换为C#类。但我不知道如何处理<xs:element ref="xs:schema"/>
。任何建议?如何将XSD类型转换与REF =“XS:模式”属性为C#类?
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="urn:IEEE-1641:2010:STDTSF"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
tsf="urn:IEEE-1641:2010:STDTSF"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="TSFType">
<xs:sequence>
<xs:element name="interface">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:documentation>Any XMLSchema definition can be used whose element/attribute types map onto a 1641 type</xs:documentation>
</xs:annotation>
<xs:element ref="xs:schema"/>
<!--xs:any namespace="http://www.w3.org/2001/XMLSchema" processContents="strict" maxOccurs="unbounded"/-->
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:NCName" use="required"/>
</xs:complexType>
<xs:element name="TSFLibrary">
<xs:annotation>
<xs:documentation>TSFLibrary represents the IEEE 1641 intechangeable Signal Model Library</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="string" minOccurs="0"/>
<xs:element name="TSF" type="tsf:TSFType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NCName" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
整个xsd可用here。
我试过xsd.exe,它给出了以下不正确的界面元素类,其中模式类型未定义。
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:IEEE-1641:2010:STDTSF")]
public partial class TSFTypeInterface {
private schema schemaField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.w3.org/2001/XMLSchema")]
public schema schema {
get {
return this.schemaField;
}
set {
this.schemaField = value;
}
}
}
,它是无效的,而且看起来很空。你能提供一个更好的例子吗? – lokusking