void ExpandEntity(StringBuilder sb, char terminator) { char ch = _current.ReadChar(); if (ch == '#') { string charent = _current.ExpandCharEntity(); sb.Append(charent); ch = _current.ReadChar(); } else { _name.Length = 0; while (ch != Entity.EOF && (Char.IsLetter(ch) || ch == '_' || ch == '-')) { _name.Append(ch); ch = _current.ReadChar(); } string name = _name.ToString(); if (_dtd != null && name != "") { Entity e = (Entity)_dtd.FindEntity(name); if (e != null) { if (e.Internal) { sb.Append(e.Literal); if (ch != terminator) ch = _current.ReadChar(); return; } else { Entity ex = new Entity(name, e.PublicId, e.Uri, _current.Proxy); e.Open(_current, new Uri(e.Uri)); _current = ex; _current.ReadChar(); return; } } else { Log("Undefined entity '{0}'", name); } } // Entity is not defined, so just keep it in with the rest of the // text. sb.Append("&"); sb.Append(name); if (ch != terminator) { sb.Append(ch); ch = _current.ReadChar(); } } }
//-------------------------------- Parser ------------------------- void PushEntity(Uri baseUri, Entity e) { e.Open(_current, baseUri); _current = e; _current.ReadChar(); }