/// <summary>If the stack contains an element with this tag's name, pop up the stack to remove the first occurrence. /// </summary> /// <remarks> /// If the stack contains an element with this tag's name, pop up the stack to remove the first occurrence. If not /// found, skips. /// </remarks> /// <param name="endTag"/> private void PopStackToClose(Token.EndTag endTag) { String elName = endTag.Name(); iText.StyledXmlParser.Jsoup.Nodes.Element firstFound = null; for (int pos = stack.Count - 1; pos >= 0; pos--) { iText.StyledXmlParser.Jsoup.Nodes.Element next = stack[pos]; if (next.NodeName().Equals(elName)) { firstFound = next; break; } } if (firstFound == null) { return; } // not found, skip for (int pos = stack.Count - 1; pos >= 0; pos--) { iText.StyledXmlParser.Jsoup.Nodes.Element next = stack[pos]; stack.JRemoveAt(pos); if (next == firstFound) { break; } } }
internal void Emit(Token token) { Validate.IsFalse(isEmitPending, "There is an unread token pending!"); emitPending = token; isEmitPending = true; if (token.type == iText.StyledXmlParser.Jsoup.Parser.TokenType.StartTag) { Token.StartTag startTag = (Token.StartTag)token; lastStartTag = startTag.tagName; if (startTag.selfClosing) { selfClosingFlagAcknowledged = false; } } else { if (token.type == iText.StyledXmlParser.Jsoup.Parser.TokenType.EndTag) { Token.EndTag endTag = (Token.EndTag)token; if (endTag.attributes != null) { Error("Attributes incorrectly present on end tag"); } } } }