void IXmlParserContext.ConnectAll() { XNode prev = null; foreach (XObject o in Nodes) { XContainer container = o as XContainer; if (prev != null && container != null && prev.IsComplete) { container.AddChildNode(prev); } if (o.Parent != null) { break; } prev = o as XNode; } }
protected virtual void Close(XElement element, IXmlParserContext context, DocumentLocation location) { //have already checked that element is not null, i.e. top of stack is our element if (element.IsClosed) { context.Nodes.Pop(); } element.End(location); if (context.BuildTree) { XContainer container = element.IsClosed? (XContainer)context.Nodes.Peek() : (XContainer)context.Nodes.Peek(1); container.AddChildNode(element); } }
public override State PushChar(char c, IParseContext context, ref string rollback) { AspNetDirective directive = context.Nodes.Peek() as AspNetDirective; if (directive == null || directive.IsComplete) { directive = new AspNetDirective(context.LocationMinus(4)); // 4 == <%@ + current char context.Nodes.Push(directive); } if (c == '<') { context.LogError("Unexpected '<' in directive."); rollback = string.Empty; return(Parent); } Debug.Assert(!directive.IsComplete); if (context.StateTag != ENDING && c == '%') { context.StateTag = ENDING; return(null); } if (context.StateTag == ENDING) { if (c == '>') { //have already checked that directive is not null, i.e. top of stack is our directive context.Nodes.Pop(); if (!directive.IsNamed) { context.LogError("Directive closed prematurely."); } else { directive.End(context.Location); if (context.BuildTree) { XContainer container = (XContainer)context.Nodes.Peek(); container.AddChildNode(directive); } } return(Parent); } //ending but not '>'? Error; go to end. } else if (char.IsLetter(c)) { rollback = string.Empty; if (!directive.IsNamed) { return(NameState); } else { return(AttributeState); } } else if (char.IsWhiteSpace(c)) { return(null); } rollback = string.Empty; context.LogError("Unexpected character '" + c + "' in tag."); return(Parent); }