示例#1
0
        /// <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 Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#2
0
        /// <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 == Specification.EQ)
            {
                var q = _stream.Next;

                if (q == Specification.DQ || q == Specification.SQ)
                {
                    _stringBuffer.Clear();
                    c = _stream.Next;

                    if (c.IsLetter())
                    {
                        do
                        {
                            _stringBuffer.Append(c);
                            c = _stream.Next;
                        }while (c.IsAlphanumericAscii() || c == Specification.DOT || c == Specification.UNDERSCORE || c == Specification.MINUS);
                    }

                    if (c == q)
                    {
                        decl.Encoding = _stringBuffer.ToString();
                        return(TextDeclAfter(_stream.Next, decl));
                    }
                }
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#3
0
        /// <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 == Specification.EQ)
            {
                var q = _stream.Next;

                if (q == Specification.DQ || q == Specification.SQ)
                {
                    _stringBuffer.Clear();
                    c = _stream.Next;

                    while (c.IsDigit() || c == Specification.DOT)
                    {
                        _stringBuffer.Append(c);
                        c = _stream.Next;
                    }

                    if (c == q)
                    {
                        decl.Version = _stringBuffer.ToString();
                        return(TextDeclBetween(_stream.Next, decl));
                    }
                }
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#4
0
        /// <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 == Specification.GT)
            {
                return(decl);
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#5
0
        /// <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 == Specification.QM)
            {
                return(TextDeclEnd(_stream.Next, decl));
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#6
0
        /// <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 Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
        /// <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 Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
        /// <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 == Specification.GT)
                return decl;

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
        /// <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 == Specification.QM)
                return TextDeclEnd(_stream.Next, decl);

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#10
0
        /// <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 == Specification.EQ)
            {
                var q = _stream.Next;

                if (q == Specification.DQ || q == Specification.SQ)
                {
                    _stringBuffer.Clear();
                    c = _stream.Next;

                    if (c.IsLetter())
                    {
                        do
                        {
                            _stringBuffer.Append(c);
                            c = _stream.Next;
                        }
                        while (c.IsAlphanumericAscii() || c == Specification.DOT || c == Specification.UNDERSCORE || c == Specification.MINUS);
                    }

                    if (c == q)
                    {
                        decl.Encoding = _stringBuffer.ToString();
                        return TextDeclAfter(_stream.Next, decl);
                    }
                }
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#11
0
        /// <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 Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
示例#12
0
        /// <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 == Specification.EQ)
            {
                var q = _stream.Next;

                if (q == Specification.DQ || q == Specification.SQ)
                {
                    _stringBuffer.Clear();
                    c = _stream.Next;

                    while (c.IsDigit() || c == Specification.DOT)
                    {
                        _stringBuffer.Append(c);
                        c = _stream.Next;
                    }

                    if (c == q)
                    {
                        decl.Version = _stringBuffer.ToString();
                        return TextDeclBetween(_stream.Next, decl);
                    }
                }
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }