public Send(SaxonItemFactory itemFactory) { this.itemFactory = itemFactory; this._FunctionName = new QName(XPathSmtpClient.Namespace, "send"); this._ArgumentTypes = new[] { new XdmSequenceType(XdmNodeKind.Element, ' ') }; this.resultType = new XdmSequenceType(XdmNodeKind.Element, ' '); }
public SendRequest(SaxonItemFactory itemFactory) { this.itemFactory = itemFactory; this._FunctionName = new QName(XPathHttpClient.Namespace, "send-request"); this._ArgumentTypes = new[] { new XdmSequenceType(XdmNodeKind.Element, '?'), new XdmSequenceType(XdmAtomicType.BuiltInAtomicType(QName.XS_STRING), '?'), new XdmSequenceType(XdmAnyItemType.Instance, '*') }; this.resultType = new XdmSequenceType(XdmAnyItemType.Instance, '+'); }
public ValidateWithSchematron(SaxonItemFactory itemFactory) { this.itemFactory = itemFactory; this._FunctionName = new QName(ValidationModule.Namespace, "validate-with-schematron"); this._ArgumentTypes = new[] { new XdmSequenceType(XdmAtomicType.BuiltInAtomicType(QName.XS_STRING), ' '), new XdmSequenceType(XdmAnyNodeType.Instance, ' '), new XdmSequenceType(XdmAtomicType.BuiltInAtomicType(QName.XS_STRING), '?'), new XdmSequenceType(XdmAnyNodeType.Instance, '*'), }; this.resultType = new XdmSequenceType(XdmNodeKind.Document, ' '); }
void RegisterExtensionFunctions(Processor processor, SaxonItemFactory itemFactory) { IEnumerable<IEnumerable<Type>> builtInFunctions = new IEnumerable<Type>[] { new modules.exslt.common.Index(), new modules.request.Index(), new modules.response.Index(), new modules.session.Index(), new modules.util.Index(), new modules.validation.Index(), new modules.smtpclient.Index(), new modules.expath.httpclient.Index(), }; IEnumerable<IEnumerable<Type>> importedFunctions = (from m in XPathModules.GetModuleAdaptersForProcessor(this.GetType()) let t = m.AdapterType let isCollection = typeof(IEnumerable<Type>).IsAssignableFrom(t) select (isCollection) ? (IEnumerable<Type>)Activator.CreateInstance(t) : new Type[] { t }); Type itemFactoryType = itemFactory.GetType(); foreach (var types in Enumerable.Concat(builtInFunctions, importedFunctions)) { var functions = from t in types let ctor = t.GetConstructors().First() let param = ctor.GetParameters() let args = param.Select(p => p.ParameterType.IsAssignableFrom(itemFactoryType) ? (object)itemFactory : null).ToArray() select (ExtensionFunctionDefinition)ctor.Invoke(args); if (functions.Select(f => f.FunctionName.Uri).Distinct().Count() > 1) throw new InvalidOperationException("Functions in module must belog to the same namespace."); foreach (var fn in functions) processor.RegisterExtensionFunction(fn); } }
public Serialize(SaxonItemFactory itemFactory) { this.itemFactory = itemFactory; }
public SaxonProcessor() { processor = new Processor(); _ItemFactory = new SaxonItemFactory(processor); RegisterExtensionFunctions(processor, _ItemFactory); }
void RegisterExtensionFunctions(Processor processor, SaxonItemFactory itemFactory) { ExtensionFunctionDefinition[] precompiledFunctions = extensions.exslt.common.Index.GetFunctions() .Concat(extensions.w3c.xpath.math.Index.GetFunctions()) .Concat(extensions.saxon.Index.GetFunctions(itemFactory)) .ToArray(); bool[] funcAvailable = FunctionsAvailable(precompiledFunctions.Select(d => d.FunctionName).ToArray(), processor, itemFactory); for (int i = 0; i < precompiledFunctions.Length; i++) { if (!funcAvailable[i]) { processor.RegisterExtensionFunction(precompiledFunctions[i]); } } Type itemFactoryType = itemFactory.GetType(); var fnGen = new IntegratedExtensionFunctionGenerator(); foreach (Type t in fnGen.Generate(XPathModules.Modules)) { ConstructorInfo ctor = t.GetConstructors().First(); object[] args = ctor.GetParameters().Select(p => p.ParameterType.IsAssignableFrom(typeof(SaxonProcessor)) ? (object)this : p.ParameterType.IsAssignableFrom(itemFactoryType) ? (object)itemFactory : null ).ToArray(); var def = (ExtensionFunctionDefinition)ctor.Invoke(args); processor.RegisterExtensionFunction(def); } }
public Parse(SaxonItemFactory itemFactory) { this.itemFactory = itemFactory; }
public static XdmNode ToXdmNode(this XPathNavigator value, SaxonItemFactory itemFactory) { if (value == null) throw new ArgumentNullException("navigator"); XdmNode node; if (!TryGetXdmNode(value, out node)) return MoveToElementOrReturnUnchanged(value, itemFactory.CreateXdmNode(value.ReadSubtree())); return node; }
public static XdmNode ToXdmNode(this IXPathNavigable value, SaxonItemFactory itemFactory) { if (value == null) throw new ArgumentNullException("value"); return ToXdmNode(value.CreateNavigator(), itemFactory); }
public static XdmValue ToXdmValue(this IEnumerable<XPathItem> value, SaxonItemFactory itemFactory) { if (value == null) return XdmEmptySequence.INSTANCE; return new XdmValue(value.Select(i => ToXdmValue(i, itemFactory))); }
public static XdmItem ToXdmItem(this XPathItem value, SaxonItemFactory itemFactory) { if (value == null) throw new ArgumentNullException("item"); return (value.IsNode) ? (XdmItem)ToXdmNode((XPathNavigator)value, itemFactory) : ToXdmAtomicValue(value, itemFactory); }
public static XdmItem ToXdmItem(this object value, SaxonItemFactory itemFactory) { if (value == null) throw new ArgumentNullException("value"); var xdmItem = value as XdmItem; if (xdmItem != null) return xdmItem; var item = value as XPathItem; if (item != null) return ToXdmItem(item, itemFactory); var nav = value as IXPathNavigable; if (nav != null) return ToXdmNode(nav, itemFactory); Type type = value.GetType(); TypeCode typeCode = Type.GetTypeCode(type); switch (typeCode) { case TypeCode.Boolean: case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: case TypeCode.Byte: case TypeCode.SByte: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: case TypeCode.Char: case TypeCode.String: case TypeCode.DateTime: case TypeCode.Decimal: case TypeCode.Double: case TypeCode.Single: return ToXdmAtomicValue(value, type, typeCode, itemFactory.processor); case TypeCode.DBNull: case TypeCode.Empty: throw new ArgumentException("value cannot be null or empty.", "value"); default: case TypeCode.Object: break; } if (typeof(Uri).IsAssignableFrom(type)) return ToXdmAtomicValue((Uri)value); if (typeof(XmlQualifiedName).IsAssignableFrom(type)) return ToXdmAtomicValue((XmlQualifiedName)value); if (typeof(QName).IsAssignableFrom(type)) return ToXdmAtomicValue((QName)value); return ToXdmNode(itemFactory.CreateDocument(value), itemFactory); }
public static XdmValue ToXdmValue(this IXPathNavigable value, SaxonItemFactory itemFactory) { if (value == null) return XdmEmptySequence.INSTANCE; return ToXdmItem(value, itemFactory); }
public static XdmValue ToXdmValue(this XPathItem value, SaxonItemFactory itemFactory) { return (value != null) ? (XdmValue)ToXdmItem(value, itemFactory) : XdmEmptySequence.INSTANCE; }
public static XdmValue ToXdmValue(this IEnumerable value, SaxonItemFactory itemFactory) { if (value == null) return XdmEmptySequence.INSTANCE; XdmValue result = XdmEmptySequence.INSTANCE; IEnumerator en = value.GetEnumerator(); while (en.MoveNext()) result = result.Append(ToXdmValue(en.Current, itemFactory)); return result; }
public FunctionCall(SaxonItemFactory itemFactory) { this.itemFactory = itemFactory; }
public static XdmItem ToXdmItem(this IXPathNavigable value, SaxonItemFactory itemFactory) { return ToXdmNode(value, itemFactory); }
public static XdmValue ToXdmValue(this object value, SaxonItemFactory itemFactory) { if (value == null) return XdmEmptySequence.INSTANCE; // Must check for string before checking for IEnumerable var str = value as string; if (str != null) return ToXdmAtomicValue(str); var xdmVal = value as XdmValue; if (xdmVal != null) return xdmVal; var item = value as XPathItem; if (item != null) return ToXdmItem(item, itemFactory); var nav = value as IXPathNavigable; if (nav != null) return ToXdmNode(nav, itemFactory); Type type = value.GetType(); if (type.IsArray || typeof(IEnumerable).IsAssignableFrom(type)) return ToXdmValue((IEnumerable)value, itemFactory); return ToXdmItem(value, itemFactory); }
public static XdmAtomicValue ToXdmAtomicValue(this XPathItem value, SaxonItemFactory itemFactory) { return ToXdmAtomicValue(value, itemFactory.processor); }
public static IEnumerable <ExtensionFunctionDefinition> GetFunctions(SaxonItemFactory itemFactory) { yield return(new Parse(itemFactory)); yield return(new Serialize(itemFactory)); }
public static XdmNode ToXdmNode(this XPathItem value, SaxonItemFactory itemFactory) { if (value == null) throw new ArgumentNullException("value"); if (value.IsNode) return ToXdmNode((XPathNavigator)value, itemFactory); return ToXdmNode(itemFactory.CreateDocument(value.TypedValue), itemFactory); }