getCurrentIndex() public method

Get the index value of the current element. Creation date: (11/16/03 6:40:25 PM)
public getCurrentIndex ( ) : int
return int
コード例 #1
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
        private String getNameSpaceURI(VTDNav vn)
        {
            if (argCount1 == 0)
            {
                try
                {
                    int i = vn.getCurrentIndex();
                    int type = vn.getTokenType(i);

                    if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
                            || type == VTDNav.TOKEN_ATTR_NAME))
                    {
                        int a = vn.lookupNS();
                        if (a == 0)
                            return "";
                        else
                            return vn.toString(a);
                    }
                    return "";
                }
                catch (Exception e)
                {
                    return "";
                }
            }
            else if (argCount1 == 1 && argumentList.e.NodeSet)
            {
                vn.push2();
                int size = vn.contextStack2.size;
                int a = -1;
                try
                {
                    a = argumentList.e.evalNodeSet(vn);
                }
                catch (Exception e)
                {
                }
                String s = "";
                // return a;
                try
                {
                    if (a == -1 || vn.ns == false)
                    { }
                    else
                    {
                        int type = vn.getTokenType(a);
                        if (type == VTDNav.TOKEN_STARTING_TAG
                                || type == VTDNav.TOKEN_ATTR_NAME)
                            s = vn.toString(vn.lookupNS());

                    }
                }
                catch (Exception e) { };
                vn.contextStack2.size = size;
                argumentList.e.reset(vn);
                vn.pop2();
                return s;

            }
            else
                throw new System.ArgumentException
                ("namespace-uri()'s argument count is invalid");
        }
コード例 #2
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
        private bool matchLocalName(VTDNav vn)
        {
            if (argCount1 == 1)
            {
                try
                {
                    int index = vn.getCurrentIndex();
                    int type = vn.getTokenType(index);
                    String s1 = argumentList.e.evalString(vn);
                    if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
                            || type == VTDNav.TOKEN_ATTR_NAME))
                    {
                        int offset = vn.getTokenOffset(index);
                        int length = vn.getTokenLength(index);
                        if (length < 0x10000 || (length >> 16) == 0)
                        {
                            return (vn.compareRawTokenString(index, s1) == 0);//vn.toRawString(index);
                        }
                        else
                        {
                            int preLen = length >> 16;
                            int QLen = length & 0xffff;
                            if (preLen != 0)
                            {
                                return (vn.compareRawTokenString(offset + preLen + 1, QLen
                                           - preLen - 1, s1) == 0);
                            }
                        }
                    }
                    else if (type == VTDNav.TOKEN_PI_NAME)
                    {
                        return vn.compareRawTokenString(index, s1) == 0;
                    }
                    else
                        return "".Equals(s1);
                }
                catch (NavException e)
                {
                    return false; // this will never occur
                }

            }
            else if (argCount1 == 2)
            {
                int a = evalFirstArgumentListNodeSet2(vn);
                String s1 = argumentList.next.e.evalString(vn);
                if (a == -1 || vn.ns == false)
                    return "".Equals(s1);
                int type = vn.getTokenType(a);
                if (type == VTDNav.TOKEN_STARTING_TAG || type == VTDNav.TOKEN_ATTR_NAME)
                {
                    //return "".equals(s1);
                    try
                    {
                        int offset = vn.getTokenOffset(a);
                        int length = vn.getTokenLength(a);
                        if (length < 0x10000 || (length >> 16) == 0)
                            return vn.compareRawTokenString(a, s1) == 0;
                        else
                        {
                            int preLen = length >> 16;
                            int QLen = length & 0xffff;
                            if (preLen != 0)
                                return vn.compareRawTokenString(offset + preLen + 1,
                                        QLen - preLen - 1, s1) == 0;
                            /*else {
                                return vn.toRawString(offset, QLen);
                            }*/
                        }
                    }
                    catch (NavException e)
                    {
                        return "".Equals(s1); // this will almost never occur
                    }
                }
                else if (type == VTDNav.TOKEN_PI_NAME)
                {
                    try
                    {
                        return vn.compareRawTokenString(a, s1) == 0;
                    }
                    catch (NavException e)
                    {
                        return "".Equals(s1);
                    }
                }
                return "".Equals(s1);
            }
            else
                throw new ArgumentException
                ("match-local-name()'s argument count is invalid");
            return false;
        }
コード例 #3
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
        private String getLocalName(VTDNav vn)
        {
            if (argCount1 == 0)
            {
                try
                {
                    int index = vn.getCurrentIndex();
                    int type = vn.getTokenType(index);
                    if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
                            || type == VTDNav.TOKEN_ATTR_NAME))
                    {
                        int offset = vn.getTokenOffset(index);
                        int length = vn.getTokenLength(index);
                        if (length < 0x10000)
                        {
                            if (vn.localNameIndex != index)
                            {
                                vn.localNameIndex = index;
                                vn.localName = vn.toRawString(index);
                            }
                            return vn.localName;
                        }
                        else
                        {
                            int preLen = length >> 16;
                            int QLen = length & 0xffff;
                            if (preLen != 0)
                            {
                                if (vn.localNameIndex != index)
                                {
                                    vn.localNameIndex = index;
                                    vn.localName = vn.toRawString(offset + preLen + 1, QLen
                                            - preLen - 1);
                                }
                                return vn.localName;
                            }
                            else
                            {
                                if (vn.localNameIndex != index)
                                {
                                    vn.localNameIndex = index;
                                    vn.localName = vn.toRawString(offset, QLen);
                                }
                                return vn.localName;
                            }
                        }
                    }
                    else
                        return "";
                }
                catch (NavException e)
                {
                    return ""; // this will almost never occur
                }

            }
            else if (argCount1 == 1)
            {
                int a = evalFirstArgumentListNodeSet2(vn);

                if (a == -1 || vn.ns == false)
                    return "";
                int type = vn.getTokenType(a);
                if (type == VTDNav.TOKEN_STARTING_TAG || type == VTDNav.TOKEN_ATTR_NAME)
                {

                    try
                    {
                        int offset = vn.getTokenOffset(a);
                        int length = vn.getTokenLength(a);
                        if (length < 0x10000)
                            return vn.toRawString(a);
                        else
                        {
                            int preLen = length >> 16;
                            int QLen = length & 0xffff;
                            if (preLen != 0)
                                return vn.toRawString(offset + preLen + 1,
                                        QLen - preLen - 1);
                            else
                            {
                                return vn.toRawString(offset, QLen);
                            }
                        }
                    }

                    catch (NavException e)
                    {
                        return ""; // this will almost never occur
                    }
                }
                else if (type == VTDNav.TOKEN_PI_NAME)
                {
                    try
                    {
                        return vn.toRawString(a);
                    }
                    catch (NavException e)
                    {
                        return "";
                    }
                }
                else
                    return "";
            }
            else
                throw new System.ArgumentException
                ("local-name()'s argument count is invalid");
        }
コード例 #4
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
        private System.String normalizeSpace(VTDNav vn)
        {
            if (argCount1 == 0)
            {
                String s = null;
                try
                {
                    if (vn.atTerminal)
                    {
                        int ttype = vn.getTokenType(vn.LN);
                        if (ttype == VTDNav.TOKEN_CDATA_VAL)
                            s = vn.toRawString(vn.LN);
                        else if (ttype == VTDNav.TOKEN_ATTR_NAME ||
                             ttype == VTDNav.TOKEN_ATTR_NS)
                        {
                            s = vn.toString(vn.LN + 1);
                        }
                        else
                            s = vn.toString(vn.LN);
                    }
                    else
                    {
                        int i = vn.getCurrentIndex();
                        int t = vn.getTokenType(i);
                        if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                        {
                            s = vn.toNormalizedXPathString(i);
                        }
                        else
                            s = vn.toNormalizedString(i);
                    }
                    return normalize(s);
                }
                catch (NavException e)
                {
                    return ""; // this will almost never occur
                }
            }
            else if (argCount1 == 1)
            {
                String s = "";
                if (argumentList.e.NodeSet)
                {
                    //boolean b = false;
                    int a = evalFirstArgumentListNodeSet(vn);
                    if (a == -1)
                        return "";
                    else
                    {
                        try
                        {
                            int t = vn.getTokenType(a);
                            if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
                            {
                                s = vn.toNormalizedXPathString(a);
                            }
                            else
                                s = vn.toNormalizedString(a);
                        }
                        catch (Exception e)
                        {
                        }
                        return s;
                    }
                }
                else
                {
                    s = argumentList.e.evalString(vn);
                    return normalize(s);
                }
	        
            }
            throw new System.ArgumentException("normalize-space()'s argument count is invalid");
            //return null;
        }
コード例 #5
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
 private bool matchName(VTDNav vn)
 {
     int a;
     if (argCount1 == 1)
     {
         a = vn.getCurrentIndex();
         int type = vn.getTokenType(a);
         String s1 = argumentList.e.evalString(vn);
         if (type == VTDNav.TOKEN_STARTING_TAG
                 || type == VTDNav.TOKEN_ATTR_NAME
                 || type == VTDNav.TOKEN_PI_NAME)
         {
             try
             {
                 return vn.matchRawTokenString(a, s1);
             }
             catch (Exception e)
             {
                 return false;
             }
         }
         else
             return false;
     }
     else if (argCount1 == 2)
     {
         a = evalFirstArgumentListNodeSet2(vn);
         String s1 = argumentList.next.e.evalString(vn);
         try
         {
             if (a == -1 || vn.ns == false)
                 return s1.CompareTo("")==0;
             else
             {
                 int type = vn.getTokenType(a);
                 if (type == VTDNav.TOKEN_STARTING_TAG
                         || type == VTDNav.TOKEN_ATTR_NAME
                         || type == VTDNav.TOKEN_PI_NAME)
                     return vn.matchRawTokenString(a, s1);
                 return false;
             }
         }
         catch (Exception e)
         {
         }
         return false;
     }
     else
         throw new System.ArgumentException(
                 "matchName()'s argument count is invalid");
 }
コード例 #6
0
        protected int process_DDFP2(VTDNav vn)
        {
            AutoPilot ap;
            bool b = false, b1 = false;
            Predicate t = null;
            int result;

            switch (state) {
            case START:
            case FORWARD:
            /*if (vn.atTerminal) {
                if (state == START)
                    state = END;
                else {
                    // no need to set_ft to true
                    // no need to resetP
                    state = BACKWARD;
                    currentStep = currentStep.prevS;
                }
                break;
            }*/

            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 == START)
                    state = END;
                else {
                    currentStep = currentStep.prevS;
                    state = BACKWARD;
                }
                break;
            }

            String helper = null;
            /*if (currentStep.nt.testType == NodeTest.NAMETEST) {
                helper = currentStep.nt.nodeName;
            } else if (currentStep.nt.testType == NodeTest.NODE) {
                helper = "*";
            } else
                throw new XPathEvalException(
                        "can't run descendant "
                                + "following, or following-sibling axis over comment(), pi(), and text()");*/
            if (currentStep.o == null)
                currentStep.o = ap = new AutoPilot(vn);
            else {
                ap = (AutoPilot) currentStep.o;
                ap.bind(vn);
            }
            if (currentStep.ft) {

                /*if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF)
                    if (currentStep.nt.testType == NodeTest.NODE)
                        ap.setSpecial(true);
                    else
                        ap.setSpecial(false);*/
                // currentStep.o = ap = new AutoPilot(vn);
                if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF)
                    ap.selectNode();
                else if (currentStep.axis_type == AxisType.DESCENDANT)
                    ap.selectDescendantNode();
                else if (currentStep.axis_type == AxisType.PRECEDING)
                    ap.selectPrecedingNode();
                else
                    ap.selectFollowingNode();
                currentStep.ft = false;
            }
            if (state == START)
                state = END;

            vn.push2(); // not the most efficient. good for now
            // System.out.println("  --++ push in //");
            b = false;
            while (ap.iterate2()) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                        && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                    b = true;
                    break;
                }
            }
            if (b == false) {
                vn.pop2();
                // System.out.println("  --++ pop in //");
                currentStep.ft = true;
                if (currentStep.hasPredicate)
                    currentStep.resetP(vn);
                if (state == FORWARD) {
                    state = BACKWARD;
                    currentStep = currentStep.prevS;
                }
            } else {
                if (currentStep.nextS != null) {
                    state = FORWARD;
                    currentStep = currentStep.nextS;
                } else {
                    // vn.pop();
                    state = TERMINAL;
                    result = vn.getCurrentIndex();
                    if (isUnique(result))
                        return result;
                }
            }
            break;

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

            case BACKWARD:
            if(currentStep.out_of_range){
                currentStep.out_of_range = false;
                transition_DDFP(vn);
                break;
            }
            // currentStep = currentStep.prevS;
            ap = (AutoPilot) currentStep.o;
            // vn.push();
            //b = false;
            while (ap.iterate2()) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                        && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                    b = true;
                    break;
                }
            }
            if (b ) {
                //if (currentStep.nextS != null) {
                    // vn.push();
                    // System.out.println("  --++ push in //");
                    state = FORWARD;
                    currentStep = currentStep.nextS;
                //} else {
                //	state = TERMINAL;
                //	result = vn.getCurrentIndex();
                //	if (isUnique(result))
                //		return result;
                //}
            } else
                transition_DDFP(vn);
            break;

            case TERMINAL:
            if(currentStep.out_of_range){
                currentStep.out_of_range = false;
                transition_DDFP(vn);
                break;
            }
            ap = (AutoPilot) currentStep.o;
            b = false;
            while (ap.iterate2()) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                        && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                    b = true;
                    break;
                }
            }
            if (b) {
                //if (currentStep.evalPredicates(vn)) {
                result = vn.getCurrentIndex();
                if (isUnique(result))
                    return result;
                //}
            } else{
                transition_DDFP(vn);
            }
            break;

            default:
            throw new XPathEvalException("unknown state");
            }
            return -2;
        }
コード例 #7
0
ファイル: LocationPathExpr.cs プロジェクト: DuLerWeil/vtd-xml
        protected internal int process_ancestor2( 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.requireContext) {
                        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.toNode(VTDNav.P)) {
                        if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                                && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                            if (currentStep.nextS != null) {
                                state = FORWARD;
                                currentStep = currentStep.nextS;
                                break;
                            } else {
                                //vn.pop();
                                state = TERMINAL;
                                result = vn.getCurrentIndex();
                                if (isUnique(result))
                                    return result;
                            }
                        }
                    }
                    if (state == END) {
                        if (currentStep.hasPredicate)
                            currentStep.resetP(vn);
                        vn.pop2();
                    }
               // }
                break;

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

            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){
                    currentStep = currentStep.prevS;
                    state = BACKWARD;
                    break;
                }
                state =  BACKWARD;
               	vn.push2();

               	while(vn.toNode(VTDNav.P)){
               		if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
               				&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))){
               			if (currentStep.nextS != null){
               				 state =  FORWARD;
               				currentStep = currentStep.nextS;
               				break;
               			}
               			else {
               				//vn.pop();
               				 state =  TERMINAL;
               				result = vn.getCurrentIndex();
                            if ( isUnique(result))
                                return result;
               			}
               		}
               	}
               	if ( state == BACKWARD){
                    if (currentStep.hasPredicate)
                        currentStep.resetP(vn);
                    vn.pop2();
               		currentStep=currentStep.prevS;
               	}
              	break;

            case BACKWARD:
                b = false;
                vn.push2();

                while (vn.toNode(VTDNav.P)) {
                    if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                            && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                        if (currentStep.nextS!= null) {
                             state =  FORWARD;
                            currentStep = currentStep.nextS;
                            b = true;
                            break;
                        } else {
                            //vn.pop();
                             state =  TERMINAL;
                            result = vn.getCurrentIndex();
                            if ( isUnique(result))
                                return result;
                        }
                    }
                }
                if (b==false){
                    vn.pop2();
                    if (currentStep.prevS!=null) {
                        if (currentStep.hasPredicate)
                            currentStep.resetP(vn);
                        state =  BACKWARD;
                        currentStep = currentStep.prevS;
                    }
                    else {
                         state =  END;
                    }
                }
                break;

            case TERMINAL:
                while (vn.toNode(VTDNav.P)) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                        && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                    result = vn.getCurrentIndex();
                    if ( isUnique(result))
                        return result;
                }
            }
            vn.pop2();

            if (currentStep.prevS!=null) {
                if (currentStep.hasPredicate)
                    currentStep.resetP(vn);
                 state =  BACKWARD;
                currentStep = currentStep.prevS;
            }
            else {
                 state =  END;
            }
            break;

            default:
            throw new  XPathEvalException("unknown state");
            }
            return -2;
        }
コード例 #8
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
 private String getString(VTDNav vn){
     if (argCount() == 0)
         try
         {
             if (vn.atTerminal)
             {
                 if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_CDATA_VAL)
                     return vn.toRawString(vn.LN);
                 return vn.toString(vn.LN);
             }
             return vn.toString(vn.getCurrentIndex());
         }
         catch (NavException e)
         {
             return null; // this will almost never occur
         }
     else if (argCount() == 1)
     {
         return argumentList.e.evalString(vn);
     }
     else
         throw new System.ArgumentException("String()'s argument count is invalid");
 }
コード例 #9
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
        private String getLocalName(VTDNav vn)
        {
            if (argCount() == 0)
            {
                try
                {
                    int index = vn.getCurrentIndex();
                    int type = vn.getTokenType(index);
                    if (vn.ns && (type == VTDNav.TOKEN_STARTING_TAG
                            || type == VTDNav.TOKEN_ATTR_NAME))
                    {
                        long offset = vn.getTokenOffset(index);
                        int length = vn.getTokenLength(index);
                        if (length < 0x10000)
                            return vn.toRawString(index);
                        else
                        {
                            int preLen = length >> 16;
                            int QLen = length & 0xffff;
                            if (preLen != 0)
                                return vn.toRawString(offset + preLen + 1, QLen
                                        - preLen - 1);
                            else
                            {
                                return vn.toRawString(offset, QLen);
                            }
                        }
                    }
                    else
                        return "";
                }
                catch (NavException e)
                {
                    return ""; // this will almost never occur
                }

            } else if (argCount() == 1)
            {
                int a = -1;
                vn.push2();
                try
                {
                    a = argumentList.e.evalNodeSet(vn);
                    argumentList.e.reset(vn);
                    vn.pop2();
                }
                catch (Exception e)
                {
                    argumentList.e.reset(vn);
                    vn.pop2();
                }

                if (a == -1 || vn.ns == false)
                    return "";
                int type = vn.getTokenType(a);
                if (type != VTDNav.TOKEN_STARTING_TAG && type != VTDNav.TOKEN_ATTR_NAME)
                    return "";
                try
                {
                    long offset = vn.getTokenOffset(a);
                    int length = vn.getTokenLength(a);
                    if (length < 0x10000)
                        return vn.toRawString(a);
                    else
                    {
                        int preLen = length >> 16;
                        int QLen = length & 0xffff;
                        if (preLen != 0)
                            return vn.toRawString(offset + preLen + 1,
                                    QLen - preLen - 1);
                        else
                        {
                            return vn.toRawString(offset, QLen);
                        }
                    }
                }
                catch (NavException e)
                {
                    return ""; // this will almost never occur
                }
            }
            else
                throw new System.ArgumentException
                ("local-name()'s argument count is invalid");
        }
コード例 #10
0
		private int process_DDFP(VTDNav vn)
		{
			AutoPilot ap;
			bool b = false, b1 = false;
			//int contextSize;
			Predicate t = null;
			int result;
			
			
			switch (state)
			{
				
				case START: 
				case FORWARD: 
					if (vn.atTerminal)
					{
						if (state == START)
							state = END;
						else
						{
							// no need to set_ft to true
							// no need to resetP
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						break;
					}
					
					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)
					{
						if (state == START)
							state = END;
						else
						{
							currentStep = currentStep.PrevStep;
							state = BACKWARD;
						}
						break;
					}
					
					System.String helper = null;
					if (currentStep.nt.testType == NodeTest.NODE)
					{
						helper = "*";
					}
					else
					{
						helper = currentStep.nt.nodeName;
					}
					if (currentStep.o == null)
						currentStep.o = ap = new AutoPilot(vn);
					else
					{
						ap = (AutoPilot) currentStep.o;
						ap.bind(vn);
					}
					if (currentStep.get_ft() == true)
					{
						
						if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF)
							if (currentStep.nt.testType == NodeTest.NODE)
								ap.Special = true;
							else
								ap.Special = false;
						//currentStep.o = ap = new AutoPilot(vn);
						if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF)
							ap.selectElement(helper);
						else if (currentStep.axis_type == AxisType.DESCENDANT)
							ap.selectElement_D(helper);
						else if (currentStep.axis_type == AxisType.PRECEDING)
							ap.selectElement_P(helper);
						else
							ap.selectElement_F(helper);
						currentStep.set_ft(false);
					}
					if (state == START)
						state = END;
					
					vn.push2(); // not the most efficient. good for now
					//System.out.println("  --++ push in //");
					b = false;
					while (ap.iterate())
					{
						if (currentStep.evalPredicates(vn))
						{
							b = true;
							break;
						}
					}
					if (b == false)
					{
						vn.pop2();
						//System.out.println("  --++ pop in //");
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						if (state == FORWARD)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
					}
					else
					{
						if (currentStep.NextStep != null)
						{
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else
						{
							//vn.pop();
							state = TERMINAL;
							result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case BACKWARD: 
					//currentStep = currentStep.getPrevStep();
					ap = (AutoPilot) currentStep.o;
					//vn.push();
					b = false;
					while (ap.iterate())
					{
						if (currentStep.evalPredicates(vn))
						{
							b = true;
							break;
						}
					}
					if (b == false)
					{
						vn.pop2();
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						//System.out.println("  --++ pop in //");
						if (currentStep.PrevStep != null)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						else
							state = END;
					}
					else
					{
						if (currentStep.NextStep != null)
						{
							//vn.push();
							//System.out.println("  --++ push in //");
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else
						{
							state = TERMINAL;
							result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					break;
				
				
				case TERMINAL: 
					ap = (AutoPilot) currentStep.o;
					b = false;
					while (ap.iterate())
					{
						if (currentStep.evalPredicates(vn))
						{
							b = true;
							break;
						}
					}
					if (b == true)
					{
						if (currentStep.evalPredicates(vn))
						{
							result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					else if (currentStep.PrevStep == null)
					{
						currentStep.resetP(vn);
						vn.pop2();
						state = END;
					}
					else
					{
						vn.pop2();
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						//System.out.println(" --++ pop in //");
						state = BACKWARD;
						//currentStep.ft = true;
						currentStep = currentStep.PrevStep;
					}
					break;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}
コード例 #11
0
		private int process_parent(VTDNav vn)
		{
			bool b1 = false;
			//int contextSize;
			Predicate t = null;
			int result;
			switch (state)
			{
				
				case START: 
				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)
					{
						if (state == FORWARD)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						else
							state = END;
						break;
					}
					
					if (vn.getCurrentDepth() == - 1)
					{
						if (state == START)
							state = END;
						else
						{
							//vn.pop();
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
					}
					else
					{
						vn.push2();
						vn.toElement(VTDNav.P); // must return true
						if (currentStep.eval(vn))
						{
							if (currentStep.NextStep != null)
							{
								state = FORWARD;
								currentStep = currentStep.NextStep;
							}
							else
							{
								state = TERMINAL;
								result = vn.getCurrentIndex();
								if (isUnique(result))
									return result;
							}
						}
						else
						{
							vn.pop2();
							currentStep.resetP(vn);
							if (state == START)
								state = END;
							else
							{
								state = BACKWARD;
								currentStep = currentStep.PrevStep;
							}
						}
					}
					
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case BACKWARD: 
				case TERMINAL: 
					if (currentStep.PrevStep == null)
					{
						vn.pop2();
						state = END;
						break;
					}
					else
					{
						vn.pop2();
						state = BACKWARD;
						currentStep = currentStep.PrevStep;
						break;
					}
					//goto default;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}
コード例 #12
0
		private int process_child(VTDNav vn)
		{
			int result;
			bool b = false, b1 = false;
			//int contextSize;
			Predicate t = null;
			
			switch (state)
			{
				
				case START: 
					if (currentStep.nt.testType != NodeTest.TEXT)
					{
						// first search for any predicate that 
						// requires contextSize
						// if so, compute its context size
						// if size > 0
						// set context
						// if size ==0 
						// immediately set the state to backward or end
						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;
						}
						
						b = vn.toElement(VTDNav.FIRST_CHILD);
						state = END;
						if (b == true)
						{
							do 
							{
								if (currentStep.eval(vn))
								{
									if (currentStep.NextStep != null)
									{
										//currentStep.position++;
										state = FORWARD;
										currentStep = currentStep.NextStep;
									}
									else
									{
										state = TERMINAL;
										result = vn.getCurrentIndex();
										if (isUnique(result))
										{
											return result;
										}
									}
									break;
								}
							}
							while (vn.toElement(VTDNav.NS));
							if (state == END)
								vn.toElement(VTDNav.PARENT);
						}
					}
					else
					{
                        if (vn.AtTerminal == true)
                        {
                            state = END;
                        }
                        else
                        {
                            // compute context size;
                            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;
                            }
                            // b1 false indicate context size is zero. no need to go any further...
                            if (b1)
                            {
                                state = END;
                                break;
                            }
                            // get textIter
                            TextIter ti = null;
                            if (currentStep.o != null)
                            {
                                ti = (TextIter)currentStep.o;
                            }
                            else
                            {
                                ti = new TextIter();
                                currentStep.o = ti;
                            }
                            ti.touch(vn);
                            state = END;
                            while ((result = ti.getNext()) != -1)
                            {
                                if (currentStep.evalPredicates(vn))
                                {
                                    break;
                                }
                            }
                            // old code
                            //result = vn.getText();
                            if (result != -1)
                            {
                                vn.AtTerminal=true;
                                //currentStep.resetP(vn);
                                vn.LN = result;
                                if (currentStep.NextStep != null)
                                {
                                    vn.LN = result;
                                    state = FORWARD;
                                    currentStep = currentStep.NextStep;
                                }
                                else
                                {
                                    //vn.pop();
                                    state = TERMINAL;
                                    if (isUnique(result))
                                    {
                                        vn.LN = result;
                                        return result;
                                    }
                                }
                            }
                            else
                            {
                                //currentStep.set_ft(true);
                                currentStep.resetP(vn);
                                vn.AtTerminal=false;
                            }
                        }		    
					}
					break;
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case FORWARD: 
					if (currentStep.nt.testType != NodeTest.TEXT)
					{
						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;
						if (vn.toElement(VTDNav.FC))
						{
							do 
							{
								if (currentStep.eval(vn))
								{
									if (currentStep.NextStep != null)
									{
										state = FORWARD;
										currentStep = currentStep.NextStep;
									}
									else
									{
										state = TERMINAL;
										result = vn.getCurrentIndex();
										if (isUnique(result))
											return result;
									}
									//UPGRADE_NOTE: Labeled break statement was changed to a goto statement. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1012'"
									goto forward_brk;
								}
							}
							while (vn.toElement(VTDNav.NS));
							vn.toElement(VTDNav.P);
							currentStep.resetP(vn);
							currentStep = currentStep.PrevStep;
						}
						else
						{
							//vn.toElement(VTDNav.P);
							currentStep = currentStep.PrevStep;
						}
						//UPGRADE_NOTE: Label 'forward_brk' was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1011'"

forward_brk: ;
						
					}
					else
					{
                        // predicate at an attribute is not evaled
                        if (vn.AtTerminal == true)
                        {
                            state = BACKWARD;
                            currentStep = currentStep.PrevStep;
                        }
                        else
                        {
                            // compute context size;
                            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;
                            }
                            // b1 false indicate context size is zero. no need to go any further...
                            if (b1)
                            {
                                state = BACKWARD;
                                break;
                            }
                            // get textIter
                            TextIter ti = null;
                            if (currentStep.o != null)
                            {
                                ti = (TextIter)currentStep.o;
                            }
                            else
                            {
                                ti = new TextIter();
                                currentStep.o = ti;
                            }
                            ti.touch(vn);
                            //result = ti.getNext();

                            while ((result = ti.getNext()) != -1)
                            {
                                if (currentStep.evalPredicates(vn))
                                {
                                    break;
                                }
                            }

                            if (result == -1)
                            {
                                //currentStep.set_ft(true);
                                //currentStep.resetP(vn);
                                vn.AtTerminal=false;
                                if (state == FORWARD)
                                {
                                    state = BACKWARD;
                                    currentStep = currentStep.PrevStep;
                                }
                            }
                            else
                            {
                                vn.AtTerminal=true;
                                if (currentStep.NextStep != null)
                                {
                                    vn.LN = result;
                                    state = FORWARD;
                                    currentStep = currentStep.NextStep;
                                }
                                else
                                {
                                    //vn.pop();
                                    state = TERMINAL;
                                    if (isUnique(result))
                                    {
                                        vn.LN = result;
                                        return result;
                                    }
                                }
                            }
                        }				
					}
					
					break;
				
				
				case BACKWARD: 
					if (currentStep.nt.testType != NodeTest.TEXT)
					{
						//currentStep = currentStep.getPrevStep();
						b = false;
						while (vn.toElement(VTDNav.NS))
						{
							if (currentStep.eval(vn))
							{
								b = true;
								break;
							}
						}
						if (b == true)
						{
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else if (currentStep.PrevStep == null)
						{
							currentStep.resetP(vn);
							vn.toElement(VTDNav.P);
							state = END;
						}
						else
						{
							currentStep.resetP(vn);
							state = BACKWARD;
							vn.toElement(VTDNav.P);
							currentStep = currentStep.PrevStep;
						}
					}
					else
					{
						vn.AtTerminal = false;
						if (currentStep.PrevStep == null)
							state = END;
						else
						{
							state = BACKWARD;
							//vn.setAtTerminal(false);
							currentStep = currentStep.PrevStep;
						}
					}
					break;
				
				
				case TERMINAL: 
					if (currentStep.nt.testType != NodeTest.TEXT)
					{
						while (vn.toElement(VTDNav.NS))
						{
							if (currentStep.eval(vn))
							{
								// state =  TERMINAL;
								result = vn.getCurrentIndex();
								if (isUnique(result))
									return result;
							}
						}
						currentStep.resetP(vn);
						if (currentStep.PrevStep == null)
						{
							state = END;
							vn.toElement(VTDNav.P);
						}
						else
						{
							vn.toElement(VTDNav.P);
							
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
					}
					else
					{
                        TextIter ti = (TextIter)currentStep.o;
                        while ((result = ti.getNext()) != -1)
                        {
                            if (currentStep.evalPredicates(vn))
                            {
                                if (isUnique(result))
                                    return result;
                            }
                        }
                        currentStep.resetP(vn);
                        vn.AtTerminal=false;
                        if (currentStep.PrevStep == null)
                            state = END;
                        else
                        {
                            state = BACKWARD;
                            currentStep = currentStep.PrevStep;
                        }
					}
					break;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}
コード例 #13
0
		private int process_self(VTDNav vn)
		{
			bool b1 = false;
			//int contextSize;
			Predicate t = null;
			int result;
			switch (state)
			{
				
				case START: 
				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)
					{
						if (state == FORWARD)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						else
							state = END;
						break;
					}
					if (currentStep.eval(vn))
					{
						if (currentStep.NextStep != null)
						{
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else
						{
							state = TERMINAL;
							if (vn.atTerminal == true)
								result = vn.LN;
							else
								result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					else
					{
						currentStep.resetP(vn);
						if (state == START)
							state = END;
						else
							state = BACKWARD;
					}
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case BACKWARD: 
				case TERMINAL: 
					if (currentStep.PrevStep != null)
					{
						state = BACKWARD;
						currentStep = currentStep.PrevStep;
					}
					else
					{
						state = END;
					}
					break;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}
コード例 #14
0
		private int process_ancestor_or_self(VTDNav vn)
		{
			bool b = false, b1 = false;
			//int contextSize;
			Predicate t = null;
			int result;
			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;
					vn.push2();
					
					if (currentStep.get_ft() == true)
					{
						currentStep.set_ft(false);
						if (currentStep.eval(vn))
						{
							if (currentStep.NextStep != null)
							{
								state = FORWARD;
								currentStep = currentStep.NextStep;
								break;
							}
							else
							{
								//vn.pop();
								state = TERMINAL;
								if (vn.atTerminal)
									result = vn.LN;
								else
									result = vn.getCurrentIndex();
								if (isUnique(result))
									return result;
							}
						}
					}
					
					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 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();
					if (currentStep.get_ft() == true)
					{
						currentStep.set_ft(false);
						
						if (currentStep.eval(vn))
						{
							if (currentStep.NextStep != null)
							{
								state = FORWARD;
								currentStep = currentStep.NextStep;
								break;
							}
							else
							{
								//vn.pop();
								state = TERMINAL;
								if (vn.atTerminal)
									result = vn.LN;
								else
									result = vn.getCurrentIndex();
								if (isUnique(result))
									return result;
							}
						}
					}
					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);
						currentStep.set_ft(true);
						vn.pop2();
						currentStep = currentStep.PrevStep;
					}
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				
				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();
						currentStep.resetP(vn);
						if (currentStep.PrevStep != null)
						{
							currentStep.set_ft(true);
							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();
					currentStep.resetP(vn);
					if (currentStep.PrevStep != null)
					{
						currentStep.set_ft(true);
						state = BACKWARD;
						currentStep = currentStep.PrevStep;
					}
					else
					{
						state = END;
					}
					break;
				
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}
コード例 #15
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
        private String getName(VTDNav vn)
        {
            int a;
            if (argCount1 == 0)
            {
                a = vn.getCurrentIndex();
                int type = vn.getTokenType(a);

                if ((type == VTDNav.TOKEN_STARTING_TAG
                        || type == VTDNav.TOKEN_ATTR_NAME
                        || type == VTDNav.TOKEN_PI_NAME))
                {
                    try
                    {
                        if (vn.nameIndex != a)
                        {
                            vn.name = vn.toRawString(a);
                            vn.nameIndex = a;
                        }
                        return vn.name;
                    }
                    catch (Exception e)
                    {
                        return "";
                    }
                }
                else
                    return "";
            }
            else if (argCount1 == 1)
            {
                a = evalFirstArgumentListNodeSet2(vn);
                try
                {
                    if (a == -1 || vn.ns == false)
                        return "";
                    else
                    {
                        int type = vn.getTokenType(a);
                        if (type == VTDNav.TOKEN_STARTING_TAG
                                || type == VTDNav.TOKEN_ATTR_NAME
                                || type == VTDNav.TOKEN_PI_NAME)
                            return vn.toRawString(a);
                        return "";
                    }
                }
                catch (Exception e)
                {
                }
                return "";
            }
            else
                throw new System.ArgumentException
                ("name()'s argument count is invalid");

        }
コード例 #16
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
        private String getName(VTDNav vn)
        {
            int a;
            if (argCount() == 0)
            {
                a = vn.getCurrentIndex();
                int type = vn.getTokenType(a);

                if ((type == VTDNav.TOKEN_STARTING_TAG
                        || type == VTDNav.TOKEN_ATTR_NAME))
                {
                    try
                    {
                        return vn.toString(a);
                    }
                    catch (Exception e)
                    {
                        return "";
                    }
                }
                else
                    return "";
            }
            else if (argCount() == 1)
            {
                a = -1;
                vn.push2();
                try
                {
                    a = argumentList.e.evalNodeSet(vn);
                    argumentList.e.reset(vn);
                    vn.pop2();
                }
                catch (Exception e)
                {
                    argumentList.e.reset(vn);
                    vn.pop2();
                }
                try
                {
                    if (a == -1 || vn.ns == false)
                        return "";
                    else
                    {
                        int type = vn.getTokenType(a);
                        if (type == VTDNav.TOKEN_STARTING_TAG
                                || type == VTDNav.TOKEN_ATTR_NAME)
                            return vn.toString(a);
                        return "";
                    }
                }
                catch (Exception e)
                {
                }
                return "";
            }
            else
                throw new System.ArgumentException
                ("name()'s argument count is invalid");

        }
コード例 #17
0
        protected internal int process_child2(VTDNav vn)
        {
            int result;
            bool b = false, b1 = false;
            Predicate t= null;

            switch(state){
            case START:
            // first search for any predicate that
            // requires contextSize
            // if so, compute its context size
            // if size > 0
            // set context
            // if size ==0
            // immediately set the state to backward or end
            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) {
                state = END;
                break;
            }

            b = vn.toNode(VTDNav.FIRST_CHILD);
            state = END;
            if (b) {
                do {
                    if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                            && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                        if (currentStep.nextS != null) {
                            // currentStep.position++;
                            state = FORWARD;
                            currentStep = currentStep.nextS;
                        } else {
                            state = TERMINAL;
                            result = vn.getCurrentIndex();
                            if (isUnique(result)) {
                                return result;
                            }
                        }
                        break;
                    }
                } while (vn.toNode(VTDNav.NS));
                if (state == END)
                    vn.toNode(VTDNav.PARENT);
            }
            break;

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

            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) {
                currentStep = currentStep.prevS;
                state = BACKWARD;
                break;
            }

            state = BACKWARD;
             if (vn.toNode(VTDNav.FC)) {
                do {
                    if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                            && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                        if (currentStep.nextS != null) {
                            state = FORWARD;
                            currentStep = currentStep.nextS;
                        } else {
                            state = TERMINAL;
                            result = vn.getCurrentIndex();
                            if (isUnique(result))
                                return result;
                        }
                        goto forward;
                    }
                } while (vn.toNode(VTDNav.NS));

                vn.toNode(VTDNav.P);
                if (currentStep.hasPredicate)
                    currentStep.resetP(vn);
                currentStep = currentStep.prevS;
            } else {
                // vn.toElement(VTDNav.P);
                currentStep = currentStep.prevS;
            }
             forward:
            break;

            case BACKWARD:
            if (currentStep.out_of_range){
                currentStep.out_of_range = false;
                transition_child(vn);
                break;
            }

            // currentStep = currentStep.prevS;
            //b = false;
            while (vn.toNode(VTDNav.NS)) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                        && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                    b = true;
                    break;
                }
            }
            if (b) {
                state = FORWARD;
                currentStep = currentStep.nextS;
            } else{
                        currentStep.out_of_range = false;
                        transition_child(vn);
            }

            break;

            case TERMINAL:
            if (currentStep.out_of_range){
                currentStep.out_of_range = false;
                transition_child(vn);
                break;
            }
            while (vn.toNode(VTDNav.NS)) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                        && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                    // state = TERMINAL;
                    result = vn.getCurrentIndex();
                    if (isUnique(result))
                        return result;
                }
            }
                    currentStep.out_of_range = false;
                    transition_child(vn);

            break;

            default:
            throw new XPathEvalException("unknown state");
            }
            return -2;
        }
コード例 #18
0
ファイル: FuncExpr.cs プロジェクト: IgorBabalich/vtd-xml
 private System.String normalizeSpace(VTDNav vn)
 {
     if (argCount() == 0)
     {
         String s = null;
         try
         {
             if (vn.atTerminal)
             {
                 int ttype = vn.getTokenType(vn.LN);
                 if (ttype == VTDNav.TOKEN_CDATA_VAL)
                     s = vn.toRawString(vn.LN);
                 else if (ttype == VTDNav.TOKEN_ATTR_NAME ||
                      ttype == VTDNav.TOKEN_ATTR_NS)
                 {
                     s = vn.toString(vn.LN + 1);
                 }
                 else
                     s = vn.toString(vn.LN);
             }else
                 s = vn.toString(vn.getCurrentIndex());
             return normalize(s);
         }
         catch (NavException e)
         {
             return ""; // this will almost never occur
         }
     }
     else if (argCount() == 1)
     {
         String s = argumentList.e.evalString(vn);
         return normalize(s);
     }
     throw new System.ArgumentException("normalize-space()'s argument count is invalid");
     //return null;
 }
コード例 #19
0
        protected int process_preceding_sibling2(VTDNav vn)
        {
            bool b = false, 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 ( state ==  START)
              		 state =  END;
              	else
              		 state =  BACKWARD;
              	vn.push2();
              	while (vn.toNode(VTDNav.PS)){
              		if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
              				&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))){
              			if (currentStep.nextS!=null){
              				 state =  FORWARD;
              				currentStep = currentStep.nextS;
              				break;
              			} else {
              				 state =  TERMINAL;
              				result = vn.getCurrentIndex();
                        if ( isUnique(result))
                            return result;
              			}
              		}
              	}
            if (state == END)
            {
                if (currentStep.hasPredicate)
                    currentStep.resetP(vn);
                vn.pop2();
            }
              	else if ( state ==  BACKWARD){
                if (currentStep.hasPredicate)
                    currentStep.resetP(vn);
                vn.pop2();
              		currentStep = currentStep.prevS;
              	}
              	break;

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

              case  BACKWARD:
                    if (currentStep.out_of_range)
                    {
                        currentStep.out_of_range = false;
                        transition_preceding_sibling(vn);
                        break;
                    }
                    while (vn.toNode(VTDNav.PS)){
              		if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
              				&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))){
              			if (currentStep.nextS!=null){
              				 state =  FORWARD;
              				currentStep = currentStep.nextS;
              				b = true;
              				break;
              			} else {
              				 state =  TERMINAL;
              				result = vn.getCurrentIndex();
                        if ( isUnique(result))
                            return result;
              			}
              		}
              	}
            if (b==false){
                   currentStep.out_of_range = false;
                   transition_preceding_sibling(vn);
            }
              	break;

              case  TERMINAL:
                    if (currentStep.out_of_range)
                    {
                        currentStep.out_of_range = false;
                        transition_preceding_sibling(vn);
                        break;
                    }
                    while (vn.toNode(VTDNav.PS)){
              		if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
              				&& ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))){
              			// state =  TERMINAL;
              			result = vn.getCurrentIndex();
                    if ( isUnique(result))
                        return result;
              		}
              	}
                    currentStep.out_of_range = false;
                    transition_preceding_sibling(vn);
                    break;

              default:
            throw new  XPathEvalException("unknown state");
            }
            return -2;
        }
コード例 #20
0
ファイル: LocationPathExpr.cs プロジェクト: DuLerWeil/vtd-xml
        protected int process_self2(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 ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                    && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                if (currentStep.nextS != null) {
                    state = FORWARD;
                    currentStep = currentStep.nextS;
                } else {
                    state = TERMINAL;
                    if (vn.atTerminal)
                        result = vn.LN;
                    else
                        result = vn.getCurrentIndex();
                    if (isUnique(result))
                        return result;
                }
            } else {
                if (currentStep.hasPredicate)
                    currentStep.resetP(vn);
                if (state == START)
                    state = END;
                else
                    state = BACKWARD;
            }
            break;

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

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

            default:
            throw new XPathEvalException("unknown state");
            }
            return -2;
        }