public override void WriteStartElement(string prefix, string localName, string ns) {
try {
AutoComplete(Token.StartElement);
PushStack();
textWriter.Write('<');
if (this.namespaces) {
// Propagate default namespace and mix model down the stack.
stack[top].defaultNs = stack[top-1].defaultNs;
if (stack[top-1].defaultNsState != NamespaceState.Uninitialized)
stack[top].defaultNsState = NamespaceState.NotDeclaredButInScope;
stack[top].mixed = stack[top-1].mixed;
if (ns == null) {
// use defined prefix
if (prefix != null && prefix.Length != 0 && (LookupNamespace(prefix) == -1)) {
throw new ArgumentException(Res.GetString(Res.Xml_UndefPrefix));
}
}
else {
if (prefix == null) {
string definedPrefix = FindPrefix(ns);
if (definedPrefix != null) {
prefix = definedPrefix;
}
else {
PushNamespace(null, ns, false); // new default
}
}
else if (prefix.Length == 0) {
PushNamespace(null, ns, false); // new default
}
else {
if (ns.Length == 0) {
prefix = null;
}
VerifyPrefixXml(prefix, ns);
PushNamespace(prefix, ns, false); // define
}
}
stack[top].prefix = null;
if (prefix != null && prefix.Length != 0) {
stack[top].prefix = prefix;
textWriter.Write(prefix);
textWriter.Write(':');
}
}
else {
if ((ns != null && ns.Length != 0) || (prefix != null && prefix.Length != 0)) {
throw new ArgumentException(Res.GetString(Res.Xml_NoNamespaces));
}
}
stack[top].name = localName;
textWriter.Write(localName);
}
catch {
currentState = State.Error;
throw;
}
}