/// <summary> /// Attribute objects are reused during parsing to reduce memory allocations, /// hence the Reset method. /// </summary> public void Reset(string name, string value, char quote) { this.Name = name; this.literalValue = value; this.QuoteChar = quote; this.DtdType = null; }
public void Add(AttDef a) { AttDefs.Add(a.Name, a); }
void ParseAttDefault(char ch, AttDef attdef) { if (ch == '%') { Entity e = ParseParameterEntity(WhiteSpace); PushEntity(this.current.ResolvedUri, e); ParseAttDefault(this.current.Lastchar, attdef); PopEntity(); // bugbug - are we at the end of the entity? ch = this.current.Lastchar; return; } bool hasdef = true; if (ch == '#') { this.current.ReadChar(); string token = this.current.ScanToken(this.sb, WhiteSpace, true); hasdef = attdef.SetPresence(token); ch = this.current.SkipWhitespace(); } if (hasdef) { if (ch == '\'' || ch == '"') { string lit = this.current.ScanLiteral(this.sb, ch); attdef.Default = lit; ch = this.current.SkipWhitespace(); } else { string name = this.current.ScanToken(this.sb, WhiteSpace, false); name = name.ToUpper(); name = this.nameTable.Add(name); attdef.Default = name; // bugbug - must be one of the enumerated names. ch = this.current.SkipWhitespace(); } } }
void ParseAttType(char ch, AttDef attdef) { if (ch == '%') { Entity e = ParseParameterEntity(WhiteSpace); PushEntity(this.current.ResolvedUri, e); ParseAttType(this.current.Lastchar, attdef); PopEntity(); // bugbug - are we at the end of the entity? ch = this.current.Lastchar; return; } if (ch == '(') { attdef.EnumValues = ParseNameGroup(ch, false); attdef.Type = AttributeType.ENUMERATION; } else { string token = ScanName(WhiteSpace); if (token == "NOTATION") { ch = this.current.SkipWhitespace(); if (ch != '(') { this.current.Error("Expecting name group '(', but found '{0}'", ch); } attdef.Type = AttributeType.NOTATION; attdef.EnumValues = ParseNameGroup(ch, true); } else { attdef.SetType(token); } } }
AttDef ParseAttDef(char ch) { ch = this.current.SkipWhitespace(); string name = ScanName(WhiteSpace); name = name.ToUpper(); name = this.nameTable.Add(name); AttDef attdef = new AttDef(name); ch = this.current.SkipWhitespace(); if (ch == '-') ch = ParseDeclComments(); ParseAttType(ch, attdef); ch = this.current.SkipWhitespace(); if (ch == '-') ch = ParseDeclComments(); ParseAttDefault(ch, attdef); ch = this.current.SkipWhitespace(); if (ch == '-') ch = ParseDeclComments(); return attdef; }