2016-11-22 41 views
1

我想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; 
     } 
    } 
} 
+0

,它是无效的,而且看起来很空。你能提供一个更好的例子吗? – lokusking

回答

1

您是否运行过此命令? xsd STDTSF.xsd STDBSC.xsd /c

试试这个:xsd STDTSF.xsd XMLSchema.xsd STDBSC.xsd /c 它会产生很多的东西,包括下面的类

/// <remarks/> 
[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="http://www.w3.org/2001/XMLSchema")] 
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.w3.org/2001/XMLSchema", IsNullable=false)] 
public partial class schema : openAttrs { 

    private openAttrs[] itemsField; 

    private topLevelSimpleType[] simpleTypeField; 

    private topLevelComplexType[] complexTypeField; 

    private namedGroup[] groupField; 

    private namedAttributeGroup[] attributeGroupField; 

    private topLevelElement[] elementField; 

您所需要的XSD在这里找到:https://www.w3.org/2001/XMLSchema.xsd

我做了该文件的一个引擎收录,如果根据您发布的XSD片段您有任何问题 http://pastebin.com/4upNhiB1

+0

你肯定是正确的,我跑命令'XSD STDTSF.xsd STDBSC.xsd/C'。 – ricky