public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string validatorUri = arguments[0].AsAtomicValues().Single().ToString(); XPathNavigator source = arguments[1].AsNodes().Single().ToXPathNavigator(); XPathNavigator report; if (arguments.Length == 2) { report = ValidationModule.ValidateWithSchematron(validatorUri, source); } else { string phase = arguments[2].AsAtomicValues().Select(x => x.ToString()).SingleOrDefault(); if (arguments.Length == 3) { report = ValidationModule.ValidateWithSchematron(validatorUri, source, phase); } else { IEnumerable<XPathNavigator> parameters = arguments[3].AsNodes() .Select(n => n.ToXPathNavigator()); report = ValidationModule.ValidateWithSchematron(validatorUri, source, phase, parameters); } } XdmNode result = report.ToXdmNode(this.itemFactory); return result.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XPathHttpClient client = new XPathHttpClient { ItemFactory = this.itemFactory }; XPathItem[] result; XPathNavigator request = arguments[0].AsNodes().Select(x => x.ToXPathNavigator()).SingleOrDefault(); if (arguments.Length == 1) { result = client.SendRequest(request); } else { string href = arguments[1].AsAtomicValues().Select(x => x.ToString()).SingleOrDefault(); if (arguments.Length == 2) { result = client.SendRequest(request, href); } else { IEnumerable<XPathItem> bodies = arguments[2].AsItems() .ToXPathItems(); result = client.SendRequest(request, href, bodies); } } return result.ToXdmValue(itemFactory).GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string value = arguments[0].AsAtomicValues().Single().ToString(); ResponseModule.SetContentType(value); return XdmEmptySequence.INSTANCE.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string refUrl = RequestModule.ReferrerUrl(); XdmValue result = refUrl.ToXdmValue(); return result.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { long code = (long)arguments[0].AsAtomicValues().Single().Value; string description = arguments[1].AsAtomicValues().Single().ToString(); ResponseModule.SetStatus(code, description); return XdmEmptySequence.INSTANCE.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string name = arguments[0].AsAtomicValues().Single().ToString(); string[] values = RequestModule.QueryString(name); XdmValue result = values.ToXdmValue(); return result.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string relativePath = arguments[0].AsAtomicValues().Single().ToString(); string absolutePath = UtilModule.AbsolutePath(relativePath); XdmValue result = absolutePath.ToXdmValue(); return result.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XdmAtomicValue p1 = arguments[0].AsAtomicValues().SingleOrDefault(); if (p1 == null) { return EmptyEnumerator.INSTANCE; } return Math.Acos((double)p1.Value).ToXdmAtomicValue().GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { IXdmEnumerator result; if (arguments != null || arguments.Length > 0) result = arguments[0]; else result = XdmEmptySequence.INSTANCE.GetXdmEnumerator(); return result; }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XPathSmtpClient client = new XPathSmtpClient { ItemFactory = this.itemFactory }; XPathNavigator message = arguments[0].AsNodes().Select(x => x.ToXPathNavigator()).Single(); XPathNavigator result = client.Send(message); return result.ToXdmValue(this.itemFactory).GetXdmEnumerator(); }
public override JSequence call(JXPathContext context, JSequence [] argument) { SequenceEnumerator <XdmItem>[] na = new SequenceEnumerator <XdmItem> [argument.Length]; for (int i = 0; i < na.Length; i++) { na[i] = new SequenceEnumerator <XdmItem>((JXdmSequenceIterator)XdmValue.FromGroundedValueToJXdmValue(argument[i].materialize()).iterator()); } DynamicContext dc = new DynamicContext(context); IEnumerator <XdmItem> result = functionCall.Call(na, dc); return(new net.sf.saxon.om.LazySequence(new net.sf.saxon.om.IteratorWrapper(new net.sf.saxon.dotnet.DotNetIterator(result, new Mapper())))); }
public override JSequence call(JXPathContext context, JSequence [] argument) { SequenceEnumerator[] na = new SequenceEnumerator[argument.Length]; for (int i = 0; i < na.Length; i++) { na[i] = new SequenceEnumerator(argument[i].iterate()); } DynamicContext dc = new DynamicContext(context); IXdmEnumerator result = functionCall.Call(na, dc); return(new net.sf.saxon.om.LazySequence(new DotNetSequenceIterator(result))); }
public override JSequenceIterator call(JSequenceIterator[] arguments, JXPathContext context) { SequenceEnumerator[] na = new SequenceEnumerator[arguments.Length]; for (int i = 0; i < na.Length; i++) { na[i] = new SequenceEnumerator(arguments[i]); } DynamicContext dc = new DynamicContext(context); IXdmEnumerator result = functionCall.Call(na, dc); return(new DotNetSequenceIterator(result)); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string name = arguments[0].AsAtomicValues().Single().ToString(); XdmItem value = arguments[1].AsItems().Single(); object sessionVal = value.IsAtomic() ? (object)value.ToString() : (object)((XdmNode)value).ToXPathNavigator(); SessionModule.Set(name, sessionVal); return XdmEmptySequence.INSTANCE.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { IXdmEnumerator first = arguments[0]; IXdmEnumerator second = arguments[1]; first.MoveNext(); second.MoveNext(); Uri firstUri = (Uri)((XdmAtomicValue)first.Current).Value; Uri secondUri = (Uri)((XdmAtomicValue)second.Current).Value; return (IXdmEnumerator)new XdmAtomicValue( firstUri.MakeRelativeUri(secondUri) ).GetEnumerator(); }
/// <summary> /// Get the resources in the collection. This supports the fn:collection() function. It is not /// required that all collections expose a set of resources in this way, or that the resources /// returned bear any particular relationship to the URIs returned by the getResourceURIs() method /// for the same collection URI. /// </summary> /// <param name="context">context the XPath evaluation context</param> /// <returns>a list over the resources in the collection. This returns objects of implementations of the interface <code>IResource</code></returns> public List <IResource> GetResources(DynamicContext context) { List <IResource> list = new List <IResource>(); if (resourceCollection != null) { var jIter = resourceCollection.getResources(context.context); while (jIter.hasNext()) { JResource jresource = (JResource)jIter.next(); list.Add(new Resource(jresource)); } } return(list); }
/// <summary> /// Get the URIs of the resources in the collection. It is /// not required that all collections expose a list of URIs in this way, or that the URIs bear any particular /// relationship to the resources returned by the getResources() method for the same collection URI. /// </summary> /// <param name="context">the XPath evaluation context</param> /// <returns>List over the URIs of the resources in the collection. The URIs are represented as strings. /// They should preferably be absolute URIs.</returns> public List <string> GetResourceURIs(DynamicContext context) { List <string> list = new List <string>(); if (resourceCollection != null) { var jIter = resourceCollection.getResourceURIs(context.context); while (jIter.hasNext()) { string uri = (string)jIter.next(); list.Add(uri); } } return(list); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string components = arguments[0].AsAtomicValues().Single().ToString(); string result; if (arguments.Length == 1) { result = RequestModule.ReferrerUrlComponents(components); } else { string format = arguments[1].AsAtomicValues().Single().ToString(); result = RequestModule.ReferrerUrlComponents(components, format); } return result.ToXdmValue().GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XdmItem[] items = arguments[0].AsItems().ToArray(); XdmItem item; if (items.Length != 1 || (item = items[0]) is XdmNode) { return Result("node-set"); } if (item.IsAtomic()) { XdmAtomicValue atomicVal = (XdmAtomicValue)item; object typedVal = atomicVal.Value; if (typedVal is string) { return Result("string"); } switch (Type.GetTypeCode(typedVal.GetType())) { case TypeCode.Boolean: return Result("boolean"); case TypeCode.Byte: case TypeCode.Decimal: case TypeCode.Double: case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: case TypeCode.SByte: case TypeCode.Single: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: return Result("number"); } } return Result("external"); }
/// <summary> /// Create a JarCollection /// </summary> /// <param name="context">The XPath dynamic context</param> /// <param name="collectionURI">the collection URI used to identify this collection /// (typically but not necessarily the location of the JAR file)</param> /// <param name="parameters">URI query parameters appearing on the collection URI</param> public JarCollection(DynamicContext context, String collectionURI, URIQueryParameters parameters) { resourceCollection = new net.sf.saxon.resource.JarCollection(context.context, collectionURI, parameters.Implementation()); }
/// <summary> /// Method called at run time to evaluate the function. /// </summary> /// <param name="arguments">The values of the arguments to the function, supplied as iterators over XPath /// sequence values.</param> /// <param name="context">The dynamic context for evaluation of the function. This provides access /// to the context item, position, and size, and if required to internal data maintained by the Saxon /// engine.</param> /// <returns>An iterator over a sequence, representing the result of the extension function. /// Note that Saxon does not guarantee to read this sequence to completion, so calls on the iterator /// must have no side-effects. In rare circumstances (for example, when <code>last()</code> is /// used) Saxon may clone the returned iterator by calling its <c>GetAnother()</c> method, /// allowing the function results to be read more than once.</returns> public abstract IEnumerator <XdmItem> Call(IEnumerator <XdmItem>[] arguments, DynamicContext context);
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { arguments[0].MoveNext(); var arg = (XdmAtomicValue)arguments[0].Current; string path = arg.Value.ToString(); if(string.IsNullOrWhiteSpace(path)) return EmptyEnumerator.INSTANCE; var nodeset = compiler.Evaluate(path, context.ContextItem); return (IXdmEnumerator)nodeset.GetEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XdmValue result = RequestModule.IsLocal().ToXdmItem(); return result.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { Boolean exists = arguments[0].MoveNext(); if (exists) { XdmAtomicValue arg = (XdmAtomicValue)arguments[0].Current; double val = (double)arg.Value; double sqrt = System.Math.Sqrt(val); XdmAtomicValue result = new XdmAtomicValue(sqrt); return (IXdmEnumerator)result.GetEnumerator(); } else { return EmptyEnumerator.INSTANCE; } }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { return arguments[0]; }
public override JSequenceIterator call(JSequenceIterator[] arguments, JXPathContext context) { SequenceEnumerator[] na = new SequenceEnumerator[arguments.Length]; for (int i = 0; i < na.Length; i++) { na[i] = new SequenceEnumerator(arguments[i]); } DynamicContext dc = new DynamicContext(context); IXdmEnumerator result = functionCall.Call(na, dc); return new DotNetSequenceIterator(result); }
public XdmItem GetXdmItem(DynamicContext context) { return(XdmItem.FromGroundedValue(resource.getItem(context.context).materialize()).ItemAt(0)); }
/// <summary> /// Method called at run time to evaluate the function. /// </summary> /// <param name="arguments">The values of the arguments to the function, supplied as iterators over XPath /// sequence values.</param> /// <param name="context">The dynamic context for evaluation of the function. This provides access /// to the context item, position, and size, and if required to internal data maintained by the Saxon /// engine.</param> /// <returns>An iterator over a sequence, representing the result of the extension function. /// Note that Saxon does not guarantee to read this sequence to completion, so calls on the iterator /// must have no side-effects. In rare circumstances (for example, when <code>last()</code> is /// used) Saxon may clone the returned iterator by calling its <c>GetAnother()</c> method, /// allowing the function results to be read more than once.</returns> public abstract IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context);
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XdmValue result = RequestModule.UrlAppRelativeFilePath().ToXdmValue(); return result.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { string xml = arguments[0].AsAtomicValues().Single().ToString(); var parseOptions = new XmlParsingOptions { ConformanceLevel = ConformanceLevel.Document, BaseUri = new Uri("", UriKind.Relative) // Saxon requires a base URI }; using (var reader = new StringReader(xml)) { return this.itemFactory.CreateNodeReadOnly(reader, parseOptions) .ToXdmNode(this.itemFactory) .GetXdmEnumerator(); } }
/// <summary> /// Locate the collection of resources corresponding to a collection URI /// </summary> /// <param name="context">The XPath dynamic evaluation context</param> /// <param name="collectionURI">The collection URI: an absolute URI, formed by resolving the argument /// supplied to the fn:collection or fn:uri-collection against the static base URI</param> /// <returns>a ResourceCollection object representing resources in the collection identified by this collection URI</returns> public IResourceCollection FindCollection(DynamicContext context, string collectionURI) { return(new ResourceCollection(collectionFinder.findCollection(context.context, collectionURI))); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XdmValue result = RequestModule.HttpMethod().ToXdmValue(); return result.GetXdmEnumerator(); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { return Math.PI.ToXdmAtomicValue().GetXdmEnumerator(); }
public bool IsStable(DynamicContext context) { return(resourceCollection.isStable(context.context)); }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { if (defaultNamespace != null) { return (IXdmEnumerator)new XdmAtomicValue(defaultNamespace).GetEnumerator(); } else { return EmptyEnumerator.INSTANCE; } }
public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context) { XdmNode node = arguments[0].AsNodes().Single(); var options = new XPathSerializationOptions(); XdmItem arg2 = null; if (arguments.Length > 1 && (arg2 = arguments[1].AsItems().SingleOrDefault()) != null) { if (arg2.IsAtomic()) { string methodLexical = arg2.ToString(); QName method = (context.ContextItem == null || context.ContextItem.IsAtomic()) ? new QName(methodLexical) : new QName(methodLexical, (XdmNode)context.ContextItem); options.Method = method.ToXmlQualifiedName(); } } Serializer serializer = this.itemFactory.CreateSerializer(options); if (arg2 != null && !arg2.IsAtomic()) { foreach (XdmNode attr in ((IXdmEnumerator)((XdmNode)arg2).EnumerateAxis(XdmAxis.Attribute)).AsNodes()) { serializer.SetOutputProperty(attr.NodeName, attr.StringValue); } } using (var writer = new StringWriter()) { serializer.SetOutputWriter(writer); this.itemFactory.processor.WriteXdmValue(node, serializer); return writer.ToString().ToXdmAtomicValue().GetXdmEnumerator(); } }