Пример #1
0
        Boolean DeclarationNameBefore(Char c, DtdToken decl)
        {
            while (c.IsSpaceCharacter())
                c = src.Next;

            if (c == Specification.NULL)
            {
                RaiseErrorOccurred(ErrorCode.NULL);
                stringBuffer.Clear();
                stringBuffer.Append(Specification.REPLACEMENT);
                return DeclarationName(src.Next, decl);
            }
            else if (c == Specification.GT)
            {
                RaiseErrorOccurred(ErrorCode.TagClosedWrong);
                return false;
            }
            else if (c == Specification.EOF)
            {
                RaiseErrorOccurred(ErrorCode.EOF);
                src.Back();
                return false;
            }

            stringBuffer.Clear();
            stringBuffer.Append(c);
            return DeclarationName(src.Next, decl);
        }
Пример #2
0
        /// <summary>
        /// Consumes the given token.
        /// </summary>
        /// <param name="token">The token to consume.</param>
        void Consume(DtdToken token)
        {
            switch (token.Type)
            {
            case DtdTokenType.Attribute:
                _result.AddAttribute(((DtdAttributeToken)token).ToElement());
                break;

            case DtdTokenType.Element:
                _result.AddElement(((DtdElementToken)token).ToElement());
                break;

            case DtdTokenType.Entity:
                AddEntity((DtdEntityToken)token);
                break;

            case DtdTokenType.Notation:
                _result.AddNotation(((DtdNotationToken)token).ToElement());
                break;

            case DtdTokenType.TextDecl:
                throw Errors.Xml(ErrorCode.XmlInvalidPI);

            case DtdTokenType.Comment:
            case DtdTokenType.ProcessingInstruction:
                break;
            }
        }
Пример #3
0
        Boolean DeclarationName(Char c, DtdToken decl)
        {
            while (true)
            {
                if (c.IsSpaceCharacter())
                {
                    decl.Name = stringBuffer.ToString();
                    stringBuffer.Clear();
                    return DeclarationNameAfter(src.Next);
                }
                else if (c == Specification.GT)
                {
                    decl.Name = stringBuffer.ToString();
                    return false;
                }
                else if (c == Specification.NULL)
                {
                    RaiseErrorOccurred(ErrorCode.NULL);
                    stringBuffer.Append(Specification.REPLACEMENT);
                }
                else if (c == Specification.EOF)
                {
                    RaiseErrorOccurred(ErrorCode.EOF);
                    src.Back();
                    decl.Name = stringBuffer.ToString();
                    return false;
                }
                else
                    stringBuffer.Append(c);

                c = src.Next;
            }
        }
Пример #4
0
        void Consume(DtdToken token)
        {
            switch (token.Type)
            {
            case DtdTokenType.Attribute:
                _result.AddAttribute(((DtdAttributeToken)token).ToElement());
                break;

            case DtdTokenType.Comment:
                _result.AddComment(((DtdCommentToken)token).ToElement());
                break;

            case DtdTokenType.Element:
                _result.AddElement(((DtdElementToken)token).ToElement());
                break;

            case DtdTokenType.Entity:
                _result.AddEntity(((DtdEntityToken)token).ToElement());
                break;

            case DtdTokenType.Notation:
                _result.AddNotation(((DtdNotationToken)token).ToElement());
                break;

            case DtdTokenType.ProcessingInstruction:
                _result.AddProcessingInstruction(((DtdPIToken)token).ToElement());
                break;
            }
        }
Пример #5
0
        /// <summary>
        /// Consume the given prolog token (first token to consume).
        /// </summary>
        /// <param name="token">The token to consume.</param>
        void Prolog(DtdToken token)
        {
            if (_tokenizer.IsExternal && token.Type == DtdTokenType.TextDecl)
            {
                var pi = (DtdDeclToken)token;

                if (!String.IsNullOrEmpty(pi.Encoding))
                {
                    SetEncoding(_src, pi.Encoding);
                }
            }
            else
            {
                Consume(token);
            }
        }
Пример #6
0
        /// <summary>
        /// Consumes the given token.
        /// </summary>
        /// <param name="token">The token to consume.</param>
        void Consume(DtdToken token)
        {
            switch (token.Type)
            {
                case DtdTokenType.Attribute:
                    _result.AddAttribute(((DtdAttributeToken)token).ToElement());
                    break;

                case DtdTokenType.Element:
                    _result.AddElement(((DtdElementToken)token).ToElement());
                    break;

                case DtdTokenType.Entity:
                    AddEntity((DtdEntityToken)token);
                    break;

                case DtdTokenType.Notation:
                    _result.AddNotation(((DtdNotationToken)token).ToElement());
                    break;

                case DtdTokenType.TextDecl:
                    throw Errors.Xml(ErrorCode.XmlInvalidPI);

                case DtdTokenType.Comment:
                case DtdTokenType.ProcessingInstruction:
                    break;
            }
        }
Пример #7
0
        /// <summary>
        /// Consume the given prolog token (first token to consume).
        /// </summary>
        /// <param name="token">The token to consume.</param>
        void Prolog(DtdToken token)
        {
            if (_tokenizer.IsExternal && token.Type == DtdTokenType.TextDecl)
            {
                var pi = (DtdDeclToken)token;

                if (!String.IsNullOrEmpty(pi.Encoding))
                    SetEncoding(_src, pi.Encoding);
            }
            else
                Consume(token);
        }
Пример #8
0
 void Consume(DtdToken token)
 {
     switch (token.Type)
     {
         case DtdTokenType.Attribute:
             _result.AddAttribute(((DtdAttributeToken)token).ToElement());
             break;
         case DtdTokenType.Comment:
             _result.AddComment(((DtdCommentToken)token).ToElement());
             break;
         case DtdTokenType.Element:
             _result.AddElement(((DtdElementToken)token).ToElement());
             break;
         case DtdTokenType.Entity:
             _result.AddEntity(((DtdEntityToken)token).ToElement());
             break;
         case DtdTokenType.Notation:
             _result.AddNotation(((DtdNotationToken)token).ToElement());
             break;
         case DtdTokenType.ProcessingInstruction:
             _result.AddProcessingInstruction(((DtdPIToken)token).ToElement());
             break;
     }
 }
Пример #9
0
        Boolean DeclarationNameBefore(Char c, DtdToken decl)
        {
            while (c.IsSpaceCharacter())
                c = _src.Next;

            if (c == Specification.NULL)
            {
                RaiseErrorOccurred(ErrorCode.NULL);
                _stringBuffer.Clear();
                _stringBuffer.Append(Specification.REPLACEMENT);
                return DeclarationName(_src.Next, decl);
            }
            else if (c == Specification.GT)
            {
                RaiseErrorOccurred(ErrorCode.TagClosedWrong);
                return false;
            }
            else if (c == Specification.EOF)
            {
                RaiseErrorOccurred(ErrorCode.EOF);
                _src.Back();
                return false;
            }

            _stringBuffer.Clear();
            _stringBuffer.Append(c);
            return DeclarationName(_src.Next, decl);
        }
Пример #10
0
        Boolean DeclarationName(Char c, DtdToken decl)
        {
            while (true)
            {
                if (c.IsSpaceCharacter())
                {
                    decl.Name = _stringBuffer.ToString();
                    _stringBuffer.Clear();
                    return DeclarationNameAfter(_src.Next);
                }
                else if (c == Specification.GT)
                {
                    decl.Name = _stringBuffer.ToString();
                    return false;
                }
                else if (c == Specification.NULL)
                {
                    RaiseErrorOccurred(ErrorCode.NULL);
                    _stringBuffer.Append(Specification.REPLACEMENT);
                }
                else if (c == Specification.EOF)
                {
                    RaiseErrorOccurred(ErrorCode.EOF);
                    _src.Back();
                    decl.Name = _stringBuffer.ToString();
                    return false;
                }
                else
                    _stringBuffer.Append(c);

                c = _src.Next;
            }
        }
Пример #11
0
        Boolean DeclarationName(Char c, DtdToken decl)
        {
            while (c.IsXmlName())
            {
                _stringBuffer.Append(c);
                c = _stream.Next;
            }

            if (c == Specification.PERCENT)
            {
                PEReference(_stream.Next);
                return DeclarationName(_stream.Current, decl);
            }

            decl.Name = _stringBuffer.ToString();
            _stringBuffer.Clear();

            if (c == Specification.EOF)
                throw Errors.Xml(ErrorCode.EOF);

            return c.IsSpaceCharacter();
        }