public override void WriteEndAttribute ()
{
if (state != WriteState.Attribute)
throw StateError ("End of attribute");
if (writer == preserver) {
writer = source;
string value = preserver.ToString ();
if (is_preserved_xmlns) {
if (preserved_name.Length > 0 &&
value.Length == 0)
throw ArgumentError ("Non-empty prefix must be mapped to non-empty namespace URI.");
string existing = nsmanager.LookupNamespace (preserved_name, false);
// consider OmitDuplicates here.
if ((namespace_handling & NamespaceHandling.OmitDuplicates) == 0 || existing != value)
explicit_nsdecls.Add (preserved_name);
if (open_count > 0) {
if (v2 &&
elements [open_count - 1].Prefix == preserved_name &&
elements [open_count - 1].NS != value)
throw new XmlException (String.Format ("Cannot redefine the namespace for prefix '{0}' used at current element", preserved_name));
if (elements [open_count - 1].NS == String.Empty &&
elements [open_count - 1].Prefix == preserved_name)
; // do nothing
else if (existing != value)
nsmanager.AddNamespace (preserved_name, value);
}
} else {
switch (preserved_name) {
case "lang":
if (open_count > 0)
elements [open_count - 1].XmlLang = value;
break;
case "space":
switch (value) {
case "default":
if (open_count > 0)
elements [open_count - 1].XmlSpace = XmlSpace.Default;
break;
case "preserve":
if (open_count > 0)
elements [open_count - 1].XmlSpace = XmlSpace.Preserve;
break;
default:
throw ArgumentError ("Invalid value for xml:space.");
}
break;
}
}
writer.Write (value);
}
writer.Write (quote_char);
state = WriteState.Element;
}