private void ParseEntity() { char ch = this.m_current.SkipWhitespace(); bool pe = (ch == '%'); if (pe) { // parameter entity. this.m_current.ReadChar(); // move to next char ch = this.m_current.SkipWhitespace(); } string name = this.m_current.ScanToken(this.m_sb, SgmlDtd.WhiteSpace, true); ch = this.m_current.SkipWhitespace(); Entity e = null; if (ch == '"' || ch == '\'') { string literal = this.m_current.ScanLiteral(this.m_sb, ch); e = new Entity(name, literal); } else { string pubid = null; string extid = null; string tok = this.m_current.ScanToken(this.m_sb, SgmlDtd.WhiteSpace, true); if (Entity.IsLiteralType(tok)) { ch = this.m_current.SkipWhitespace(); string literal = this.m_current.ScanLiteral(this.m_sb, ch); e = new Entity(name, literal); e.SetLiteralType(tok); } else { extid = tok; if (string.Equals(extid, "PUBLIC", StringComparison.OrdinalIgnoreCase)) { ch = this.m_current.SkipWhitespace(); if (ch == '"' || ch == '\'') { pubid = this.m_current.ScanLiteral(this.m_sb, ch); } else { this.m_current.Error("Expecting public identifier literal but found '{0}'",ch); } } else if (!string.Equals(extid, "SYSTEM", StringComparison.OrdinalIgnoreCase)) { this.m_current.Error("Invalid external identifier '{0}'. Expecing 'PUBLIC' or 'SYSTEM'.", extid); } string uri = null; ch = this.m_current.SkipWhitespace(); if (ch == '"' || ch == '\'') { uri = this.m_current.ScanLiteral(this.m_sb, ch); } else if (ch != '>') { this.m_current.Error("Expecting system identifier literal but found '{0}'",ch); } e = new Entity(name, pubid, uri, this.m_current.Proxy); } } ch = this.m_current.SkipWhitespace(); if (ch == '-') ch = ParseDeclComments(); if (ch != '>') { this.m_current.Error("Expecting end of entity declaration '>' but found '{0}'", ch); } if (pe) this.m_pentities.Add(e.Name, e); else this.m_entities.Add(e.Name, e); }
void ParseEntity() { char ch = _current.SkipWhitespace(); bool pe = (ch == '%'); if (pe) { // parameter entity. _current.ReadChar(); // move to next char ch = _current.SkipWhitespace(); } string name = _current.ScanToken(_sb, _ws, true); name = _nt.Add(name); ch = _current.SkipWhitespace(); Entity e = null; if (ch == '"' || ch == '\'') { string literal = _current.ScanLiteral(_sb, ch); e = new Entity(name, literal); } else { string pubid = null; string extid = null; string tok = _current.ScanToken(_sb, _ws, true); if (Entity.IsLiteralType(tok) ) { ch = _current.SkipWhitespace(); string literal = _current.ScanLiteral(_sb, ch); e = new Entity(name, literal); e.SetLiteralType(tok); } else { extid = tok; if (extid == "PUBLIC") { ch = _current.SkipWhitespace(); if (ch == '"' || ch == '\'') { pubid = _current.ScanLiteral(_sb, ch); } else { _current.Error("Expecting public identifier literal but found '{0}'",ch); } } else if (extid != "SYSTEM") { _current.Error("Invalid external identifier '{0}'. Expecing 'PUBLIC' or 'SYSTEM'.", extid); } string uri = null; ch = _current.SkipWhitespace(); if (ch == '"' || ch == '\'') { uri = _current.ScanLiteral(_sb, ch); } else if (ch != '>') { _current.Error("Expecting system identifier literal but found '{0}'",ch); } e = new Entity(name, pubid, uri, _current.Proxy); } } ch = _current.SkipWhitespace(); if (ch == '-') ch = ParseDeclComments(); if (ch != '>') { _current.Error("Expecting end of entity declaration '>' but found '{0}'", ch); } if (pe) _pentities.Add(e.Name, e); else _entities.Add(e.Name, e); }