Пример #1
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();
            }
        }
Пример #2
0
        public bool compare(BookMark bm1)
        {
            /*for (int i = 0; i < vn1.nestingLevel; i++) {
             *  ba[i] = bm1.ba[i];
             * }
             * if (vn1.getCurrentDepth()>)*/
            if (vn1.shallowDepth)
            {
                for (int i = 0; i < vn1.nestingLevel + 7; i++)
                {
                    if (ba[i] != bm1.ba[i])
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                for (int i = 0; i < vn1.nestingLevel + 14; i++)
                {
                    if (ba[i] != bm1.ba[i])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #3
0
 public bool deepEquals(BookMark bm2)
 {
     if (bm2.vn1 == this.vn1)
     {
         if (bm2.ba[bm2.ba[0]] == this.ba[this.ba[0]])
         {
             if (vn1.shallowDepth)
             {
                 if (this.ba[this.vn1.nestingLevel + 7] < 0)
                 {
                     if (this.ba[this.vn1.nestingLevel + 7]
                         != bm2.ba[this.vn1.nestingLevel + 7])
                     {
                         return(false);
                     }
                 }
             }
             else
             {
                 if (this.ba[this.vn1.nestingLevel + 13] < 0)
                 {
                     if (this.ba[this.vn1.nestingLevel + 13]
                         != bm2.ba[this.vn1.nestingLevel + 13])
                     {
                         return(false);
                     }
                 }
             }
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
 public bool Equals(BookMark bm2)
 {
     if (this == bm2)
     {
         return(true);
     }
     return(deepEquals(bm2));
 }
Пример #5
0
 public bool deepEquals(BookMark bm2)
 {
     if (bm2.vn1 == this.vn1)
     {
         if (bm2.ba[bm2.ba[0]] == this.ba[this.ba[0]])
         {
             return(true);
         }
     }
     return(false);
 }
Пример #6
0
 /// <summary>
 /// 
 /// Return the byte offset and length of up to i sibling fragments. If 
 /// there is a i+1 sibling element, the cursor element would 
 /// move to it; otherwise, there is no cursor movement. If the cursor isn't 
 /// positioned at an element (due to XPath evaluation), then -1 will be 
 /// returned
 /// @param i number of silbing elements including the cursor element
 /// @return a long encoding byte offset (bit 31 to bit 0), length (bit 62 
 /// to bit 32) of those fragments 
 /// @throws NavException
 /// </summary>
 /// <param name="i"></param>
 /// <returns></returns>
 public long getSiblingElementFragments(int i)
 {
     if (i <= 0)
         throw new ArgumentException(" # of sibling can be less or equal to 0");
     // get starting char offset
     if (atTerminal == true)
         return -1L;
     // so is the char offset
     int so = getTokenOffset(getCurrentIndex()) - 1;
     // char offset to byte offset conversion
     if (encoding >= FORMAT_UTF_16BE)
         so = so << 1;
     BookMark bm = new BookMark(this);
     bm.recordCursorPosition();
     while (i > 1 && toElement(VTDNav.NEXT_SIBLING))
     {
         i--;
     }
     long l = getElementFragment();
     int len = (int)l + (int)(l >> 32) - so;
     if (i == 1 && toElement(VTDNav.NEXT_SIBLING))
     {
     }
     else
         bm.setCursorPosition();
     return (((long)len) << 32) | so;
 }
Пример #7
0
 public bool Equals(BookMark bm2)
 {
     if (this == bm2)
         return true;
     return deepEquals(bm2);
 }
Пример #8
0
 public bool deepEquals(BookMark bm2)
 {
     if (bm2.vn1 == this.vn1)
     {
         if (bm2.ba[bm2.ba[0]] == this.ba[this.ba[0]])
             return true;
     }
     return false;
 }
Пример #9
0
        public bool compare(BookMark bm1)
        {

            /*for (int i = 0; i < vn1.nestingLevel; i++) {
                ba[i] = bm1.ba[i];
            }    	
            if (vn1.getCurrentDepth()>)*/
            if (vn1.shallowDepth)
            {
                for (int i = 0; i < vn1.nestingLevel + 7; i++)
                {
                    if (ba[i] != bm1.ba[i])
                        return false;
                }
                return true;
            }
            else
            {
                for (int i = 0; i < vn1.nestingLevel + 14; i++)
                {
                    if (ba[i] != bm1.ba[i])
                        return false;
                }
            }

            return true;
        }
Пример #10
0
 public bool deepEquals(BookMark bm2)
 {
     if (bm2.vn1 == this.vn1)
     {
         if (bm2.ba[bm2.ba[0]] == this.ba[this.ba[0]])
         {
             if (vn1.shallowDepth)
             {
                 if (this.ba[this.vn1.nestingLevel + 7] < 0)
                 {
                     if (this.ba[this.vn1.nestingLevel + 7]
                             != bm2.ba[this.vn1.nestingLevel + 7])
                         return false;
                 }
             }
             else
             {
                 if (this.ba[this.vn1.nestingLevel + 13] < 0)
                 {
                     if (this.ba[this.vn1.nestingLevel + 13]
                             != bm2.ba[this.vn1.nestingLevel + 13])
                         return false;
                 }
             }
             return true;
         }
     }
     return false;
 }