/// <summary> /// The text declaration for external DTDs. /// </summary> /// <param name="c">The character.</param> /// <returns>The token.</returns> protected DtdToken TextDecl(Char c) { if (_external) { var token = new DtdDeclToken(); if (c.IsSpaceCharacter()) { c = SkipSpaces(c); if (_stream.ContinuesWith(AttributeNames.Version)) { _stream.Advance(6); return(TextDeclVersion(_stream.Next, token)); } else if (_stream.ContinuesWith(AttributeNames.Encoding)) { _stream.Advance(7); return(TextDeclEncoding(_stream.Next, token)); } } } throw new DomException(DomError.InvalidNodeType); }
/// <summary> /// Gets the encoding specified in the text declaration. /// </summary> /// <param name="c">The character.</param> /// <param name="decl">The current declaration.</param> /// <returns>The token.</returns> DtdToken TextDeclEncoding(Char c, DtdDeclToken decl) { if (c == Symbols.Equality) { var q = _stream.Next; if (q == Symbols.DoubleQuote || q == Symbols.SingleQuote) { StringBuffer.Clear(); c = _stream.Next; if (c.IsLetter()) { do { StringBuffer.Append(c); c = _stream.Next; }while (c.IsAlphanumericAscii() || c == Symbols.Dot || c == Symbols.Underscore || c == Symbols.Minus); } if (c == q) { decl.Encoding = StringBuffer.ToString(); return(TextDeclAfter(_stream.Next, decl)); } } } throw new DomException(DomError.InvalidNodeType); }
/// <summary> /// Gets the version specified in the text declaration. /// </summary> /// <param name="c">The character.</param> /// <param name="decl">The current declaration.</param> /// <returns>The token.</returns> DtdToken TextDeclVersion(Char c, DtdDeclToken decl) { if (c == Symbols.Equality) { var q = _stream.Next; if (q == Symbols.DoubleQuote || q == Symbols.SingleQuote) { StringBuffer.Clear(); c = _stream.Next; while (c.IsDigit() || c == Symbols.Dot) { StringBuffer.Append(c); c = _stream.Next; } if (c == q) { decl.Version = StringBuffer.ToString(); return(TextDeclBetween(_stream.Next, decl)); } } } throw new DomException(DomError.InvalidNodeType); }
/// <summary> /// Checks if the text declaration ended correctly. /// </summary> /// <param name="c">The character.</param> /// <param name="decl">The current declaration.</param> /// <returns>The token.</returns> DtdToken TextDeclEnd(Char c, DtdDeclToken decl) { if (c != Symbols.GreaterThan) { throw new DomException(DomError.InvalidNodeType); } return(decl); }
/// <summary> /// After the declaration specified in the text declaration. /// </summary> /// <param name="c">The character.</param> /// <param name="decl">The current declaration.</param> /// <returns>The token.</returns> DtdToken TextDeclAfter(Char c, DtdDeclToken decl) { while (c.IsSpaceCharacter()) { c = _stream.Next; } if (c != Symbols.QuestionMark) { throw new DomException(DomError.InvalidNodeType); } return(TextDeclEnd(_stream.Next, decl)); }
/// <summary> /// Between the version and the encoding in the text declaration. /// </summary> /// <param name="c">The character.</param> /// <param name="decl">The current declaration.</param> /// <returns>The token.</returns> DtdToken TextDeclBetween(Char c, DtdDeclToken decl) { if (c.IsSpaceCharacter()) { while (c.IsSpaceCharacter()) { c = _stream.Next; } if (_stream.ContinuesWith(AttributeNames.Encoding)) { _stream.Advance(7); return(TextDeclEncoding(_stream.Next, decl)); } } throw new DomException(DomError.InvalidNodeType); }