private void VerifyArgument(System.Xml.XPath.Function root) { if (root.ArgumentList != null) { for (int i = 0; i < root.ArgumentList.Count; i++) { Operand operand = root.ArgumentList[i] as Operand; if ((operand == null) || (operand.ReturnType != XPathResultType.String)) { throw new XPathException(Res.Xp_InvalidPatternString, _query); } } } }
private IQuery ProcessFunction( System.Xml.XPath.Function root, IQuery qyInput, ref bool cache, ref bool position) { _specialAxis = false; IQuery qy = null; switch (root.TypeOfFunction) { case FT.FuncLast: qy = new MethodOperand( null, root.TypeOfFunction); cache = true; return(qy); case FT.FuncPosition: qy = new MethodOperand( null, root.TypeOfFunction); position = true; return(qy); case FT.FuncCount: return(new MethodOperand( ProcessNode((AstNode)(root.ArgumentList[0]), null, Regular_D, Axis.AxisType.None, ref cache, ref position), FT.FuncCount)); case FT.FuncID: _specialAxis = true; return(new IDQuery( ProcessNode((AstNode)(root.ArgumentList[0]), null, Regular_D, Axis.AxisType.None, ref cache, ref position))); case FT.FuncLocalName: case FT.FuncNameSpaceUri: case FT.FuncName: if (root.ArgumentList != null && root.ArgumentList.Count > 0) { return(new MethodOperand(ProcessNode( (AstNode)(root.ArgumentList[0]), null, Regular_D, Axis.AxisType.None, ref cache, ref position), root.TypeOfFunction)); } else { return(new MethodOperand( null, root.TypeOfFunction)); } case FT.FuncString: case FT.FuncConcat: case FT.FuncStartsWith: case FT.FuncContains: case FT.FuncSubstringBefore: case FT.FuncSubstringAfter: case FT.FuncSubstring: case FT.FuncStringLength: case FT.FuncNormalize: case FT.FuncTranslate: ArrayList ArgList = null; if (root.ArgumentList != null) { int count = 0; ArgList = new ArrayList(); while (count < root.ArgumentList.Count) { ArgList.Add(ProcessNode( (AstNode)root.ArgumentList[count++], null, Regular_D, Axis.AxisType.None, ref cache, ref position)); } } return(new StringFunctions(ArgList, root.TypeOfFunction)); case FT.FuncNumber: case FT.FuncSum: case FT.FuncFloor: case FT.FuncCeiling: case FT.FuncRound: if (root.ArgumentList != null && root.ArgumentList.Count > 0) { return(new NumberFunctions( ProcessNode((AstNode)root.ArgumentList[0], null, Regular_D, Axis.AxisType.None, ref cache, ref position), root.TypeOfFunction)); } else { return(new NumberFunctions(null)); } case FT.FuncTrue: case FT.FuncFalse: return(new BooleanFunctions(null, root.TypeOfFunction)); case FT.FuncNot: case FT.FuncLang: case FT.FuncBoolean: return(new BooleanFunctions( ProcessNode((AstNode)root.ArgumentList[0], null, Regular_D, Axis.AxisType.None, ref cache, ref position), root.TypeOfFunction)); case FT.FuncUserDefined: _hasPrefix = true; ArgList = null; if (!allowCurrent && root.Name == "current" && root.Prefix == "") { throw new XPathException(Res.Xp_InvalidPatternString, _query); } if (!allowKey && root.Name == "key" && root.Prefix == "") { throw new XPathException(Res.Xp_InvalidKeyPattern, _query); } if (root.ArgumentList != null) { int count = 0; ArgList = new ArrayList(); while (count < root.ArgumentList.Count) { ArgList.Add(ProcessNode( (AstNode)root.ArgumentList[count++], null, Regular_D, Axis.AxisType.None, ref cache, ref position)); } } return(new XsltFunction(root.Prefix, root.Name, ArgList)); default: throw new XPathException(Res.Xp_NotSupported, _query); } //return null; }