public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { CorrelationDataMessageProperty property; string str; SeekableMessageNavigator navigator = docContext as SeekableMessageNavigator; if ((navigator != null) && (CorrelationDataMessageProperty.TryGet(navigator.Message, out property) && property.TryGetValue((string)args[0], out str))) { return(str); } return(string.Empty); }
/// <summary> /// Perform custom processing for this XsltCustomFunction /// </summary> /// <param name="xsltContext">XsltContext this function is operating under</param> /// <param name="args">Parameters from function</param> /// <param name="docContext">XPathNavigator for which function is being applied to</param> /// <returns>Returns true if match is found, otherwise false</returns> public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { if (args.Length != 2) { throw new ApplicationException("Two arguments must be provided to compare function."); } string arg1 = args[0].ToString(); string arg2 = args[1].ToString(); return(String.Compare(arg1, arg2, true)); }
// Invoked from XsltKey (XPathFunction) public BaseIterator Evaluate(BaseIterator iter, Expression valueExpr) { XPathNodeIterator i = iter; if (iter.CurrentPosition == 0) { i = iter.Clone(); i.MoveNext(); } XPathNavigator nav = i.Current; object o = valueExpr.Evaluate(iter); XPathNodeIterator it = o as XPathNodeIterator; XsltContext ctx = iter.NamespaceManager as XsltContext; BaseIterator result = null; if (it != null) { while (it.MoveNext()) { ArrayList nodes = GetNodesByValue( nav, it.Current.Value, ctx); if (nodes == null) { continue; } ListIterator tmp = new ListIterator(nodes, ctx); if (result == null) { result = tmp; } else { result = new UnionIterator( iter, result, tmp); } } } else { ArrayList nodes = GetNodesByValue( nav, XPathFunctions.ToString(o), ctx); if (nodes != null) { result = new ListIterator(nodes, ctx); } } return(result != null ? result : new NullIterator(iter)); }
internal override void SetXsltContext(XsltContext context) { checkWhitespace = context.Whitespace; if (checkWhitespace) { this.context = context; } if (_Opnd != null) { _Opnd.SetXsltContext(context); } }
public override void SetXsltContext(XsltContext input) { base.SetXsltContext(input); cond.SetXsltContext(input); if (cond.StaticType != XPathResultType.Number && cond.StaticType != XPathResultType.Any && noPosition) { ReversePositionQuery query = qyInput as ReversePositionQuery; if (query != null) { qyInput = query.input; } } }
/// <summary> /// Rotina que executa a função em tempo de execução /// </summary> /// <param name="xsltContext">Contexto</param> /// <param name="args">Parâmetros</param> /// <param name="docContext"></param> /// <returns></returns> public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { if (FunctionName == "ValidarUsuario") { return(ValidarUsuario((XPathNodeIterator)args[0], args[1].ToString())); } else if (FunctionName == "ValidarSenha") { return(ValidarSenha((XPathNodeIterator)args[0], args[1].ToString())); } return(null); }
public override void SetXsltContext(XsltContext input) { base.SetXsltContext(input); this.cond.SetXsltContext(input); if (((this.cond.StaticType != XPathResultType.Number) && (this.cond.StaticType != XPathResultType.Any)) && this.noPosition) { ReversePositionQuery qyInput = base.qyInput as ReversePositionQuery; if (qyInput != null) { base.qyInput = qyInput.input; } } }
public override bool Matches(XPathNavigator node, XsltContext ctx) { XPathNavigator tmp = ((XsltCompiledContext)ctx).GetNavCache(this, node); for (int i = 0; i < ids.Length; i++) { if (tmp.MoveToId(ids [i]) && tmp.IsSamePosition(node)) { return(true); } } return(false); }
internal override void SetXsltContext(XsltContext input) { m_qyInput.SetXsltContext(input); _opnd.SetXsltContext(input); if (_opnd.ReturnType() != XPathResultType.Number) { ReversePositionQuery query = m_qyInput as ReversePositionQuery; if (query != null) { m_qyInput = query.m_qyInput; } } }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { Debug.Assert(args.Length <= this.Minargs, "We cheking this on resolve time"); for (int i = args.Length - 1; 0 <= i; i--) { args[i] = ConvertToXPathType(args[i], this.ArgTypes[i], this.typeCodes[i]); } if (this.permissions != null) { this.permissions.PermitOnly(); } return(method.Invoke(extension, args)); }
/// <summary> /// This method resolves the prefix of an argument. /// If a prefix is found, the corresponding namespace URI is looked up /// and substituted. /// </summary> /// <param name="args">An argument of the function to be resolved</param> /// <param name="xsltContext">The Xslt context for namespace resolving</param> private string ResolveNsPrefix(string args, XsltContext xsltContext) { if (args.Contains(":")) { var prefix = args.Substring(0, args.IndexOf(":", StringComparison.Ordinal)); string ns; if (!string.IsNullOrEmpty((ns = xsltContext.LookupNamespace(prefix)))) { args = args.Replace(prefix + ":", ns); } } return(args); }
public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { var context = xsltContext as XPathContext; var argTypes = args.Select(x => { switch (x.GetType().FullName) { case "MS.Internal.Xml.XPath.XPathSelectionIterator": return(typeof(string)); default: return(x.GetType()); } }); var customFunc = context.CustomFunctions .FirstOrDefault(x => x.Namespace == Namespace && x.Name == Name && Enumerable.SequenceEqual(argTypes, x.ArgTypes)); if (customFunc != null) { var methodParameterLength = customFunc.Method.GetParameters().Count(); var funcArgs = args.Select <object, object>((arg, i) => { switch (arg.GetType().FullName) { case "MS.Internal.Xml.XPath.XPathSelectionIterator": return(GetAttributeValue(args[i])); default: return(args[i].ToString()); } }).ToArray(); int argIndex = 0; var invokeParameters = new List <object>(); foreach (var realArgType in customFunc.RealArgTypes) { switch (realArgType) { case Type _ when realArgType == typeof(XPathNavigator): invokeParameters.Add(docContext); break; default: invokeParameters.Add(funcArgs[argIndex++]); break; } } return(customFunc.Method.Invoke(context, invokeParameters.ToArray())); } else { throw new KeyNotFoundException($"No function found. ({Namespace}.{Name})"); } }
public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { var input = GetXPathValue(args[0]); var pattern = GetXPathValue(args[1]); decimal number; if (decimal.TryParse(input, out number)) { return(number.ToString(pattern)); } return(null); }
/// <summary> /// Provides the method to invoke the function with the given arguments in the given context. /// </summary> /// <returns> /// An <see cref="T:System.Object"/> representing the return value of the function. /// </returns> /// <param name="xsltContext"> /// The XSLT context for the function call. /// </param> /// <param name="args"> /// The arguments of the function call. Each argument is an element in the array. /// </param> /// <param name="docContext"> /// The context node for the function call. /// </param> public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { //return args.FirstOrDefault(t => !string.IsNullOrEmpty(t as string)); string s1 = args[0] as string; string s2 = args[1] as string; int ix = s1.LastIndexOf(s2, StringComparison.Ordinal); if (ix > 0) { return(s1.Substring(0, ix)); } return(string.Empty); }
/// <summary> /// Perform custom processing for this XsltCustomFunction /// </summary> /// <param name="xsltContext">XsltContext this function is operating under</param> /// <param name="args">Parameters from function</param> /// <param name="docContext">XPathNavigator for which function is being applied to</param> /// <returns>Returns true if match is found, otherwise false</returns> public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { if (args.Length != 2) { throw new ApplicationException("Two arguments must be provided to compare function."); } string arg1 = args[0].ToString(); string arg2 = args[1].ToString(); var regex = new Regex(arg1); return(regex.IsMatch(arg2)); }
internal int getNonWSCount(XsltContext context) { if (NonWSCount == 0) { for (int i = 0; i < _Stk.Count; i++) { XPathNavigator nav = _Stk[i] as XPathNavigator; if (nav.NodeType != XPathNodeType.Whitespace || context.PreserveWhitespace(nav)) { NonWSCount++; } } } return(NonWSCount); }
internal PushXsltVariableOpcode(XsltContext context, IXsltContextVariable variable) : base(OpcodeID.PushXsltVariable) { this.xsltContext = context; this.variable = variable; this.type = XPathXsltFunctionExpr.ConvertTypeFromXslt(variable.VariableType); switch (this.type) { case ValueDataType.Boolean: case ValueDataType.Double: case ValueDataType.Sequence: case ValueDataType.String: return; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QueryCompileException(QueryCompileError.InvalidType, System.ServiceModel.SR.GetString("QueryVariableTypeNotSupported", new object[] { this.variable.VariableType.ToString() }))); }
/// <summary> /// This method resolves the prefix of an argument. /// If a prefix is found, the corresponding namespace URI is looked up /// and substituted. /// </summary> /// <param name="args">An argument of the function to be resolved</param> /// <param name="xsltContext">The Xslt context for namespace resolving</param> private string resolveNsPrefix(string args, XsltContext xsltContext) { string prefix; string ns; if (args.Contains(":")) { prefix = args.Substring(0, args.IndexOf(":")); if (!string.IsNullOrEmpty((ns = xsltContext.LookupNamespace(prefix)))) { args = args.Replace(prefix + ":", ns); } } return(args); }
public override void SetXsltContext(XsltContext input) { base.SetXsltContext(input); _cond.SetXsltContext(input); if (_cond.StaticType != XPathResultType.Number && _cond.StaticType != XPathResultType.Any && _noPosition) { // BugBug: We can do such trick at Evaluate time only. // But to do this FilterQuery should stop inherit from BaseAxisQuery ReversePositionQuery query = qyInput as ReversePositionQuery; if (query != null) { qyInput = query.input; } } }
public override void SetContext(IXmlNamespaceResolver nsResolver) { XsltContext context = nsResolver as XsltContext; if (context == null) { if (nsResolver == null) { nsResolver = new XmlNamespaceManager(new NameTable()); } context = new UndefinedXsltContext(nsResolver); } this.query.SetXsltContext(context); this.needContext = false; }
/// <summary> /// Perform custom processing for this XsltCustomFunction /// </summary> /// <param name="xsltContext">XsltContext this function is operating under</param> /// <param name="args">Parameters from function</param> /// <param name="docContext">XPathNavigator for which function is being applied to</param> /// <returns>Returns true if match is found, otherwise false</returns> public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { string Value = ((CustomContext)xsltContext).ArgumentList.GetParam("value", "").ToString(); string Arg1 = args[0].ToString(); if (String.Compare(Arg1, Value, true) == 0) { return(true); } else { return(false); } }
public override void SetXsltContext(XsltContext context) { if (context == null) { throw XPathException.Create("Xp_NoContext"); } if (base.xsltContext != context) { base.xsltContext = context; this.variable = base.xsltContext.ResolveVariable(base.prefix, base.name); if (this.variable == null) { throw XPathException.Create("Xp_UndefVar", base.QName); } } }
private ArrayList GetNodesByValue(XPathNavigator nav, string value, XsltContext ctx) { if (this.mappedDocuments == null) { this.mappedDocuments = new Hashtable(); } Hashtable hashtable = (Hashtable)this.mappedDocuments[nav.BaseURI]; if (hashtable == null) { hashtable = new Hashtable(); this.mappedDocuments.Add(nav.BaseURI, hashtable); this.CollectTable(nav, ctx, hashtable); } return(hashtable[value] as ArrayList); }
///<summary> ///Provides the method to invoke the function with the given arguments in the given context. ///</summary> /// ///<returns> ///An <see cref="T:System.Object"></see> representing the return value of the function. ///</returns> /// ///<param name="xsltContext">The XSLT context for the function call. </param> ///<param name="args">The arguments of the function call. Each argument is an element in the array. </param> ///<param name="docContext">The context node for the function call. </param> public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { foreach (MethodInfo mi in fMethodInfos) { ParameterInfo[] parameters = mi.GetParameters(); if (parameters.Length == args.Length) { // The arguments come in as a set of node iterators // Convert the arguments to a set of .Net Objects object[] functionArgs = ConvertXPathArgsToObjects(args, parameters); return(mi.Invoke(fDeclaringObject, functionArgs)); } } // TODO: should this return an exception? return(null); }
public override void SetContext(XmlNamespaceManager nsManager) { XsltContext xsltContext = nsManager as XsltContext; if (xsltContext == null) { if (nsManager == null) { nsManager = new XmlNamespaceManager(new NameTable()); } xsltContext = new UndefinedXsltContext(nsManager); } query.SetXsltContext(xsltContext); needContext = false; }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { SeekableMessageNavigator navigator = docContext as SeekableMessageNavigator; if (navigator == null) { return(ExtractFromNavigator(docContext.Clone())); } Uri to = navigator.Message.Headers.To; if (to == null) { return(string.Empty); } return(to.ToString()); }
public override object Evaluate(BaseIterator iter) { XPathResultType[] argTypes = this.GetArgTypes(iter); IXsltContextFunction xsltContextFunction = null; XsltContext xsltContext = iter.NamespaceManager as XsltContext; if (xsltContext != null) { if (this.resolvedName) { xsltContextFunction = xsltContext.ResolveFunction(this._name, argTypes); } else { xsltContextFunction = xsltContext.ResolveFunction(this._name.Namespace, this._name.Name, argTypes); } } if (xsltContextFunction == null) { throw new XPathException("function " + this._name.ToString() + " not found"); } object[] array = new object[this._args.Count]; if (xsltContextFunction.Maxargs != 0) { XPathResultType[] argTypes2 = xsltContextFunction.ArgTypes; for (int i = 0; i < this._args.Count; i++) { XPathResultType type; if (argTypes2 == null) { type = XPathResultType.Any; } else if (i < argTypes2.Length) { type = argTypes2[i]; } else { type = argTypes2[argTypes2.Length - 1]; } Expression expression = (Expression)this._args[i]; object obj = expression.EvaluateAs(iter, type); array[i] = obj; } } return(xsltContextFunction.Invoke(xsltContext, array, iter.Current)); }
private ArrayList GetNodesByValue(XPathNavigator nav, string value, XsltContext ctx) { if (mappedDocuments == null) { mappedDocuments = new Hashtable(); } Hashtable map = (Hashtable)mappedDocuments [nav.BaseURI]; if (map == null) { map = new Hashtable(); mappedDocuments.Add(nav.BaseURI, map); CollectTable(nav, ctx, map); } return(map [value] as ArrayList); }
internal virtual void SetContext(XsltContext context) { if (value != null) { value.SetContext(context); } foreach (var child in dependencies) { child.SetContext(context); } if (next != null) { next.SetContext(context); } }
public bool Matches(XPathNavigator nav, string value, XsltContext ctx) { ArrayList nodesByValue = this.GetNodesByValue(nav, value, ctx); if (nodesByValue == null) { return(false); } for (int i = 0; i < nodesByValue.Count; i++) { if (((XPathNavigator)nodesByValue[i]).IsSamePosition(nav)) { return(true); } } return(false); }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { DecimalFormat formatInfo = ((XsltCompileContext)xsltContext).ResolveFormatName(args.Length == 3 ? ToString(args[2]) : null); return DecimalFormatter.Format(ToNumber(args[0]), ToString(args[1]), formatInfo); }
object IXsltContextVariable.Evaluate(XsltContext xsltContext) { return ((XsltCompileContext)xsltContext).EvaluateVariable(this); }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { Debug.Assert(args.Length <= this.Minargs, "We cheking this on resolve time"); for (int i = args.Length - 1; 0 <= i; i--) { args[i] = ConvertToXPathType(args[i], this.ArgTypes[i], _types[i]); } return _method.Invoke(_extension, args); }
public abstract object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext);
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { return ((XsltCompileContext)xsltContext).Current(); }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { throw XsltException.Create(Res.Xslt_UnsuppFunction, "unparsed-entity-uri"); }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { Debug.Assert(args.Length <= this.Minargs, "We cheking this on resolve time"); for(int i = args.Length -1; 0 <= i; i --) { args[i] = ConvertToXPathType(args[i], this.ArgTypes[i], this.typeCodes[i]); } if (this.permissions != null) { this.permissions.PermitOnly(); } return method.Invoke(extension, args); }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { if(args.Length > 0) { XPathNodeIterator it = ToIterator(args[0]); if(it.MoveNext()) { return it.Current.UniqueId; } else { // if empty nodeset, return empty string, otherwise return generated id return string.Empty; } } else { return docContext.UniqueId; } }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { return new XPathSingletonIterator(ToNavigator(args[0])); }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { return ((XsltCompileContext)xsltContext).SystemProperty(ToString(args[0])); }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { XsltCompileContext xsltCompileContext = (XsltCompileContext) xsltContext; string local, prefix; PrefixQName.ParseQualifiedName(ToString(args[0]), out prefix, out local); string ns = xsltContext.LookupNamespace(prefix); XmlQualifiedName keyName = new XmlQualifiedName(local, ns); XPathNavigator root = docContext.Clone(); root.MoveToRoot(); ArrayList resultCollection = null; foreach (Key key in xsltCompileContext.processor.KeyList) { if (key.Name == keyName) { Hashtable keyTable = key.GetKeys(root); if (keyTable == null) { keyTable = xsltCompileContext.BuildKeyTable(key, root); key.AddKey(root, keyTable); } XPathNodeIterator it = args[1] as XPathNodeIterator; if (it != null) { it = it.Clone(); while (it.MoveNext()) { resultCollection = AddToList(resultCollection, (ArrayList) keyTable[it.Current.Value]); } } else { resultCollection = AddToList(resultCollection, (ArrayList) keyTable[ToString(args[1])]); } } } if (resultCollection == null) { return XPathEmptyIterator.Instance; } else if (resultCollection[0] is XPathNavigator) { return new XPathArrayIterator(resultCollection); } else { return new XPathMultyIterator(resultCollection); } }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { string baseUri = null; if (args.Length == 2) { XPathNodeIterator it = ToIterator(args[1]); if (it.MoveNext()){ baseUri = it.Current.BaseURI; } else { // http://www.w3.org/1999/11/REC-xslt-19991116-errata (E14): // It is an error if the second argument node-set is empty and the URI reference is relative; the XSLT processor may signal the error; // if it does not signal an error, it must recover by returning an empty node-set. baseUri = string.Empty; // call to Document will fail if args[0] is reletive. } } try { return ((XsltCompileContext)xsltContext).Document(args[0], baseUri); } catch (Exception e) { if (!XmlException.IsCatchableException(e)) { throw; } return XPathEmptyIterator.Instance; } }
public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext) { return ((XsltCompileContext)xsltContext).FunctionAvailable(ToString(args[0])); }