public override void WriteStartElement(string prefix, string localName, string ns)
{
try
{
// check local name
if (localName == null || localName.Length == 0)
{
throw new ArgumentException(SR.Xml_EmptyLocalName);
}
CheckNCName(localName);
AdvanceState(Token.StartElement);
// lookup prefix / namespace
if (prefix == null)
{
if (ns != null)
{
prefix = LookupPrefix(ns);
}
if (prefix == null)
{
prefix = string.Empty;
}
}
else if (prefix.Length > 0)
{
CheckNCName(prefix);
if (ns == null)
{
ns = LookupNamespace(prefix);
}
if (ns == null || (ns != null && ns.Length == 0))
{
throw new ArgumentException(SR.Xml_PrefixForEmptyNs);
}
}
if (ns == null)
{
ns = LookupNamespace(prefix);
if (ns == null)
{
Debug.Assert(prefix.Length == 0);
ns = string.Empty;
}
}
if (_elemTop == 0 && _rawWriter != null)
{
// notify the underlying raw writer about the root level element
_rawWriter.OnRootElement(_conformanceLevel);
}
// write start tag
_writer.WriteStartElement(prefix, localName, ns);
// push element on stack and add/check namespace
int top = ++_elemTop;
if (top == _elemScopeStack.Length)
{
ElementScope[] newStack = new ElementScope[top * 2];
Array.Copy(_elemScopeStack, newStack, top);
_elemScopeStack = newStack;
}
_elemScopeStack[top].Set(prefix, localName, ns, _nsTop);
PushNamespaceImplicit(prefix, ns);
if (_attrCount >= MaxAttrDuplWalkCount)
{
_attrHashTable.Clear();
}
_attrCount = 0;
}
catch
{
_currentState = State.Error;
throw;
}
}