/* * (non-Javadoc) * * @see com.ximpleware.xpath.Expr#evalBoolean(com.ximpleware.VTDNav) */ public override bool evalBoolean(VTDNav vn) { if (e.Boolean) { return(e.evalBoolean(vn)); } if (e.NodeSet) { bool a = false; vn.push2(); // record teh stack size int size = vn.contextStack2.size; try { a = (evalNodeSet(vn) != -1); } catch (System.Exception ee) { } //rewind stack vn.contextStack2.size = size; reset(vn); vn.pop2(); return(a); } if (e.Numerical) { double dval = e.evalNumber(vn); if (dval == 0.0 || System.Double.IsNaN(dval)) { return(false); } return(true); } String s = e.evalString(vn); if (s == null || s.Length == 0) { return(false); } return(true); }
public override String evalString(VTDNav vn) { if (cached) { return(es); } else { cached = true; es = e.evalString(vn); return(es); } }
/// <summary> /// evalXPathToString() evaluates the xpath expression to a String /// </summary> /// <returns>return the result as a string</returns> public String evalXPathToString() { return(xpe.evalString(vn)); }
/* * (non-Javadoc) * * @see com.ximpleware.xpath.Expr#evalString(com.ximpleware.VTDNav) */ public override System.String evalString(VTDNav vn) { if (e.NodeSet == false) { return(e.evalString(vn)); } else { String s = ""; int a = 0x7fffffff, k = -1; vn.push2(); int size = vn.contextStack2.size; try { while ((k = evalNodeSet(vn)) != -1) { //a = evalNodeSet(vn); if (k < a) { a = k; } } if (a == 0x7fffffff) { a = -1; } if (a != -1) { int t = vn.getTokenType(a); switch (t) { case VTDNav.TOKEN_STARTING_TAG: case VTDNav.TOKEN_DOCUMENT: s = vn.getXPathStringVal(); break; case VTDNav.TOKEN_ATTR_NAME: s = vn.toString(a + 1); break; case VTDNav.TOKEN_PI_NAME: //if (a + 1 < vn.vtdSize // || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL) s = vn.toString(a + 1); break; default: s = vn.toString(a); break; } /*if (t == VTDNav.TOKEN_ATTR_NAME) { * s = vn.toString(a + 1); * } else if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT) { || s = vn.getXPathStringVal(); ||} else if (t == VTDNav.TOKEN_PI_NAME) { || if (a + 1 < vn.vtdSize || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL) || s = vn.toString(a + 1); || // s = vn.toString(a+1); ||} else || s = vn.toString(a);*/ } } catch (Exception ee) { } vn.contextStack2.size = size; reset(vn); vn.pop2(); return(s); } }