public override bool Equals(object ob) { if (ob == this) { return(true); } if (!(ob is DTDProcessingInstruction)) { return(false); } DTDProcessingInstruction other = (DTDProcessingInstruction)ob; if (Text == null) { if (other.Text != null) { return(false); } } else { if (!Text.Equals(other.Text)) { return(false); } } return(true); }
protected void ParseTopLevelElement() { Token token = Scanner.Get(); // Is <? xxx ?> even valid in a DTD? I'll ignore it just in case it's there if (token.Type == Scanner.LTQUES) { string textBuffer = ""; for (;;) { string text = Scanner.GetUntil('?'); textBuffer += (text); token = Scanner.Peek(); if (token.Type == Scanner.GT) { Scanner.Get(); break; } textBuffer += ('?'); } DTDProcessingInstruction instruct = new DTDProcessingInstruction(textBuffer); Dtd.Items.Add(instruct); return; } if (token.Type == Scanner.CONDITIONAL) { token = Expect(Scanner.IDENTIFIER); if (token.Value.Equals("IGNORE")) { Scanner.SkipConditional(); } else { if (token.Value.Equals("INCLUDE")) { Scanner.SkipUntil('['); } else { throw new DTDParseException(Scanner.GetUriId(), "Invalid token in conditional: " + token.Value, Scanner.GetLineNumber(), Scanner.GetColumn()); } } } else if (token.Type == Scanner.ENDCONDITIONAL) { // Don't need to do anything for this token } else if (token.Type == Scanner.COMMENT) { Dtd.Items.Add(new DTDComment(token.Value)); } else if (token.Type == Scanner.LTBANG) { token = Expect(Scanner.IDENTIFIER); if (token.Value.Equals("ELEMENT")) { ParseElement(); } else if (token.Value.Equals("ATTLIST")) { ParseAttlist(); } else if (token.Value.Equals("ENTITY")) { ParseEntity(); } else if (token.Value.Equals("NOTATION")) { ParseNotation(); } else { SkipUntil(Scanner.GT); } } else { // MAW Version 1.17 // Previously, the parser would skip over unexpected tokens at the // upper level. Some invalid DTDs would still show up as valid. throw new DTDParseException(Scanner.GetUriId(), "Unexpected token: " + token.Type.Name + "(" + token.Value + ")", Scanner.GetLineNumber(), Scanner.GetColumn()); } }