private Boolean Lang(IQuery qy) { String str = _qy.getValue(qy).ToString(); XPathNavigator context = qy.peekElement().Clone(); return(Lang(str, context)); }
private String Normalize(IQuery qy) { String str1; if (_ArgList != null && _ArgList.Count > 0) { str1 = ((IQuery)_ArgList[0]).getValue(qy).ToString().Trim(); } else { str1 = qy.peekElement().Value.Trim(); } int count = 0; StringBuilder str2 = new StringBuilder();; bool FirstSpace = true; while (count < str1.Length) { if (!XmlCharType.IsWhiteSpace(str1[count])) { FirstSpace = true; str2.Append(str1[count]); } else if (FirstSpace) { FirstSpace = false; str2.Append(str1[count]); } count++; } return(str2.ToString()); }
internal override XPathNavigator peekElement() { if (_VarQuery != null) { return(_VarQuery.peekElement()); } throw new XPathException(Res.Xp_UndefinedXsltContext, Prefix, Name); }
private double Number(IQuery qyContext) { XPathNavigator value = null; if (_qy != null) { if (_qy.ReturnType() == XPathResultType.NodeSet) { _qy.setContext(qyContext.peekElement().Clone()); value = _qy.advance(); if (value != null) { return(Number(value.Value)); } else { return(double.NaN); } } else if (_qy.ReturnType() == XPathResultType.String) { return(Number(_qy.getValue(qyContext).ToString())); } else if (_qy.ReturnType() == XPathResultType.Boolean) { return(Number(Convert.ToBoolean(_qy.getValue(qyContext)))); } else { return(XmlConvert.ToXPathDouble(_qy.getValue(qyContext))); } } else if ((value = qyContext.peekElement()) != null) { return(XmlConvert.ToXPathDouble(value.Value)); } else { return(double.NaN); } }
private String toString(IQuery qyContext) { XPathNavigator value = null; if (_ArgList != null && _ArgList.Count > 0) { IQuery _qy = (IQuery)_ArgList[0]; if (_qy.ReturnType() == XPathResultType.NodeSet) { _qy.setContext(qyContext.peekElement().Clone()); value = _qy.advance(); if (value != null) { return(value.Value); } else { return(String.Empty); } } else if (_qy.ReturnType() == XPathResultType.String) { return(_qy.getValue(qyContext).ToString()); } else if (_qy.ReturnType() == XPathResultType.Boolean) { return(toString(Convert.ToBoolean(_qy.getValue(qyContext)))); } return(toString(XmlConvert.ToXPathDouble(_qy.getValue(qyContext)))); } else if ((value = qyContext.peekElement()) != null) { return(value.Value); } else { return(String.Empty); } }
private double Sum(IQuery qyContext) { double sum = 0; _qy.setContext(qyContext.peekElement().Clone()); XPathNavigator value = _qy.advance(); while (value != null) { sum += Number(value.Value); value = _qy.advance(); } return(sum); }
private Double StringLength(IQuery qy) { if (_ArgList != null && _ArgList.Count > 0) { return(((IQuery)_ArgList[0]).getValue(qy).ToString().Length); } else { XPathNavigator temp = qy.peekElement(); if (temp != null) { return(temp.Value.Length); } else { return(0); } } }
} // toBoolean internal Boolean toBoolean(IQuery qyContext) { if (_qy.ReturnType() == XPathResultType.NodeSet) { _qy.setContext(qyContext.peekElement().Clone()); XPathNavigator value = _qy.advance(); if (value != null) { return(true); } else { return(false); } } else if (_qy.ReturnType() == XPathResultType.String) { if (_qy.getValue(qyContext).ToString().Length > 0) { return(true); } else { return(false); } } else if (_qy.ReturnType() == XPathResultType.Boolean) { return(Convert.ToBoolean(_qy.getValue(qyContext))); } else if (_qy.ReturnType() == XPathResultType.Number) { return(toBoolean(XmlConvert.ToXPathDouble(_qy.getValue(qyContext)))); } return(false); } // toBoolean
internal override object getValue(IQuery qyContext) { XPathNavigator eNext; switch (_FType) { case FT.FuncPosition: if (qyContext != null) { return((double)qyContext.Position); } break; case FT.FuncLast: if (qyContext != null) { if (checkWhitespace) { return((double)((PositionQuery)qyContext).getNonWSCount(context)); } try { return((double)((PositionQuery)qyContext).getCount()); } catch (Exception) { if (last == -1) { last = 0; IQuery temp = qyContext.Clone(); while (temp.advance() != null) { last++; } } return(last); } } break; case FT.FuncCount: int i = 0; _Opnd.setContext(qyContext.peekElement()); if (checkWhitespace) { XPathNavigator nav; while ((nav = _Opnd.advance()) != null) { if (nav.NodeType != XPathNodeType.Whitespace || context.PreserveWhitespace(nav)) { i++; } } return((double)i); } while (_Opnd.advance() != null) { i++; } return((double)i); case FT.FuncNameSpaceUri: if (_Opnd != null) { _Opnd.setContext(qyContext.peekElement()); if ((eNext = _Opnd.advance()) != null) { return(eNext.NamespaceURI); } else { return(String.Empty); } } return(qyContext.peekElement().NamespaceURI); case FT.FuncLocalName: if (_Opnd != null) { _Opnd.setContext(qyContext.peekElement().Clone()); if ((eNext = _Opnd.advance()) != null) { return(eNext.LocalName); } else { return(String.Empty); } } return(qyContext.peekElement().LocalName); case FT.FuncName: if (_Opnd != null) { _Opnd.setContext(qyContext.peekElement().Clone()); if ((eNext = _Opnd.advance()) != null) { return(eNext.Name); } else { return(String.Empty); } } return(qyContext.peekElement().Name); } return(String.Empty); }
private Double StringLength(IQuery qy) { if (_ArgList != null && _ArgList.Count > 0) return((IQuery)_ArgList[0]).getValue(qy).ToString().Length; else { XPathNavigator temp = qy.peekElement(); if (temp != null) return temp.Value.Length; else return 0; } }
private String Normalize(IQuery qy) { String str1; if (_ArgList != null && _ArgList.Count > 0) str1 = ((IQuery)_ArgList[0]).getValue(qy).ToString().Trim(); else str1 = qy.peekElement().Value.Trim(); int count = 0; StringBuilder str2 = new StringBuilder();; bool FirstSpace = true; while (count < str1.Length) { if (!XmlCharType.IsWhiteSpace(str1[count])) { FirstSpace = true; str2.Append(str1[count]); } else if (FirstSpace) { FirstSpace = false; str2.Append(str1[count]); } count++; } return str2.ToString(); }
internal override XPathNavigator peekElement() { Debug.Assert(_ResultQuery != null && _ResultQuery.ReturnType() == XPathResultType.NodeSet); return(_ResultQuery.peekElement()); }
static bool compareQueryQuery1( IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) { XPathNavigator val1, val2; String str1,str2; opnd1.setContext(qyContext.peekElement().Clone()); opnd2.setContext(qyContext.peekElement().Clone()); while (true) { val1 = opnd1.advance(); if (val1 != null) str1 = val1.Value; else return false; val2 = opnd2.advance(); if (val2 != null) str2 = val2.Value; else return false; while (true) { switch (op) { case Operator.Op.EQ : if (str1 == str2) return true; break; case Operator.Op.NE : if (str1 != str2) return true; break; } val2 = opnd2.advance(); if (val2 != null) str2 = val2.Value; else { opnd2.reset(); break; } } } }
private Boolean Lang(IQuery qy) { String str = _qy.getValue(qy).ToString(); XPathNavigator context = qy.peekElement().Clone(); return Lang(str, context); }
static bool compareStringQuery2(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) { XPathNavigator val1; opnd1.setContext(qyContext.peekElement().Clone()); double n2, n1 = NumberFunctions.Number(XmlConvert.ToXPathString(opnd1.getValue(qyContext))); while (true) { val1 = opnd2.advance(); if (val1 != null) n2 = NumberFunctions.Number(val1.Value); else return false; switch (op) { case Operator.Op.LT :if (n1 < n2) return true ; break; case Operator.Op.GT :if (n1 > n2) return true ; break; case Operator.Op.LE :if (n1 <= n2) return true ; break; case Operator.Op.GE :if (n1 >= n2) return true ; break; case Operator.Op.EQ :if (n1 == n2) return true ; break; case Operator.Op.NE :if (n1 != n2) return true ; break; } } }
private double Number(IQuery qyContext) { XPathNavigator value = null; if (_qy != null) { if (_qy.ReturnType() == XPathResultType.NodeSet) { _qy.setContext(qyContext.peekElement().Clone()); value = _qy.advance(); if (value != null) return Number(value.Value); else return double.NaN; } else if (_qy.ReturnType() == XPathResultType.String) return Number(_qy.getValue(qyContext).ToString()); else if (_qy.ReturnType() == XPathResultType.Boolean) return Number(Convert.ToBoolean(_qy.getValue(qyContext))); else return XmlConvert.ToXPathDouble(_qy.getValue(qyContext)); } else if ((value = qyContext.peekElement()) != null) return XmlConvert.ToXPathDouble(value.Value); else return double.NaN; }
static bool compareStringQuery1(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) { XPathNavigator val1; opnd2.setContext(qyContext.peekElement().Clone()); String n2, n1 = XmlConvert.ToXPathString(opnd1.getValue(qyContext)); while (true) { val1 = opnd2.advance(); if (val1 != null) n2 = val1.Value; else return false; switch (op) { case Operator.Op.EQ : if (n1 == n2) return true ; break; case Operator.Op.NE : if (n1 != n2) return true ; break; } } }
static bool compareQueryString1(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) { XPathNavigator val1; opnd1.setContext(qyContext.peekElement().Clone()); String n2 = XmlConvert.ToXPathString(opnd2.getValue(qyContext)); while ((val1 = opnd1.advance()) != null) { if (op == Operator.Op.EQ) { if (val1.Value == n2) return true; } else if (val1.Value != n2) return true; } return false; }
static bool compareQueryQuery2( IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) { XPathNavigator val1, val2; double n1,n2; opnd1.setContext(qyContext.peekElement().Clone()); opnd2.setContext(qyContext.peekElement().Clone()); while (true) { val1 = opnd1.advance(); if (val1 != null) n1 = NumberFunctions.Number(val1.Value); else return false; val2 = opnd2.advance(); if (val2 != null) n2 = NumberFunctions.Number(val2.Value); else return false; while (true) { switch (op) { case Operator.Op.LT : if (n1 < n2) return true; break; case Operator.Op.GT : if (n1 > n2) return true; break; case Operator.Op.LE : if (n1 <= n2) return true; break; case Operator.Op.GE : if (n1 >= n2) return true; break; case Operator.Op.EQ : if (n1 == n2) return true; break; case Operator.Op.NE : if (n1 != n2) return true; break; } val2 = opnd2.advance(); if (val2 != null) n2 = NumberFunctions.Number(val2.Value); else { opnd2.reset(); break; } } } }
internal override Object getValue(IQuery qy) { InvokeFunction(qy.peekElement().Clone()); return _ResultQuery.getValue(qy); }
internal override object getValue( IQuery qyContext) { XPathNavigator eNext; switch (_FType) { case FT.FuncPosition: if (qyContext != null) { return (double)qyContext.Position; } break; case FT.FuncLast: if (qyContext != null) { if (checkWhitespace) { return(double)((PositionQuery)qyContext).getNonWSCount(context); } try { return(double)((PositionQuery)qyContext).getCount(); } catch(Exception) { if (last == -1) { last = 0; IQuery temp = qyContext.Clone(); while (temp.advance() != null) { last++; } } return last; } } break; case FT.FuncCount: int i = 0; _Opnd.setContext(qyContext.peekElement()); if (checkWhitespace) { XPathNavigator nav; while ((nav = _Opnd.advance())!= null) { if (nav.NodeType != XPathNodeType.Whitespace || context.PreserveWhitespace(nav)) { i++; } } return (double)i; } while (_Opnd.advance()!= null) { i++; } return (double)i; case FT.FuncNameSpaceUri: if (_Opnd != null) { _Opnd.setContext(qyContext.peekElement()); if (( eNext = _Opnd.advance()) != null) { return eNext.NamespaceURI; } else { return String.Empty; } } return qyContext.peekElement().NamespaceURI; case FT.FuncLocalName: if (_Opnd != null) { _Opnd.setContext(qyContext.peekElement().Clone()); if (( eNext = _Opnd.advance()) != null) { return eNext.LocalName; } else { return String.Empty; } } return qyContext.peekElement().LocalName; case FT.FuncName : if (_Opnd != null) { _Opnd.setContext(qyContext.peekElement().Clone()); if (( eNext = _Opnd.advance()) != null) { return eNext.Name; } else { return String.Empty; } } return qyContext.peekElement().Name; } return String.Empty; }
private String toString(IQuery qyContext) { XPathNavigator value = null; if (_ArgList != null && _ArgList.Count > 0) { IQuery _qy = (IQuery) _ArgList[0]; if (_qy.ReturnType() == XPathResultType.NodeSet) { _qy.setContext(qyContext.peekElement().Clone()); value = _qy.advance(); if (value != null) return value.Value; else return String.Empty; } else if (_qy.ReturnType() == XPathResultType.String) { return _qy.getValue(qyContext).ToString(); } else if (_qy.ReturnType() == XPathResultType.Boolean) { return toString(Convert.ToBoolean(_qy.getValue(qyContext))); } return toString(XmlConvert.ToXPathDouble(_qy.getValue(qyContext))); } else if ((value = qyContext.peekElement())!= null) return value.Value; else return String.Empty; }
internal override Object getValue(IQuery qy) { InvokeFunction(qy.peekElement().Clone()); return(_ResultQuery.getValue(qy)); }
static bool compareBoolQuery1(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) { XPathNavigator val1; opnd2.setContext(qyContext.peekElement().Clone()); Boolean n2 = false, n1 = Convert.ToBoolean(opnd1.getValue(qyContext)); val1 = opnd2.advance(); if (val1 != null) n2 = true; else { if (op == Operator.Op.EQ ) { return (n2 == n1); } return (n2 != n1); } switch (op) { case Operator.Op.EQ : return (n1 == n2) ; case Operator.Op.NE : return (n1 != n2) ; } return false; }
private double Sum(IQuery qyContext) { double sum = 0; _qy.setContext(qyContext.peekElement().Clone()); XPathNavigator value = _qy.advance(); while (value != null) { sum += Number(value.Value); value = _qy.advance(); } return sum; }
static bool compareBoolQuery2(IQuery opnd1, IQuery opnd2, IQuery qyContext, Operator.Op op) { XPathNavigator val1; opnd2.setContext(qyContext.peekElement().Clone()); double n2, n1 = NumberFunctions.Number(Convert.ToBoolean(opnd1.getValue(qyContext))); val1 = opnd2.advance(); if (val1 != null) n2 = 1.0; else { n2 = 0; switch (op) { case Operator.Op.LT : return (n1 < n2) ; case Operator.Op.GT : return (n1 > n2) ; case Operator.Op.LE : return (n1 <= n2) ; case Operator.Op.GE : return (n1 >= n2) ; } } switch (op) { case Operator.Op.LT : return (n1 < n2) ; case Operator.Op.GT : return (n1 > n2) ; case Operator.Op.LE : return (n1 <= n2) ; case Operator.Op.GE : return (n1 >= n2) ; } return false; }
} // toBoolean internal Boolean toBoolean(IQuery qyContext) { if (_qy.ReturnType() == XPathResultType.NodeSet) { _qy.setContext(qyContext.peekElement().Clone()); XPathNavigator value = _qy.advance(); if (value != null) return true; else return false; } else if (_qy.ReturnType() == XPathResultType.String) { if (_qy.getValue(qyContext).ToString().Length > 0) return true; else return false; } else if (_qy.ReturnType() == XPathResultType.Boolean) return Convert.ToBoolean(_qy.getValue(qyContext)); else if (_qy.ReturnType() == XPathResultType.Number) { return(toBoolean(XmlConvert.ToXPathDouble(_qy.getValue(qyContext)))); } return false; } // toBoolean