getCurrentDepth() public method

get the depth of context node
public getCurrentDepth ( ) : int
return int
Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="vn"></param>
        /// <param name="s"></param>
        /// <returns></returns>
        private bool lang(VTDNav vn, String s)
        {
            // check the length of s 
            bool b = false;
            vn.push2();
            try
            {
                while (vn.getCurrentDepth() >= 0)
                {
                    int i = vn.getAttrVal("xml:lang");
                    if (i != -1)
                    {
                        b = vn.matchTokenString(i, s);
                        break;
                    }
                    vn.toElement(VTDNav.P);
                }
            }
            catch (NavException e)
            {

            }
            vn.pop2();
            return b;
        }
Esempio n. 2
0
        private int process_parent(VTDNav vn)
        {
            bool b1 = false;
            Predicate t = null;
            int result;
            switch (state)
            {
                case START:
                case FORWARD:
                    t = currentStep.p;
                    while (t != null)
                    {
                        if (t.requireContext)
                        {
                            int i = computeContextSize(t, vn);
                            if (i == 0)
                            {
                                b1 = true;
                                break;
                            }
                            else
                                t.ContextSize=(i);
                        }
                        t = t.nextP;
                    }
                    if (b1)
                    {
                        if (state == FORWARD)
                        {
                            state = BACKWARD;
                            currentStep = currentStep.prevS;
                        }
                        else
                            state = END;
                        break;
                    }

                    if (vn.getCurrentDepth() == -1)
                    {
                        if (state == START)
                            state = END;
                        else
                        {
                            //vn.pop();
                            state = BACKWARD;
                            currentStep = currentStep.prevS;
                        }
                    }
                    else
                    {
                        vn.push2();
                        vn.toElement(VTDNav.P); // must return true
                        if ((currentStep.nt_eval || currentStep.nt.eval(vn))
                                && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn)))
                        {
                            if (currentStep.nextS != null)
                            {
                                state = FORWARD;
                                currentStep = currentStep.nextS;
                            }
                            else
                            {
                                state = TERMINAL;
                                result = vn.getCurrentIndex2();
                                if (isUnique(result))
                                    return result;
                            }
                        }
                        else
                        {
                            vn.pop2();
                            if (currentStep.hasPredicate)
                                currentStep.resetP(vn);
                            if (state == START)
                                state = END;
                            else
                            {
                                state = BACKWARD;
                                currentStep = currentStep.prevS;
                            }
                        }
                    }

                    break;

                case END:
                    currentStep = null;
                    // reset();
                    return -1;

                case BACKWARD:
                case TERMINAL:
                    if (currentStep.prevS == null)
                    {
                        vn.pop2();
                        state = END;
                        break;
                    }
                    else
                    {
                        vn.pop2();
                        state = BACKWARD;
                        currentStep = currentStep.prevS;
                        break;
                    }

                default:
                    throw new XPathEvalException("unknown state");

            }
            return -2;
        }
Esempio n. 3
0
		private int process_ancestor(VTDNav vn)
		{
			int result;
			bool b = false, b1 = false;
			//int contextSize;
			Predicate t = null;
			
			switch (state)
			{
				
				case START: 
					t = currentStep.p;
					while (t != null)
					{
						if (t.requireContextSize())
						{
							int i = computeContextSize(t, vn);
							if (i == 0)
							{
								b1 = true;
								break;
							}
							else
								t.ContextSize = i;
						}
						t = t.nextP;
					}
					if (b1)
					{
						state = END;
						break;
					}
					
					state = END;
					if (vn.getCurrentDepth() != - 1)
					{
						vn.push2();
						
						while (vn.toElement(VTDNav.P))
						{
							if (currentStep.eval(vn))
							{
								if (currentStep.NextStep != null)
								{
									state = FORWARD;
									currentStep = currentStep.NextStep;
									break;
								}
								else
								{
									//vn.pop();
									state = TERMINAL;
									result = vn.getCurrentIndex();
									if (isUnique(result))
										return result;
								}
							}
						}
						if (state == END)
						{
							currentStep.resetP(vn);
							vn.pop2();
						}
					}
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case FORWARD: 
					t = currentStep.p;
					while (t != null)
					{
						if (t.requireContextSize())
						{
							int i = computeContextSize(t, vn);
							if (i == 0)
							{
								b1 = true;
								break;
							}
							else
								t.ContextSize = i;
						}
						t = t.nextP;
					}
					if (b1)
					{
						currentStep = currentStep.PrevStep;
						state = BACKWARD;
						break;
					}
					state = BACKWARD;
					vn.push2();
					
					while (vn.toElement(VTDNav.P))
					{
						if (currentStep.eval(vn))
						{
							if (currentStep.NextStep != null)
							{
								state = FORWARD;
								currentStep = currentStep.NextStep;
								break;
							}
							else
							{
								//vn.pop();
								state = TERMINAL;
								result = vn.getCurrentIndex();
								if (isUnique(result))
									return result;
							}
						}
					}
					if (state == BACKWARD)
					{
						currentStep.resetP(vn);
						vn.pop2();
						currentStep = currentStep.PrevStep;
					}
					break;
				
				
				case BACKWARD: 
					b = false;
					vn.push2();
					
					while (vn.toElement(VTDNav.P))
					{
						if (currentStep.eval(vn))
						{
							if (currentStep.NextStep != null)
							{
								state = FORWARD;
								currentStep = currentStep.NextStep;
								b = true;
								break;
							}
							else
							{
								//vn.pop();
								state = TERMINAL;
								result = vn.getCurrentIndex();
								if (isUnique(result))
									return result;
							}
						}
					}
					if (b == false)
					{
						vn.pop2();
						if (currentStep.PrevStep != null)
						{
							currentStep.resetP(vn);
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						else
						{
							state = END;
						}
					}
					break;
				
				
				case TERMINAL: 
					while (vn.toElement(VTDNav.P))
					{
						if (currentStep.eval(vn))
						{
							result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					vn.pop2();
					
					if (currentStep.PrevStep != null)
					{
						currentStep.resetP(vn);
						state = BACKWARD;
						currentStep = currentStep.PrevStep;
					}
					else
					{
						state = END;
					}
					break;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}