共用方式為


Appinfo Element Binding Support

The .NET Framework does not provide binding support for the <appinfo> element.

When generating source code from an XML Schema document, Xsd.exe ignores the <appinfo> element and its contents.

Explanation

When generating source code from an XML Schema document, Xsd.exe ignores the <appinfo> element and its contents. The same is true for the parent of the <appinfo> element, <annotation>.

An exception is the correspondence between the following two entities:

An XmlSerializerNamespaces object is used to store a set of mappings between prefixes and the namespaces they represent. The text of the element annotation/appinfo/keepNamespaceDeclarations is the name of the XmlSerializerNamespaces field or property. This translation is done both ways—from XSD file to code, and vice versa—so that namespace prefixes can be controlled.

Example

Input C# class:

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

XML Schema document generated from an assembly compiled from the preceding C# source:

<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>

The C# class generated from the preceding XML Schema document is effectively the same as the original C# class from which the XML schema was generated.

Possible Attributes Binding Support

source

Since the .NET Framework does not bind the <appinfo> element, it does not bind the element's source attribute.

Possible parent elements: <annotation>

Possible child elements: unlimited

See Also

Reference

XmlSchemaAppInfo