final protected void transition_child(VTDNav vn)throws NavException{ vn.toElement(VTDNav.P); if (currentStep.prevS != null){ currentStep = currentStep.prevS; state = BACKWARD; }else{ state = END; } } /**
final protected void transition_child(VTDNav vn)throws NavException{ vn.toElement(VTDNav.P); if (currentStep.prevS != null){ currentStep = currentStep.prevS; state = BACKWARD; }else{ state = END; } } /**
final protected int computeContextSize4Child(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; boolean 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); currentStep.out_of_range=false; return i; } else return 0; } final public int computeContextSize(Predicate p, VTDNav vn)
final protected int computeContextSize4Child(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; boolean 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); currentStep.out_of_range=false; return i; } else return 0; } final public int computeContextSize(Predicate p, VTDNav vn)
final protected void transition_child(VTDNav vn)throws NavException{ if (currentStep.hasPredicate) currentStep.resetP(vn); vn.toElement(VTDNav.P); if (currentStep.prevS != null){ currentStep = currentStep.prevS; state = BACKWARD; }else{ state = END; } } final protected void transition_ancestor_or_self(VTDNav vn) throws NavException{
final VTDGen vg = new VTDGen(); vg.parseFile("/path/to/file.xml", false); final VTDNav vn = vg.getNav(); final AutoPilot ap = new AutoPilot(vn); ap.selectXPath("/Example/Entry"); int count = 1; while (ap.evalXPath() != -1) { System.out.println("Inside Entry: " + count); //move to n1 child vn.toElement(VTDNav.FIRST_CHILD, "n1"); System.out.println("\tn1: " + vn.toNormalizedString(vn.getText())); //move to n2 child vn.toElement(VTDNav.NEXT_SIBLING, "n2"); System.out.println("\tn2: " + vn.toNormalizedString(vn.getText())); //move back to parent vn.toElement(VTDNav.PARENT); count++; }
import com.ximpleware.*; public class getContent { public static void main(String s[]) throws VTDException{ VTDGen vg = new VTDGen(); if (!vg.parseFile("C:\\Users\\HC\\Desktop\\dataset\\book.xml", false)) return; VTDNav vn = vg.getNav(); if (vn.toElement(VTDNav.FIRST_CHILD, "book")){ long l = vn.getContentFragment(); System.out.println( "book content ==> "); System.out.println(vn.toString((int)l, (int)(l<<32))); } } }
VTDGen vg= new VTDGen(); if (vg.parseFile("input.xml",false)){ VTDNav vn = vg.getNav(); vn.toElement(VTDNav.FIRST_CHILD); int i = vn.getText(); if (i!=-1) System.out.println(" text node is "+vn.toString(i)); }
final protected int computeContextSize4PrecedingSibling(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; vn.push2(); while(vn.toElement(VTDNav.PREV_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
final protected int computeContextSize4PrecedingSibling(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; vn.push2(); while(vn.toElement(VTDNav.PREV_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
final protected int computeContextSize4PrecedingSibling(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; vn.push2(); while(vn.toElement(VTDNav.PREV_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
final protected int computeContextSize4Ancestor(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); i = 0; while (vn.toElement(VTDNav.PARENT)) { if (currentStep.eval(vn, p)) { i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
final protected int computeContextSize4FollowingSibling(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; //AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); while(vn.toElement(VTDNav.NEXT_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
final protected int computeContextSize4AncestorOrSelf(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); i = 0; do { if (currentStep.eval(vn, p)) { i++; } }while(vn.toElement(VTDNav.PARENT)); vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
final protected int computeContextSize4FollowingSibling(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; //AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); while(vn.toElement(VTDNav.NEXT_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
final protected int computeContextSize4FollowingSibling(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; //AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); while(vn.toElement(VTDNav.NEXT_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
final protected int computeContextSize4Parent(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); i = 0; if (vn.toElement(VTDNav.PARENT)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
final protected int computeContextSize4Parent(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); i = 0; if (vn.toElement(VTDNav.PARENT)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
import com.ximpleware.*; public class removeNode { public static void main(String s[]) throws Exception{ VTDGen vg = new VTDGen(); boolean b = vg.parseFile("input.xml", false); if (b==false) return; VTDNav vn = vg.getNav(); XMLModifier xm = new XMLModifier(vn); vn.toElement(VTDNav.FC); // get to A node long l = vn.getContentFragment(); xm.remove(l); xm.output("output.xml"); } }
final protected int computeContextSize4Ancestor(Predicate p, VTDNav vn) throws NavException,XPathEvalException{ int i=0; AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); i = 0; while (vn.toElement(VTDNav.PARENT)) { if (currentStep.eval(vn, p)) { i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }