hannes: I don't know too much about this, but for what it is worth - the value is specified since it is an uint (a value type) and the default value is 0. When attributes have a value of "null" they don't serialize, so you could change the data type to string. You could also add both an uint and a string property for the same private variable and serialize one of them only, but I think this is messy.
Rightfully so. Default value of an uint (and other non-string) native data type is not null. int is 0, bool is false, etc. Hence, the serialized xml will not be optional.
But, the other way round is not quite so. When we generate a serializable class out of xml schema using xsd tool, if have an optional element, we'll get something like this (following your sample, assuming "Address" is optional element):
[Serializable]
public class TestItem
{
[System.Xml.Serialization.XmlAttributeAttribute("DataName")]
public string DataName;
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool DataAddressSpecified;
[System.Xml.Serialization.XmlAttributeAttribute("DataAddress")]
public uint DataAddress;
}
Somehow, the property <ElementName>Specified is used internally by the serializer to determine the occurence of the element in the XML file. If it is false, the element DataAddress will not be serialized.
Hope it answers. 