/// <summary> /// Attribute objects are reused during parsing /// to reduce memory allocations, /// hence the Reset method. /// </summary> public void Reset(string name, string value, char quoteChar) { _name = name; _literalValue = value; _quoteChar = quoteChar; _dtdType = null; }
private void ParseAttributeType(char ch, AttributeDefinition attr) { if (ch == '%') { Entity e = ParseParameterEntity(_whiteSpace); PushEntity(_current.ResolvedUri, e); ParseAttributeType(_current.LastChar, attr); PopEntity(); ch = _current.LastChar; return; } if (ch == '(') { attr.SetEnumeratedType(ParseNameGroup(ch, false), AttributeType.Enumeration); } else { string token = ScanName(_whiteSpace); if (String.Compare(token, "NOTATION", true, CultureInfo.InvariantCulture) == 0) { ch = _current.SkipWhitespace(); if (ch != '(') throw Error.ExpectingNameGroup(ch); attr.SetEnumeratedType(ParseNameGroup(ch, true), AttributeType.Notation); } else attr.SetType(token); } }
private void ParseAttributeDefault(char ch, AttributeDefinition attr) { if (ch == '%') { Entity e = ParseParameterEntity(SgmlDtd._whiteSpace); PushEntity(_current.ResolvedUri, e); ParseAttributeDefault(_current.LastChar, attr); PopEntity(); ch = _current.LastChar; return; } bool hasDefault = true; if (ch == '#') { _current.ReadChar(); string token = _current.ScanToken(_builder, _whiteSpace, true); hasDefault = attr.SetPresence(token); ch = _current.SkipWhitespace(); } if (hasDefault) { if (ch == '\'' || ch == '"') { string lit = _current.ScanLiteral(_builder, ch); attr.Default = lit; ch = _current.SkipWhitespace(); } else { string name = _current.ScanToken(_builder, _whiteSpace, false); name = name.ToUpper(CultureInfo.InvariantCulture); attr.Default = name; ch = _current.SkipWhitespace(); } } }
private AttributeDefinition ParseAttributeDefinition(char ch) { ch = _current.SkipWhitespace(); string name = ScanName(_whiteSpace) .ToUpper(CultureInfo.InvariantCulture); AttributeDefinition attr = new AttributeDefinition(name); ch = _current.SkipWhitespace(); if (ch == '-') ch = ParseDeclarationComments(); ParseAttributeType(ch, attr); ch = _current.SkipWhitespace(); if (ch == '-') ch = ParseDeclarationComments(); ParseAttributeDefault(ch, attr); ch = _current.SkipWhitespace(); if (ch == '-') ch = ParseDeclarationComments(); return attr; }