Ejemplo n.º 1
0
        private void Parse_AttrName()
        {
            while (this.ReadNext_char())
            {
                if (this.blankChars_hs.Contains(this.currChar) || this.currChar == '=')
                {
                    Hss_XML_obj xo = this.element_st.Peek();
                    xo.SetTempKey(this.sb.ToString());

                    this.sb.Clear();
                    this.ParsingState = XML_ParseState.AfterAttrName;
                    break;
                }
                else if (this.currChar == '>')
                {
                    this.sb.Clear();
                    this.ParsingState = XML_ParseState.OutElement;
                    break;
                }
                else
                {
                    this.sb.Append(this.currChar);
                }
            }
        }
Ejemplo n.º 2
0
        private void Parse_CommentValue()
        {
            char c1 = ' ', c2 = ' ';

            while (this.ReadNext_char())
            {
                if (this.currChar == '>')
                {
                    if (c1 == '-' && c2 == '-')
                    {
                        string comment = sb.ToString();
                        if (comment.Length >= 4)
                        {
                            comment = comment.Substring(2, comment.Length - 4);
                        }

                        Hss_XML_obj xo = new Hss_XML_obj("$Comment$", XML_ElementType.Comment);
                        xo.value = comment;
                        this.element_st.Peek().Add_obj(xo);

                        this.sb.Clear();
                        this.ParsingState = XML_ParseState.OutElement;
                        break;
                    }
                }

                c1 = c2;
                c2 = this.currChar;
                this.sb.Append(this.currChar);
            }
        }
Ejemplo n.º 3
0
        private void Parse_AfterAttrName()
        {
            while (this.ReadNext_char())
            {
                if (this.blankChars_hs.Contains(this.currChar) || this.currChar == '=')
                {
                    continue;
                }
                else if (this.quoteChars_hs.Contains(this.currChar))
                {
                    this.sb.Clear();
                    this.ParsingState        = XML_ParseState.AttrValue;
                    this.value_hasQuote_flag = true;
                }
                else
                {
                    this.sb.Clear();
                    this.sb.Append(this.currChar);
                    this.ParsingState        = XML_ParseState.AttrValue;
                    this.value_hasQuote_flag = false;
                }

                break;
            }
        }
Ejemplo n.º 4
0
        private void Parse_InElement()
        {
            while (this.ReadNext_char())
            {
                if (this.blankChars_hs.Contains(this.currChar))
                {
                    continue;
                }
                else if (this.currChar == '>')
                {
                    this.ParsingState = XML_ParseState.OutElement;
                }
                else if (this.currChar == '/' || this.currChar == '?')
                {
                    Hss_XML_obj xo = this.element_st.Pop();
                    this.element_st.Peek().Add_obj(xo);
                    //xo.Show();//test output

                    this.ParsingState = XML_ParseState.OutElement;
                }
                else
                {
                    this.sb.Clear();
                    this.sb.Append(this.currChar);
                    this.ParsingState = XML_ParseState.AttrName;
                }

                break;
            }
        }
Ejemplo n.º 5
0
        private void Parse_ElementName()
        {
            while (this.ReadNext_char())
            {
                if (this.blankChars_hs.Contains(this.currChar))
                {
                    string eleName = HssStr.SafeXML_to_ori(this.sb.ToString());
                    this.element_st.Push(new Hss_XML_obj(eleName, this.ElementType));
                    this.sb.Clear();

                    this.ParsingState = XML_ParseState.InElement;
                    break;
                }
                else if (this.currChar == '>')
                {
                    string eleName = HssStr.SafeXML_to_ori(this.sb.ToString());
                    this.element_st.Push(new Hss_XML_obj(eleName, this.ElementType));
                    this.sb.Clear();
                    this.ParsingState = XML_ParseState.OutElement;
                    break;
                }
                else
                {
                    this.sb.Append(this.currChar);
                }
            }
        }
Ejemplo n.º 6
0
 private void Parse_ElementEnd()
 {
     while (this.ReadNext_char())
     {
         if (this.currChar == '>')
         {
             this.ParsingState = XML_ParseState.OutElement;
             break;
         }
     }
 }
Ejemplo n.º 7
0
        private void Parse_ElementStart()
        {
            if (!this.ReadNext_char())
            {
                return;
            }

            if (this.currChar == '?')
            {
                this.sb.Clear();
                this.ParsingState = XML_ParseState.ElementName;
                this.ElementType  = XML_ElementType.Declare;
            }
            else if (this.currChar == '!')
            {
                this.sb.Clear();
                this.ParsingState = XML_ParseState.CommentValue;
                this.ElementType  = XML_ElementType.Comment;
            }
            else if (this.currChar == '>')
            {
                Hss_XML_obj xo = this.element_st.Peek();
                xo.Add_obj(new Hss_XML_obj(null, this.ElementType));

                this.ParsingState = XML_ParseState.OutElement;
            }
            else if (this.currChar == '/')
            {
                Hss_XML_obj xo = this.element_st.Pop();
                xo.value = HssStr.SafeXML_to_ori(this.sb.ToString().Trim());
                this.sb.Clear();

                this.element_st.Peek().Add_obj(xo);
                //xo.Show();//test output

                this.ParsingState = XML_ParseState.ElementEnd;
            }
            else
            {
                this.sb.Clear();
                this.sb.Append(this.currChar);

                this.ParsingState = XML_ParseState.ElementName;
                this.ElementType  = XML_ElementType.Normal;
            }
        }
Ejemplo n.º 8
0
 private void Parse_OutElement()
 {
     while (this.ReadNext_char())
     {
         if (this.currChar == '<')
         {
             this.ParsingState = XML_ParseState.ElementStart;
             break;
         }
         else if (this.blankChars_hs.Contains(this.currChar))
         {
             this.sb.Append(' ');
         }
         else
         {
             this.sb.Append(this.currChar);
         }
     }
 }
Ejemplo n.º 9
0
        private void Parse_AttrValue()
        {
            while (this.ReadNext_char())
            {
                if ((this.quoteChars_hs.Contains(this.currChar) && this.value_hasQuote_flag) ||
                    (this.blankChars_hs.Contains(this.currChar) && !this.value_hasQuote_flag))
                {
                    Hss_XML_obj xo = this.element_st.Peek();
                    xo.SetTempValue(this.sb.ToString());

                    this.sb.Clear();
                    this.ParsingState = XML_ParseState.InElement;
                    break;
                }
                else
                {
                    this.sb.Append(this.currChar);
                }
            }
        }