Exemplo n.º 1
0
 /// <summary> Select an attribute name for iteration, * choose all attributes of an element</summary>
 /// <param name="en">
 /// </param>
 protected internal void  selectAttr(System.String en)
 {
     if (en == null)
     {
         throw new System.ArgumentException("attribute name can't be null");
     }
     iter_type = ATTR;
     ft        = true;
     size      = vn.getTokenCount();
     name      = en;
 }
Exemplo n.º 2
0
        private int count(VTDNav vn)
        {
            int a = -1;

            if (argCount() != 1 || argumentList.e.NodeSet == false)
            {
                throw new System.ArgumentException("Count()'s argument count is invalid");
            }
            vn.push2();
            try
            {
                a = 0;
                argumentList.e.adjust(vn.getTokenCount());
                while (argumentList.e.evalNodeSet(vn) != -1)
                {
                    a++;
                }
                argumentList.e.reset(vn);
                vn.pop2();
            }
            catch (System.Exception e)
            {
                argumentList.e.reset(vn);
                vn.pop2();
            }
            return(a);
        }
Exemplo n.º 3
0
/// <summary>
///
/// </summary>
/// <param name="en"></param>
        protected internal void selectNameSpace(String en)
        {
            if (en == null)
            {
                throw new ArgumentException("namespace name can't be null");
            }
            iter_type = NAME_SPACE;
            ft        = true;
            size      = vn.getTokenCount();
            name      = en;
            if (!en.Equals("*"))
            {
                name2 = "xmlns:" + en;
            }
            if (fib == null)
            {
                fib = new FastIntBuffer(4);
            }
            else
            {
                fib.size_Renamed_Field = 0;
            }
        }
Exemplo n.º 4
0
        public override int evalNodeSet(VTDNav vn)
        {
            // if tne predicate require context size
            // needs to precompute the context size
            // vn.push2();
            // computerContext();
            // set contxt();
            // vn.pop2()
            // if the context size is zero
            // get immediately set teh state to end
            // or backward
            if (first_time && p.requireContext)
            {
                first_time = false;
                int i = 0;
                //vn.push2();
                e.adjust(vn.getTokenCount());
                while (e.evalNodeSet(vn) != -1)
                {
                    i++;
                }
                //vn.pop2();
                p.ContextSize = i;
                reset2(vn);
            }
            if (out_of_range)
            {
                return(-1);
            }
            int a = e.evalNodeSet(vn);

            while (a != -1)
            {
                if (p.eval(vn) == true)
                {
                    //p.reset();
                    return(a);
                }
                else
                {
                    //p.reset();
                    a = e.evalNodeSet(vn);
                }
            }
            return(-1);
        }
Exemplo n.º 5
0
        protected override bool GetNextToken()
        {
            if (_isfirsttime)
            {
                _vgnav = null;
                _vg    = new VTDGen();

                if (_vg.parseFile(_fullname, true))
                {
                    _vgnav = _vg.getNav();
                    _vgnav.toElement(VTDNav.ROOT);
                    //_vgap = new AutoPilot(_vgnav);
                    //_vgap.selectElement("*");
                    _isfirsttime   = false;
                    _current_index = 0;
                }
            }
            if (_vgnav == null)
            {
                return(false);
            }
            int nb_tokens = _vgnav.getTokenCount();

            current_token_len = 0;
            while (true)
            {
                try
                {
                    if (_current_index >= nb_tokens)
                    {
                        return(false);
                    }
                    int len = _vgnav.getTokenLength(_current_index);
                    if (len >= 3)
                    {
                        string token = _vgnav.toString(_current_index);
                        len = token.Length;
                        if (len >= 3)
                        {
                            if (len > MAX_WORD_LEN)
                            {
                                len = MAX_WORD_LEN;
                            }
                            current_token        = token.ToCharArray(0, len);
                            current_token_offset = _vgnav.getTokenOffset(_current_index);
                            current_token_len    = len; //_vgnav.getTokenLength(_current_index)
                            _current_index++;
                            return(true);
                        }
                    }
                }
                catch (Exception e)
                {
                    e = e;
                    return(false);
                }

                _current_index++;
            }
            return(true);
        }