internal override IQuery Clone() { MethodOperand method = (_Opnd != null) ? new MethodOperand(_Opnd.Clone(), _FType) : new MethodOperand(null, _FType) ; method.checkWhitespace = this.checkWhitespace; method.context = this.context; return(method); }
private Query ProcessFunction([NotNull] Function root, Query InputQuery) { Query query; switch (root.TypeOfFunction) { case FT.FuncPosition: query = new MethodOperand(null, root.TypeOfFunction); return(query); // we should be able to count how many attributes case FT.FuncCount: query = ProcessNode((AstNode)root.ArgumentList[0], null); if (query is AttributeQuery) { return(new MethodOperand(query, FT.FuncCount)); } //none attribute count function result in error. break; 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), root.TypeOfFunction)); } 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: if (root.ArgumentList is null) { return(new StringFunctions(new ArrayList(), root.TypeOfFunction)); } var count = 0; var arg_list = new ArrayList(); while (count < root.ArgumentList.Count) { arg_list.Add(ProcessNode((AstNode)root.ArgumentList[count++], null)); } return(new StringFunctions(arg_list, root.TypeOfFunction)); case FT.FuncNumber: //case FT.FuncSum: case FT.FuncFloor: case FT.FuncCeiling: case FT.FuncRound: if (root.ArgumentList != null) { return(new NumberFunctions(ProcessNode((AstNode)root.ArgumentList[0], null), root.TypeOfFunction)); } 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), root.TypeOfFunction)); // Unsupported functions //case FT.FuncID: // Last Function is not supported, because we don't know // how many we get in the list // <Root> <e a="1"/> <e a="2"/></Root> // /Root/e[last()=2] // we will not return the first one because // we don't if we have two e elements. //case FT.FuncLast: //qy = new MethodOperand(null, root.TypeOfFunction); //return qy; default: throw new XPathReaderException("The XPath query is not supported."); } return(null); }
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; }
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; }