Annotation Element Binding Support

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation.

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

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

Explanation

When generating source code from an XML Schema document, Xsd.exe ignores the <annotation> element and its contents. Accordingly, the child elements <appinfo> and <documentation> are not supported either.

The only time Xsd.exe uses the <annotation> element involves 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

id

The Xsd.exe utility ignores the id attribute, which is intended to provide a unique identifier.

Possible parent elements: numerous

Possible child elements: <appinfo>, <documentation>

See Also

Reference

XmlSchemaAnnotation
XmlSchemaAnnotation