///////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// ������
        /// </summary>
        public CHtmlProcessingInstruction(CHtmlProcessingInstruction obj)
            : base(obj)
        {
            System.Diagnostics.Debug.Assert(obj != null) ;

            obj.AssertValid();
            m_value = obj.m_value;
        }
Ejemplo n.º 2
0
        ///////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// »ý¼ºÀÚ
        /// </summary>
        public CHtmlProcessingInstruction(CHtmlProcessingInstruction obj)
            : base(obj)
        {
            System.Diagnostics.Debug.Assert(obj != null);

            obj.AssertValid();
            m_value = obj.m_value;
        }
Ejemplo n.º 3
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 
        /// </summary>
        /// <param name="result"></param>
        private void ResolveTokens()
        {
            System.Diagnostics.Debug.Assert(m_result != null);

            int nodeIDCount = 0;

            int visitor = 0;
            while(visitor < m_tokens.Count)
            {
                Token token = m_tokens[visitor];
                //=====================================================================================//
                if(token.Type == Token.TokenType.TagBegin) // Read Start Tag
                {
                    ResolveStartTag(ref visitor, ref nodeIDCount);
                }
                //=====================================================================================//
                else if(token.Type == Token.TokenType.TagCloseBegin) // Read End Tag
                {
                    ResolveEndTag(ref visitor);
                }
                //=====================================================================================//
                else if(token.Type == Token.TokenType.Text) // Text
                {
                    StringBuilder builder = new StringBuilder();
                    do
                    {
                        builder.Append(token.Content);
                        ++ visitor;
                        token = m_tokens[visitor];
                    }
                    while(visitor < m_tokens.Count && token.Type == Token.TokenType.Text);

                    string text = builder.ToString();
                    text = CHtmlUtil.ComapctWSCString(text);
                    text = CHtmlUtil.TranHtmlTextToStr(text);

                    CHtmlText node = new CHtmlText(text);
                    ++nodeIDCount;
                    node.NodeID = nodeIDCount;
                    if(TextCreatedEvent != null) TextCreatedEvent(node);

                    m_currentLevel.Add(node);
                }
                //=====================================================================================//
                else if(token.Type == Token.TokenType.Comment) // ?? Comment
                {
                    CHtmlComment node = new CHtmlComment(token.Content);
                    ++nodeIDCount;
                    node.NodeID = nodeIDCount;
                    if(CommentCreatedEvent != null) CommentCreatedEvent(node);

                    m_currentLevel.Add(node);
                    ++visitor;
                }
                //=====================================================================================//
                else if(token.Type == Token.TokenType.SGMLComment) // SGML Comment
                {
                    CHtmlComment node = new CHtmlComment(token.Content);
                    node.SGMLComment = true;
                    ++nodeIDCount;
                    node.NodeID = nodeIDCount;
                    if(CommentCreatedEvent != null) CommentCreatedEvent(node);

                    m_currentLevel.Add(node);
                    ++visitor;
                }
                //=====================================================================================//
                else if(token.Type == Token.TokenType.ProcessingInstruction) // SGML Comment
                {
                    CHtmlProcessingInstruction node = new CHtmlProcessingInstruction(token.Content);
                    ++nodeIDCount;
                    node.NodeID = nodeIDCount;
                    if(ProcessingInstructionCreatedEvent != null) ProcessingInstructionCreatedEvent(node);

                    m_currentLevel.Add(node);
                    ++visitor;
                }
                //=====================================================================================//
                else if(token.Type == Token.TokenType.EndOfHtml)
                {
                    /*
                    for(int index = m_result.Count - 1; index >= 0; --index)
                    {
                        CHtmlElement childElement = m_result[index] as CHtmlElement;
                        if(childElement != null && childElement.m_close == false)
                            CloseElement(childElement);
                    }
                    */

                    m_tokens.Clear();
                    break;
                }
                //=====================================================================================//
            }
        }