The WSIT Tutorial

@XmlAttribute Annotation

Guideline: A property or field can be mapped to an XML attribute using @XmlAttribute annotation. .NET binds an XML attribute to a property.

Example: Mapping a field or property to an XML attribute

//-- Java code fragment
public class UKAddress extends Address {
    public int exportCode;

//-- Schema fragment
<! XML Schema fragment -->
<xs:complexType name="ukAddress">
        <xs:extension base="tns:address">
            <xs:attribute name="exportCode" type="xs:int"/>

// .NET auto generated code from schema
public partial class ukAddress : address
    private int exportCodeField;
    public int exportCode
        get { return this.exportCodeField; }
        set { this.exportCodeField = value; }