XimpleWare's AutoPilot implementation encapsulating node iterator and XPath.
Esempio n. 1
1
 static void Main(string[] args)
 {
     VTDGen vg = new VTDGen();
     AutoPilot ap = new AutoPilot();
     Encoding eg = System.Text.Encoding.GetEncoding("utf-8");
     //ap.selectXPath("/*/*/*");
     AutoPilot ap2 = new AutoPilot();
     ap2.selectXPath("//@*");
     if (vg.parseFile("soap2.xml", true))
     {
         FileStream fs = new FileStream("output.xml", System.IO.FileMode.OpenOrCreate);
         VTDNav vn = vg.getNav();
         ap.bind(vn);
         ap2.bind(vn);
         //ap.evalXPath();
         int i;
         while ((i = ap2.evalXPath()) != -1)
         {
             //System.out.println("attr name ---> "+ i+ " "+vn.toString(i)+"  value ---> "+vn.toString(i+1));
             vn.overWrite(i + 1, eg.GetBytes(""));
         }
         byte[] ba = vn.getXML().getBytes();
         fs.Write(ba,0,ba.Length);
         fs.Close();
     }
 }
Esempio n. 2
0
 public static void Main(String[] args)
 {
     // instantiate VTDGen and XMLModifier
     VTDGen vg = new VTDGen();
     XMLModifier xm = new XMLModifier();
     AutoPilot ap = new AutoPilot();
     AutoPilot ap2 = new AutoPilot();
     ap.selectXPath("(/*/*/*)[position()>1 and position()<4]");
     ap2.selectXPath("/*/*/*");
     if (vg.parseFile("soap2.xml", true))
     {
         VTDNav vn = vg.getNav();
         xm.bind(vn);
         ap2.bind(vn);
         ap.bind(vn);
         ap2.evalXPath();
         ElementFragmentNs ef = vn.getElementFragmentNs();
         int i = -1;
         while ((i = ap.evalXPath()) != -1)
         {
             xm.insertAfterElement(ef);
         }
         xm.output("new_soap.xml");
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            int i;
            AutoPilot ap = new AutoPilot();
            ap.selectXPath("/CATALOG/CD[PRICE < 10]");
            BookMark bm = new BookMark();
            if (vg.parseFile("cd.xml", false))
            {
                VTDNav vn = vg.getNav();
                bm.bind(vn);
                ap.bind(vn);

                //XPath eval returns one node at a time
                while ((i = ap.evalXPath()) != -1)
                {
                    // push the current cursor position
                    //vn.push();
                    bm.recordCursorPosition(); // equivalent to vn.push();
                    // get to the first child
                    if (vn.toElement(VTDNav.FIRST_CHILD, "TITLE"))
                    {
                        int j = vn.getText();
                        if (j != -1)
                            Console.WriteLine(" text node ==>" + vn.toString(j));
                    }
                    // restore the cursor position
                    //vn.pop(); 
                    bm.setCursorPosition(); // equivalent to vn.pop();
                }
                ap.resetXPath();
            }
        }
Esempio n. 4
0
 static void Main(string[] args)
 {
     try
     {
         // open a file and read the content into a byte array
         VTDGen vg = new VTDGen();
         if (vg.parseFile("./servers.xml", true))
         {
             VTDNav vn = vg.getNav();
             AutoPilot ap = new AutoPilot(vn);
             ap.selectElementNS("http://purl.org/dc/elements/1.1/", "*"); // select name space here; * matches any local name
             int count = 0;
             while (ap.iterate())
             {
                 Console.Write("" + vn.getCurrentIndex() + "  ");
                 Console.WriteLine("Element name ==> " + vn.toString(vn.getCurrentIndex()));
                 int t = vn.getText(); // get the index of the text (char data or CDATA)
                 if (t != -1)
                     Console.WriteLine(" Text  ==> " + vn.toNormalizedString(t));
                 Console.WriteLine("\n ============================== ");
                 count++;
             }
             Console.WriteLine("Total # of element " + count);
         }
     }
     catch (NavException e)
     {
         Console.WriteLine(" Exception during navigation " + e);
     }
 }
Esempio n. 5
0
        //test XPath function: translate
        public static void test5() 
        {
            String s = "<test2>"
                + "<e1 attr='1'>A</e1>" 
                + "<e1 attr='2'>ABC</e1>"
                + "<f1 attr='3'>_aabb_</f1>" 
                + "<f1 attr='4' attr1='6'></f1>" 
                + "</test2>";

            VTDNav vn = parseString(s);
        
            AutoPilot ap = new AutoPilot(vn);
        ap.selectXPath("translate('12:30','30','45')");
        String value = ap.evalXPathToString();
        if (value.Equals("12:45"))
            println("test5 1 succeed");
        else
            println("test5 1 failed: " + value);
        
        ap.selectXPath("translate('12:30','0123','abc')");
        value = ap.evalXPathToString();
        if (value.Equals("bc:a"))
            println("test5 2 succeed");
        else
            println("test5 2 failed: " + value);
        
        ap.selectXPath("translate('','','abc')");
        value = ap.evalXPathToString();
        if (value.Equals(""))
            println("test5 3 succeed");
        else
            println("test5 3 failed: " + value);
    }
Esempio n. 6
0
        static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            int i;
            if (vg.parseFile("po.xml", true))
            {
                // instantiate a node recorder here
                NodeRecorder nr = new NodeRecorder();
                AutoPilot ap = new AutoPilot();
                VTDNav vn = vg.getNav();
                ap.bind(vn);
                // bind node recorder to vn
                nr.bind(vn);
                ap.selectXPath("(/*/*/*)[position()=1 or position()=10]");
                while ((i = ap.evalXPath()) != -1)
                {
                    nr.record(); // save the selected nodes into nr
                }
                ap.resetXPath(); // a good practice
                nr.resetPointer(); // get into nr's read mode
                // iterating over the nodes recorded by nr
                while ((i = nr.iterate()) != -1)
                {
                    Console.WriteLine("string ==>" + vn.toString(i));
                }

                nr.clear(); //remove all the nodes in nr, buffer is however reused
            }
        }
Esempio n. 7
0
 public static void Main(String[] args)
 {
     VTDGen vg = new VTDGen();
     AutoPilot ap0 = new AutoPilot();
     AutoPilot ap1 = new AutoPilot();
     AutoPilot ap2 = new AutoPilot();
     ap0.selectXPath("/root/a");
     ap1.selectXPath("/root/b");
     ap2.selectXPath("/root/c");
     Encoding eg = System.Text.Encoding.GetEncoding("utf-8");
     if (vg.parseFile("old.xml", false))
     {
         VTDNav vn = vg.getNav();
         ap0.bind(vn);
         ap1.bind(vn);
         ap2.bind(vn);
         FileStream fos = new FileStream("new.xml", System.IO.FileMode.OpenOrCreate);
         //fos.Write("<root>".getBytes());
         byte[] ba0,ba1, ba2, ba3, ba4;
         //ba0 = eg.GetBytes("
         ba1 = eg.GetBytes("<root>");
         ba2 = eg.GetBytes("</root>");
         ba3 = eg.GetBytes("\n");
         fos.Write(ba1, 0, ba1.Length);
         byte[] ba = vn.getXML().getBytes();
         while (ap0.evalXPath() != -1)
         {
             long l = vn.getElementFragment();
             int offset = (int)l;
             int len = (int)(l >> 32);
             fos.Write(ba3,0,ba3.Length);
             fos.Write(ba, offset, len);
         }
         ap0.resetXPath();
         while (ap1.evalXPath() != -1)
         {
             long l = vn.getElementFragment();
             int offset = (int)l;
             int len = (int)(l >> 32);
             fos.Write(ba3,0,ba3.Length);
             fos.Write(ba, offset, len);
         }
         ap1.resetXPath();
         while (ap2.evalXPath() != -1)
         {
             long l = vn.getElementFragment();
             int offset = (int)l;
             int len = (int)(l >> 32);
             fos.Write(ba3,0,ba3.Length);
             fos.Write(ba, offset, len);
         }
         ap2.resetXPath();
         fos.Write(ba3,0,ba3.Length);
         fos.Write(ba2,0,ba2.Length);
     }
 }
Esempio n. 8
0
        static void Main(string[] args)
        {
            try
            {
                //File f = new File("bioinfo.xml");
                // counting child elements of parlist
                int count = 0;
                // counting child elements of parlist named "par"
                int par_count = 0;
                VTDGen vg = new VTDGen();
                if (vg.parseFile("./bioinfo.xml", true))
                {
                    VTDNav vn = vg.getNav();
                    AutoPilot ap = new AutoPilot();
                    ap.bind(vn);
                    ap.selectXPath("/bix/package/command/parlist");
                    while (ap.evalXPath() != -1)
                        count++;

                    ap.selectXPath("/bix/package/command/parlist/par");
                    while (ap.evalXPath() != -1)
                        par_count++;

                    // print out the results
                    Console.WriteLine(" count ====> " + count);
                    Console.WriteLine(" par_count ==> " + par_count);

                    // verify results using iterators
                    int v = 0;
                    vn.toElement(VTDNav.ROOT);
                    ap = new AutoPilot(vn);
                    ap.selectElement("par");
                    while (ap.iterate())
                    {
                        if (vn.getCurrentDepth() == 4)
                        {
                            v++;
                        }
                    }
                    Console.WriteLine(" verify ==> " + v);
                }
            }
            catch (NavException e)
            {
                Console.WriteLine(" Exception during navigation " + e);
            }
            catch (XPathParseException e)
            {

            }
            catch (XPathEvalException e)
            {

            }
        }
Esempio n. 9
0
	static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            if (vg.parseFile("mix3.xml", true))
            {
                vg.writeSeparateIndex("mix32.vtd");
            }
            VTDNav vn = vg.loadSeparateIndex("mix3.xml", "mix3.vtd");
            AutoPilot ap = new AutoPilot(vn);
            ap.selectXPath("//*");
            int i;
            while((i=ap.evalXPath())!=-1){
                Console.WriteLine("element name: "+vn.toString(i));
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            try
            {
                // open file to output extracted fragments
                System.IO.FileInfo f1 = new System.IO.FileInfo("./out.txt");
                System.IO.FileStream fos = new System.IO.FileStream(f1.FullName, System.IO.FileMode.Create);

                // instantiate the parser
                VTDGen vg = new VTDGen();
                if (vg.parseFile("./soap2.xml", true))
                {
                    VTDNav vn = vg.getNav();
                    // get to the SOAP header
                    AutoPilot ap = new AutoPilot();
                    ap.bind(vn);
                    ap.declareXPathNameSpace("ns1", "http://www.w3.org/2003/05/soap-envelope");
                    // get to the SOAP header
                    ap.selectXPath("/ns1:Envelope/ns1:Header/*[@ns1:mustUnderstand]");
                    Console.WriteLine("expr string is " + ap.getExprString());
                    while (ap.evalXPath() != -1)
                    {
                        long l = vn.getElementFragment();
                        int len = (int)(l >> 32);
                        int offset = (int)l;
                        byte[] b = vn.getXML().getBytes();
                        fos.Write(b, offset, len); //write the fragment out into out.txt
                        System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("ASCII");
                        byte[] bytes = encoder.GetBytes("\n=========\n");

                        fos.Write(bytes, 0, bytes.Length);
                    }

                    fos.Close();
                }
            }
            catch (NavException e)
            {
                System.Console.Out.WriteLine(" Exception during navigation " + e);
            }
            catch (System.IO.IOException e)
            {
                System.Console.Out.WriteLine(" IO exception condition" + e);
            }

        }
Esempio n. 11
0
        public static void Main(String[] args)
        {

            String xml = "<aaaa> <bbbbb> <ccccc> </ccccc> <ccccc/> <ccccc></ccccc> </bbbbb> </aaaa>";
            Encoding eg = Encoding.GetEncoding("utf-8");
            VTDGen vg = new VTDGen();
            vg.setDoc(eg.GetBytes(xml));
            vg.parse(false);
            VTDNav vn = vg.getNav();
            AutoPilot ap = new AutoPilot(vn);
            ap.selectXPath("//*");
            XMLModifier xm = new XMLModifier(vn);
            while (ap.evalXPath() != -1)
            {
                xm.updateElementName("d:/lalalala");
            }
            xm.output("lala.xml");
        }
Esempio n. 12
0
 static void Main(string[] args)
 {
     try
     {
         VTDGen vg = new VTDGen();
         VTDNav vn = vg.loadIndex("po.vxl");
         AutoPilot ap = new AutoPilot(vn);
         ap.selectXPath("//items");
         int i;
         while ((i = ap.evalXPath()) != -1)
         {
         }
         ap.resetXPath();
     }
     catch (Exception e)
     {
     }
 }
Esempio n. 13
0
 	static void Main(string[] args)
        {
            VTDGen vg = new VTDGen();
            if (vg.parseFile("mix3.xml", true))
            {
                VTDNav vn = vg.getNav();
                // duplicated VTDNav instances share the same XML, LC buffers and VTD buffers.
                VTDNav vn2 = vn.duplicateNav();
                VTDNav vn3 = vn.duplicateNav();
                AutoPilot ap = new AutoPilot(vn);
                ap.selectXPath("//*");
                int i;
                while ((i = ap.evalXPath()) != -1)
                {
                    Console.WriteLine("element name: " + vn.toString(i));
                }
            }
        }
Esempio n. 14
0
 static void Main(string[] args)
 {
     try
     {
         // open a file and read the content into a byte array
         VTDGen vg = new VTDGen();
         if (vg.parseFile("./oldpo.xml", true))
         {
             VTDNav vn = vg.getNav();
             System.IO.FileInfo f1 = new System.IO.FileInfo("./newpo.txt");
             System.IO.FileStream fos = new System.IO.FileStream(f1.FullName, System.IO.FileMode.Create);
             
             AutoPilot ap = new AutoPilot(vn);
             XMLModifier xm = new XMLModifier(vn);
             ap.selectXPath("/purchaseOrder/items/item[@partNum='872-AA']");
             int i = -1;
             while ((i = ap.evalXPath()) != -1)
             {
                 xm.remove();
                 xm.insertBeforeElement("<something/>\n");
             }
             ap.selectXPath("/purchaseOrder/items/item/USPrice[.<40]/text()");
             while ((i = ap.evalXPath()) != -1)
             {
                 xm.updateToken(i, "200");
             }
             xm.output(fos);
             fos.Close();
         }
     }
     catch (NavException e)
     {
         Console.WriteLine(" Exception during navigation " + e);
     }
     catch (ModifyException e)
     {
         Console.WriteLine(" Modify exception occurred " + e);
     }
     catch (System.IO.IOException e)
     {
         System.Console.Out.WriteLine(" IO exception condition" + e);
     }
 }
Esempio n. 15
0
        static void Main(string[] args)
        {
            try
            {
                int t;
                System.IO.FileInfo f = new System.IO.FileInfo("./soap2.xml");
                System.IO.FileStream fis = 
                    new System.IO.FileStream(f.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                System.IO.FileInfo f1 = new System.IO.FileInfo("./out.xml");
                System.IO.FileStream fos = new System.IO.FileStream(f1.FullName, System.IO.FileMode.Create);
                byte[] b = new byte[(int)f.Length];
                fis.Read(b, 0, (int)f.Length);
                AutoPilot ap = new AutoPilot();
                ap.declareXPathNameSpace("ns1", "http://www.w3.org/2003/05/soap-envelope");
                // get to the SOAP header
                ap.selectXPath("/ns1:Envelope/ns1:Header/*[@ns1:mustUnderstand]");
                Console.WriteLine("expr string is " + ap.getExprString());
                // instantiate the parser
                VTDGen vg = new VTDGen();
                int j = 0;
                VTDNav vn = null;
                while (j < 10)
                {
                    vg.setDoc_BR(b); // use setDoc_BR (instead of setDoc) to turn on buffer reuse
                    vg.parse(true);  // set namespace awareness to true 
                    vn = vg.getNav();
                    ap.bind(vn); // bind calls resetXPath() so
                    
                    while ((t = ap.evalXPath()) != -1)
                    {

                        Console.WriteLine("j t--> " + j + " " + t);
                        long l = vn.getElementFragment();
                        int len = (int)(l >> 32);
                        int offset = (int)l;
                        fos.Write(b, offset, len); //write the fragment out into out.txt
                        System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("ASCII");
                        byte[] bytes = encoder.GetBytes("\n=========\n");

                        fos.Write(bytes, 0, bytes.Length);
                    }
                    ap.resetXPath();
                    j++;
                }
                j = 0;
                Console.WriteLine("j -->" + j);
                vg.setDoc_BR(b); // use setDoc_BR (instead of setDoc) to turn on buffer reuse
                vg.parse(true);  // set namespace awareness to true 
                vn = vg.getNav();
                ap.bind(vn); // bind calls resetXPath() so
                t =-1;
                while (j < 10)
                {
                    while ((t = ap.evalXPath()) != -1)
                    {
                        Console.WriteLine("j t --> " + j + " " + t);
                        long l = vn.getElementFragment();
                        int len = (int)(l >> 32);
                        int offset = (int)l;
                        fos.Write(b, offset, len); //write the fragment out into out.txt
                        System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("ASCII");
                        byte[] bytes = encoder.GetBytes("\n=========\n");

                        fos.Write(bytes, 0, bytes.Length);
                    }
                    ap.resetXPath();
                    j++;
                }

                fis.Close();
                fos.Close();
            }
            catch (ParseException e)
            {
            }
            catch (NavException e)
            {
            }
            catch (XPathParseException e)
            {
            }
            catch (XPathEvalException e)
            {
            }
            catch (System.IO.IOException e)
            {

            }
        }
Esempio n. 16
0
        protected internal int computeContextSize4DDFP2(Predicate p, VTDNav vn)
        {
            int i=0;
            AutoPilot ap = (AutoPilot)currentStep.o;

            if (ap==null)
            ap = new AutoPilot(vn);
            else
            ap.bind(vn);

            //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();
            vn.push2();
            while(ap.iterate2()){
            if (currentStep.eval2(vn,p)){
                i++;
            }
            }
            vn.pop2();
            currentStep.resetP(vn,p);
            currentStep.out_of_range=false;
            currentStep.o = ap;
            return i;
        }
Esempio n. 17
0
 protected internal int computeContextSize4DDFP(Predicate p, VTDNav vn)
 {
     String helper = null;
     int i=0;
     AutoPilot ap = (AutoPilot)currentStep.o;
     if (currentStep.nt.testType == NodeTest.NODE){
     helper = "*";
     }else if (currentStep.nt.testType == NodeTest.NAMETEST){
     helper = currentStep.nt.nodeName;
     }else
     throw new XPathEvalException("can't run descendant "
             + "following, or following-sibling axis over comment(), pi(), and text()");
     if (ap==null)
     ap = new AutoPilot(vn);
     else
     ap.bind(vn);
     if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF0 )
     if (currentStep.nt.testType == NodeTest.NODE || helper.Equals("*"))
         ap.Special=true;
     else
         ap.Special=true;
     //currentStep.o = ap = new AutoPilot(vn);
     if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF0)
     if (currentStep.nt.localName!=null)
         ap.selectElementNS(currentStep.nt.URL,currentStep.nt.localName);
     else
         ap.selectElement(helper);
     else if (currentStep.axis_type == AxisType.DESCENDANT0)
     if (currentStep.nt.localName!=null)
         ap.selectElementNS_D(currentStep.nt.URL,currentStep.nt.localName);
     else
         ap.selectElement_D(helper);
     else if (currentStep.axis_type == AxisType.PRECEDING0)
     if (currentStep.nt.localName!=null)
         ap.selectElementNS_P(currentStep.nt.URL,currentStep.nt.localName);
     else
         ap.selectElement_P(helper);
     else
     if (currentStep.nt.localName!=null)
         ap.selectElementNS_F(currentStep.nt.URL,currentStep.nt.localName);
     else
         ap.selectElement_F(helper);
     vn.push2();
     while(ap.iterate()){
     if (currentStep.evalPredicates(vn,p)){
         i++;
     }
     }
     vn.pop2();
     currentStep.resetP(vn,p);
     currentStep.out_of_range=false;
     currentStep.o = ap;
     return i;
 }
Esempio n. 18
0
        private int process_namespace(VTDNav vn)
        {
            AutoPilot ap = null;
            bool b1 = false;
            Predicate t = null;
            int temp;
            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.atTerminal)
                    {
                        if (state == START)
                            state = END;
                        else
                        {
                            state = BACKWARD;
                            currentStep = currentStep.prevS;
                        }
                    }
                    else
                    {

                        if (currentStep.ft)
                        {
                            if (currentStep.o == null)
                                currentStep.o = ap = new AutoPilot(vn);
                            else
                            {
                                ap = (AutoPilot)currentStep.o;
                                ap.bind(vn);
                                //ap.set_ft(true);
                            }
                            if (currentStep.nt.testType == NodeTest.NODE)
                                ap.selectNameSpace("*");
                            else
                                ap.selectNameSpace(currentStep.nt.nodeName);
                            currentStep.ft = false;
                        }
                        if (state == START)
                            state = END;
                        vn.push2();
                        //vn.setAtTerminal(true);
                        while ((temp = ap.iterateNameSpace()) != -1)
                        {
                            if ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))
                            {
                                break;
                            }
                        }
                        if (temp == -1)
                        {
                            vn.pop2();
                            currentStep.ft = true;
                            if (currentStep.hasPredicate)
                                currentStep.resetP(vn);
                            vn.atTerminal=(false);
                            if (state == FORWARD)
                            {
                                state = BACKWARD;
                                currentStep = currentStep.prevS;
                            }
                        }
                        else
                        {
                            vn.atTerminal=(true);
                            if (currentStep.nextS != null)
                            {
                                vn.LN = temp;
                                state = FORWARD;
                                currentStep = currentStep.nextS;
                            }
                            else
                            {
                                //vn.pop();
                                state = TERMINAL;
                                if (isUnique(temp))
                                {
                                    vn.LN = temp;
                                    return temp;
                                }
                            }

                        }
                    }
                    break;

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

                case BACKWARD:
                    ap = (AutoPilot)currentStep.o;
                    //vn.push();
                    while ((temp = ap.iterateNameSpace()) != -1)
                    {
                        if ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))
                        {
                            break;
                        }
                    }
                    if (temp == -1)
                    {
                        vn.pop2();
                        currentStep.ft = true;
                        if (currentStep.hasPredicate)
                            currentStep.resetP(vn);
                        vn.atTerminal=(false);
                        if (currentStep.prevS != null)
                        {
                            state = BACKWARD;
                            currentStep = currentStep.prevS;
                        }
                        else
                            state = END;
                    }
                    else
                    {
                        if (currentStep.nextS != null)
                        {
                            state = FORWARD;
                            currentStep = currentStep.nextS;
                        }
                        else
                        {
                            state = TERMINAL;
                            if (isUnique(temp))
                            {
                                vn.LN = temp;
                                return temp;
                            }
                        }
                    }
                    break;

                case TERMINAL:
                    ap = (AutoPilot)currentStep.o;
                    while ((temp = ap.iterateNameSpace()) != -1)
                    {
                        if (!currentStep.hasPredicate || currentStep.evalPredicates(vn))
                        {
                            break;
                        }
                    }
                    if (temp != -1)
                        if (isUnique(temp))
                        {
                            vn.LN = temp;
                            return temp;
                        }
                    vn.atTerminal=(false);
                    if (currentStep.hasPredicate)
                        currentStep.resetP(vn);
                    if (currentStep.prevS == null)
                    {
                        currentStep.ft = true;
                        vn.pop2();
                        state = END;
                    }
                    else
                    {
                        state = BACKWARD;
                        vn.pop2();
                        currentStep.ft = true;
                        currentStep = currentStep.prevS;
                    }

                    break;

                default:
                    throw new XPathEvalException("unknown state");
            }
            return -2;
        }
Esempio n. 19
0
        private int process_DDFP(VTDNav vn)
        {
            AutoPilot ap;
            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 == 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_SELF0)
                            if (currentStep.nt.testType == NodeTest.NODE || helper.Equals("*"))
                                ap.Special=(true);
                            else
                                ap.Special=(false);
                        //currentStep.o = ap = new AutoPilot(vn);
                        if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF0)
                            ap.selectElement(helper);
                        else if (currentStep.axis_type == AxisType.DESCENDANT0)
                            ap.selectElement_D(helper);
                        else if (currentStep.axis_type == AxisType.PRECEDING0)
                            ap.selectElement_P(helper);
                        else
                            ap.selectElement_F(helper);
                        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.iterate())
                    {
                        if (!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.getCurrentIndex2();
                            if (isUnique(result))
                                return result;
                        }
                    }
                    break;

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

                case BACKWARD:
                    //currentStep = currentStep.prevS;
                    if (currentStep.out_of_range)
                    {
                        currentStep.out_of_range = false;
                        transition_DDFP(vn);
                        break;
                    }
                    ap = (AutoPilot)currentStep.o;
                    //vn.push();
                    //b = false;
                    while (ap.iterate())
                    {
                        if (!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
                    {
                        currentStep.out_of_range = false;
                        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.iterate())
                    {
                        if (!currentStep.hasPredicate || currentStep.evalPredicates(vn))
                        {
                            b = true;
                            break;
                        }
                    }
                    if (b)
                    {
                        //if (currentStep.evalPredicates(vn)) {
                        result = vn.getCurrentIndex2();
                        if (isUnique(result))
                            return result;
                        //}
                    }
                    else
                    {
                        currentStep.out_of_range = false;
                        transition_DDFP(vn);
                    }
                    break;

                default:
                    throw new XPathEvalException("unknown state");
            }
            return -2;
        }
Esempio n. 20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="p"></param>
        /// <param name="vn"></param>
        /// <returns></returns>
        public int computeContextSize(Predicate p, VTDNav vn)
        {
            bool b = false;
            //Predicate tp = null;
            int i = 0;
            AutoPilot ap = (AutoPilot)currentStep.o;
            switch (currentStep.axis_type)
            {
                case AxisType.CHILD0:
                    return computeContextSize4Child(p, vn);
                case AxisType.CHILD:
                    return computeContextSize4Child2(p, vn);
                case AxisType.DESCENDANT_OR_SELF0:
                case AxisType.DESCENDANT0:
                case AxisType.PRECEDING0:
                case AxisType.FOLLOWING0:
                    return computeContextSize4DDFP(p, vn);
                case AxisType.DESCENDANT_OR_SELF:
                case AxisType.DESCENDANT:
                case AxisType.PRECEDING:
                case AxisType.FOLLOWING:
                    return computeContextSize4DDFP2(p, vn);
                case AxisType.PARENT:
                    return computeContextSize4Parent2(p, vn);
                case AxisType.ANCESTOR:
                    return computeContextSize4Ancestor2(p, vn);
                case AxisType.ANCESTOR_OR_SELF:
                    return computeContextSize4AncestorOrSelf2(p, vn);
                case AxisType.SELF:
                    return computeContextSize4Self2(p, vn);
                case AxisType.FOLLOWING_SIBLING:
                    return computeContextSize4FollowingSibling2(p, vn);
                case AxisType.FOLLOWING_SIBLING0:
                    return computeContextSize4FollowingSibling(p, vn);
                case AxisType.PRECEDING_SIBLING:
                    return computeContextSize4PrecedingSibling2(p, vn);
                case AxisType.PRECEDING_SIBLING0:
                    return computeContextSize4PrecedingSibling(p, vn);
                case AxisType.ATTRIBUTE:
                    if (ap == null)
                        ap = new AutoPilot(vn);
                    else
                        ap.bind(vn);
                    if (currentStep.nt.testType == NodeTest.NODE)
                        ap.selectAttr("*");
                    else if (currentStep.nt.localName != null)
                        ap.selectAttrNS(currentStep.nt.URL,
                            currentStep.nt.localName);
                    else
                        ap.selectAttr(currentStep.nt.nodeName);
                    i = 0;
                    while (ap.iterateAttr2() != -1)
                    {
                        if (currentStep.evalPredicates(vn, p))
                        {
                            i++;
                        }
                    }
                    currentStep.resetP(vn, p);
                    currentStep.o = ap;
                    return i;

                case AxisType.NAMESPACE:
                    if (ap == null)
                        ap = new AutoPilot(vn);
                    else
                        ap.bind(vn);
                    if (currentStep.nt.testType == NodeTest.NODE)
                        ap.selectNameSpace("*");
                    else
                        ap.selectNameSpace(currentStep.nt.nodeName);
                    i = 0;
                    vn.push2();
                    while (ap.iterateNameSpace() != -1)
                    {
                        if (currentStep.evalPredicates(vn, p))
                        {
                            i++;
                        }
                    }
                    vn.pop2();
                    currentStep.resetP(vn, p);
                    currentStep.o = ap;
                    return i;
                default:
                    throw new XPathEvalException("axis not supported");
            }
            //return 8;
            //return 8;
        }
Esempio n. 21
0
		public int computeContextSize(Predicate p, VTDNav vn){
	    
	    bool b = false;
	    Predicate tp = null;
	    int i = 0;
	    AutoPilot ap;
	    switch(currentStep.axis_type){
	    	case AxisType.CHILD:
	    	    if (currentStep.nt.testType != NodeTest.TEXT){
	    	    b = vn.toElement(VTDNav.FIRST_CHILD);
	    		if (b) {
	    		    do {
	    		        if (currentStep.eval(vn, p)) {
                        	i++;
	    		        }
	    		    } while (vn.toElement(VTDNav.NS));	    		    
	    		    vn.toElement(VTDNav.PARENT);
	    		    currentStep.resetP(vn,p);
	    		    return i;
	    		} else
	    		    return 0;
	    	    }else {	    
	    	        TextIter ti = new TextIter();
	    	        ti.touch(vn);
	    	        while((ti.getNext())!=-1){
	    	            if (currentStep.evalPredicates(vn,p)){
	    	                i++;
	    	            }
	    	        }
	    	        currentStep.resetP(vn,p);
	    	        return i;
	    	    }
	    		   
			case AxisType.DESCENDANT_OR_SELF:
			case AxisType.DESCENDANT:
			case AxisType.PRECEDING:								
			case AxisType.FOLLOWING:
			    
			    String helper = null;
				if (currentStep.nt.testType == NodeTest.NODE){
				    helper = "*";
				}else {
				    helper = currentStep.nt.nodeName;
				}
				ap = new AutoPilot(vn);
				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)
			        if (currentStep.nt.localName!=null)
			            ap.selectElementNS(currentStep.nt.URL,currentStep.nt.localName);
			        else 
			            ap.selectElement(helper);
				else if (currentStep.axis_type == AxisType.DESCENDANT)
				    if (currentStep.nt.localName!=null)
				        ap.selectElementNS_D(currentStep.nt.URL,currentStep.nt.localName);
				    else 
				        ap.selectElement_D(helper);
				else if (currentStep.axis_type == AxisType.PRECEDING)
				    if (currentStep.nt.localName!=null)
				        ap.selectElementNS_P(currentStep.nt.URL,currentStep.nt.localName);
				    else 
				        ap.selectElement_P(helper);
				else 
				    if (currentStep.nt.localName!=null)
				        ap.selectElementNS_F(currentStep.nt.URL,currentStep.nt.localName);
				    else 
				        ap.selectElement_F(helper);
			    vn.push2();
    			while(ap.iterate()){
    				if (currentStep.evalPredicates(vn,p)){
    					i++;
    				}
    			}
    			vn.pop2();
    			currentStep.resetP(vn,p);
    			return i;
			  
			case AxisType.PARENT:
			    vn.push2();
				i = 0;
				if (vn.toElement(VTDNav.PARENT)){
				    if (currentStep.eval(vn,p)){
				        i++;
				    }
				}			    
				vn.pop2();
				currentStep.resetP(vn,p);
				return i;
				
			case AxisType.ANCESTOR:
			    vn.push2();
				i = 0;
				while (vn.toElement(VTDNav.PARENT)) {
				    if (currentStep.eval(vn, p)) {
                    	i++;
    		        }
				}				
				vn.pop2();
				currentStep.resetP(vn,p);
				return i;
				
			case AxisType.ANCESTOR_OR_SELF:
			    vn.push2();
				i = 0;
				do {
				    if (currentStep.eval(vn, p)) {
                    	i++;
    		        }
				}while(vn.toElement(VTDNav.PARENT));
				vn.pop2();
				currentStep.resetP(vn,p);
				return i;
				
			case AxisType.SELF:
			    i = 0;
				if (vn.toElement(VTDNav.PARENT)){
				    if (currentStep.eval(vn,p)){
				        i++;
				    }
				}			    
				currentStep.resetP(vn,p);
				return i;
			    
			case AxisType.FOLLOWING_SIBLING:
			    vn.push2();
				while(vn.toElement(VTDNav.NEXT_SIBLING)){
				    if (currentStep.eval(vn,p)){
				        i++;
				    }
				}			    
			    vn.pop2();
				currentStep.resetP(vn,p);
				return i;
			    
			case AxisType.PRECEDING_SIBLING:
			    vn.push2();
				while(vn.toElement(VTDNav.PREV_SIBLING)){
				    if (currentStep.eval(vn,p)){
				        i++;
				    }
				}			    
				vn.pop2();
				currentStep.resetP(vn,p);
				return i;
				
			case AxisType.ATTRIBUTE:
			    ap = new AutoPilot(vn);
				if (currentStep.nt.localName!=null)
				    ap.selectAttrNS(currentStep.nt.URL,
			            currentStep.nt.localName);
				else 
				    ap.selectAttr(currentStep.nt.nodeName);
				i = 0;
				while(ap.iterateAttr()!=-1){
				    if (currentStep.evalPredicates(vn,p)){
				        i++;
				    }
				}
          		currentStep.resetP(vn,p);
				return i;
			    
	    	default:
	    	    throw new XPathEvalException("axis not supported");
	    }
	    //return 8;
	}
Esempio n. 22
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;
		}
Esempio n. 23
0
        static void Main(string[] args)
        {
            try
            {

                // counting child elements of parlist
                int count = 0;
                // counting child elements of parlist named "par"
                int par_count = 0;

                VTDGen vg = new VTDGen();
                if (vg.parseFile("./bioinfo.xml", true))
                {

                    VTDNav vn = vg.getNav();
                    if (vn.matchElement("bix"))
                    { // match blix
                        // to first child named "package"
                        if (vn.toElement(VTDNav.FC, "package"))
                        {
                            do
                            {
                                Console.WriteLine("package");
                                // to first child named "command"
                                if (vn.toElement(VTDNav.FC, "command"))
                                {
                                    do
                                    {
                                        Console.WriteLine("command");
                                        if (vn.toElement(VTDNav.FC, "parlist"))
                                        {
                                            do
                                            {
                                                Console.WriteLine("parlist");
                                                count++; //increment count
                                                if (vn.toElement(VTDNav.FC))
                                                {
                                                    do
                                                    {
                                                        if (vn.matchElement("par"))
                                                            par_count++;
                                                    }
                                                    while (vn.toElement(VTDNav.NS));
                                                    vn.toElement(VTDNav.P);
                                                }
                                            }
                                            while (vn.toElement(VTDNav.NS, "parlist"));
                                            vn.toElement(VTDNav.P);
                                        }
                                    }
                                    // to next silbing named "command"
                                    while (vn.toElement(VTDNav.NS, "command"));
                                    vn.toElement(VTDNav.P); // go up one level
                                }
                                else
                                    Console.WriteLine(" no child element named 'command' ");
                                // verify result

                            }
                            while (vn.toElement(VTDNav.NS, "package")); // to next sibling named "package"
                            vn.toElement(VTDNav.P); // go up one level	
                        }
                        else
                            Console.WriteLine(" no child element named 'package' ");
                    }
                    else
                        Console.WriteLine(" Root is not 'bix' ");
                    // print out the results
                    Console.WriteLine(" count ====> " + count);
                    Console.WriteLine(" par_count ==> " + par_count);

                    // verify results using iterators
                    int v = 0;
                    vn.toElement(VTDNav.ROOT);
                    AutoPilot ap = new AutoPilot(vn);
                    ap.selectElement("par");
                    while (ap.iterate())
                    {
                        if (vn.getCurrentDepth() == 4)
                        {
                            v++;
                        }
                    }
                    Console.WriteLine(" verify ==> " + v);
                }
            }
            catch (NavException e)
            {
                Console.WriteLine(" Exception during navigation " + e);
            }

        }
Esempio n. 24
0
		private int process_attribute(VTDNav vn)
		{
			AutoPilot ap = null;
			bool  b1 = false;
			//int contextSize;
			Predicate t = null;
			//int result;
			int temp;
			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.AtTerminal == true)
					{
						if (state == START)
							state = END;
						else
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
					}
					else
					{
						if (currentStep.get_ft() == true)
						{
							if (currentStep.o == null)
								currentStep.o = ap = new AutoPilot(vn);
							else
							{
								ap = (AutoPilot) currentStep.o;
								ap.bind(vn);
								//ap.set_ft(true);	
							}
							if (currentStep.nt.localName != null)
								ap.selectAttrNS(currentStep.nt.URL, currentStep.nt.localName);
							else
								ap.selectAttr(currentStep.nt.nodeName);
							currentStep.set_ft(false);
						}
						if (state == START)
							state = END;
						vn.AtTerminal = true;
						while ((temp = ap.iterateAttr()) != - 1)
						{
							if (currentStep.evalPredicates(vn))
							{
								break;
							}
						}
						if (temp == - 1)
						{
							currentStep.set_ft(true);
							currentStep.resetP(vn);
							vn.AtTerminal = false;
							if (state == FORWARD)
							{
								state = BACKWARD;
								currentStep = currentStep.PrevStep;
							}
						}
						else
						{
							
							if (currentStep.NextStep != null)
							{
								vn.LN = temp;
								state = FORWARD;
								currentStep = currentStep.NextStep;
							}
							else
							{
								//vn.pop();
								state = TERMINAL;
								if (isUnique(temp))
								{
									vn.LN = temp;
									return temp;
								}
							}
						}
					}
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case BACKWARD: 
					ap = (AutoPilot) currentStep.o;
					//vn.push();
					while ((temp = ap.iterateAttr()) != - 1)
					{
						if (currentStep.evalPredicates(vn))
						{
							break;
						}
					}
					if (temp == - 1)
					{
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						vn.AtTerminal = false;
						if (currentStep.PrevStep != null)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						else
							state = END;
					}
					else
					{
						if (currentStep.NextStep != null)
						{
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else
						{
							state = TERMINAL;
							if (isUnique(temp))
							{
								vn.LN = temp;
								return temp;
							}
						}
					}
					break;
				
				
				case TERMINAL: 
					ap = (AutoPilot) currentStep.o;
					while ((temp = ap.iterateAttr()) != - 1)
					{
						if (currentStep.evalPredicates(vn))
						{
							break;
						}
					}
					if (temp != - 1)
						if (isUnique(temp))
						{
							vn.LN = temp;
							return temp;
						}
					vn.AtTerminal = false;
					currentStep.resetP(vn);
					if (currentStep.PrevStep == null)
					{
						currentStep.set_ft(true);
						state = END;
					}
					else
					{
						state = BACKWARD;
						currentStep.set_ft(true);
						currentStep = currentStep.PrevStep;
					}
					
					break;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}