Ejemplo n.º 1
0
        /// <summary>
        /// Set the value of a variable
        /// </summary>
        /// <param name="name">The name of the variable. This must match the name of a variable
        /// that was declared to the <c>XPathCompiler</c>. No error occurs if the expression does not
        /// actually reference a variable with this name.</param>
        /// <param name="value">The value to be given to the variable.</param>

        public void SetVariable(QName name, XdmValue value)
        {
            try
            {
                selector.setVariable(name.UnderlyingQName(), value == null ? null : XdmValue.FromGroundedValueToJXdmValue(value.value));
            }
            catch (JXPathException err)
            {
                throw new StaticError(err);
            }
        }
Ejemplo n.º 2
0
        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()))));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Call a global user-defined function in the compiled query.
        /// </summary>
        /// <remarks>
        /// If this is called more than once (to evaluate the same function repeatedly with different arguments,
        /// or to evaluate different functions) then the sequence of evaluations uses the same values of global
        /// variables including external variables (query parameters); the effect of any changes made to query parameters
        /// between calls is undefined.
        /// </remarks>
        /// <param name="function">
        /// The name of the function to be called
        /// </param>
        /// <param name="arguments">
        /// The values of the arguments to be supplied to the function. These
        /// must be of the correct type as defined in the function signature (there is no automatic
        /// conversion to the required type).
        /// </param>
        /// <exception cref="ArgumentException">If no function has been defined with the given name and arity
        /// or if any of the arguments does not match its required type according to the function
        /// signature.</exception>
        /// <exception cref="DynamicError">If a dynamic error occurs in evaluating the function.
        /// </exception>

        public XdmValue CallFunction(QName function, XdmValue[] arguments)
        {
            try {
                JXdmValue[] vr = new JXdmValue[arguments.Length];
                for (int i = 0; i < arguments.Length; i++)
                {
                    vr[i] = XdmValue.FromGroundedValueToJXdmValue(arguments[i].value);
                }
                JSequence result = evaluator.callFunction(function.UnderlyingQName(), vr).getUnderlyingValue();
                return(XdmValue.Wrap(result));
            } catch (JSaxonApiException e) {
                throw new DynamicError(e);
            }
        }
Ejemplo n.º 4
0
        public net.sf.saxon.s9api.XdmValue call(net.sf.saxon.s9api.XdmValue[] xvarr)
        {
            XdmValue[] values = new XdmValue[xvarr.Length];
            int        len    = xvarr.Length;

            for (int i = 0; i < len; i++)
            {
                values[i] = XdmValue.Wrap(xvarr[i].getUnderlyingValue());
            }
            try {
                XdmValue result = definition.Call(values);
                return(XdmValue.FromGroundedValueToJXdmValue(result.value));
            }
            catch (Exception ex) {
                throw new DynamicError(ex.Message);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Serialize an <c>XdmNode</c> to the selected output destination using this serializer.
 /// </summary>
 /// <param name="node">The node to be serialized</param>
 /// <remarks>since 9.8</remarks>
 public void SerializeXdmNode(XdmNode node)
 {
     serializer.serializeNode((net.sf.saxon.s9api.XdmNode)XdmValue.FromGroundedValueToJXdmValue(node.value));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Determine whether this item type matches a given item.
 /// </summary>
 /// <param name="item">the item to be tested against this item type</param>
 /// <returns>true if the item matches this item type, false if it does not match.</returns>
 virtual public bool Matches(XdmItem item)
 {
     return(type.matches((net.sf.saxon.s9api.XdmItem)XdmValue.FromGroundedValueToJXdmValue(item.value)));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Set the value of a schema parameter (a parameter defined in the schema using the <c>saxon:param</c> extension)
 /// </summary>
 /// <param name="name">the name of the schema parameter, as a QName</param>
 /// <param name="value">the value of the schema  parameter, or null to clear a previously set value</param>
 public void SetParameter(QName name, XdmValue value)
 {
     try {
         schemaValidator.setParameter(name.UnderlyingQName(), value == null ? null : XdmValue.FromGroundedValueToJXdmValue(value.value));
     } catch (net.sf.saxon.s9api.SaxonApiUncheckedException ex) {
         throw new StaticError(ex);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Set the value of an external variable declared in the query.
        /// </summary>
        /// <param name="name">The name of the external variable, expressed
        /// as a <c>QName</c>. If an external variable of this name has been declared in the
        /// query prolog, the given value will be assigned to the variable. If the
        /// variable has not been declared, calling this method has no effect (it is
        /// not an error).</param>
        /// <param name="value">The value to be given to the external variable.
        /// If the variable declaration defines a required type for the variable, then
        /// this value must match the required type: no conversions are applied.</param>

        public void SetExternalVariable(QName name, XdmValue value)
        {
            evaluator.setExternalVariable(new JXQName(name.ToStructuredQName()), value == null ? null : XdmValue.FromGroundedValueToJXdmValue(value.value));
        }