共用方式為


Annotation 項目繫結支援

.NET Framework 不會提供 <annotation> 項目的繫結支援。

從 XML 結構描述文件產生原始程式碼時,Xsd.exe 會忽略 <annotation> 項目及其內容。

說明

從 XML 結構描述文件產生原始程式碼時,Xsd.exe 會忽略 <annotation> 項目及其內容。因此,也不支援子項目 <appinfo><documentation>

只有在涉及下列兩個實體 (Entity) 之間的對應關係時,Xsd.exe 才會使用 <annotation> 項目:

XmlSerializerNamespaces 物件是用來儲存前置詞和前置詞所代表的命名空間之間的對應集合。annotation/appinfo/keepNamespaceDeclarations 項目的文字是 XmlSerializerNamespaces 欄位或屬性的名稱。這項轉譯可以雙向進行,也就是從 XSD 檔至程式碼,反之亦然,如此就可以控制命名空間的前置詞。

範例

輸入 C# 類別:

public class MyClass {
    [XmlAttribute]
    public string name;
    
    public string xpath;
    
    [XmlNamespaceDeclarationsAttribute]
    public XmlSerializerNamespaces xmlns;
}

編譯自前面 C# 原始檔而得之組件所產生的 XML 結構描述文件:

<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="MyClass" nillable="true" type="MyClass" />
  <xs:complexType name="MyClass">
    <xs:annotation>
      <xs:appinfo>
        <keepNamespaceDeclarations>xmlns</keepNamespaceDeclarations>
      </xs:appinfo>
    </xs:annotation>
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="xpath" type="xs:string" />
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" />
  </xs:complexType>
</xs:schema>

從前面的 XML 結構描述文件所產生的 C# 類別在效用上與原本產生 XML 結構描述的 C# 類別相同。

可能的屬性 繫結支援

id

Xsd.exe 公用程式忽略試圖提供唯一識別項的 id 屬性。

可能父項目:數量極多

可能子項目<appinfo><documentation>

請參閱

參考

XmlSchemaAnnotation
XmlSchemaAnnotation

Footer image

Copyright © 2007 by Microsoft Corporation. All rights reserved.