예제 #1
0
파일: Schema.cs 프로젝트: orbeon/saxon-he
 /// <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);
     }
 }
예제 #2
0
        /// <summary>
        /// Sets a property of a selected decimal format, for use by the <c>format-number()</c> function.
        /// </summary>
        /// <remarks>
        /// This method checks that the value is valid for the particular property, but it does not
        /// check that all the values for the decimal format are consistent (for example, that the
        /// decimal separator and grouping separator have different values). This consistency
        /// check is performed only when the decimal format is used.
        /// </remarks>
        /// <param name="format">The name of the decimal format whose property is to be set.
        ///  Supply null to set a property of the default (unnamed) decimal format.
        ///  This correponds to a name used in the third argument of <c>format-number()</c>.</param>
        /// <param name="property">The name of the property to set: one of
        ///   "decimal-separator", "grouping-separator", "infinity", "NaN",
        ///   "minus-sign", "percent", "per-mille", "zero-digit", "digit",
        ///   or "pattern-separator".</param>
        /// <param name="value">The new value for the property.</param>

        public void SetDecimalFormatProperty(QName format, String property, String value)
        {
            try
            {
                compiler.setDecimalFormatProperty(format.UnderlyingQName(), property, value);
            }
            catch (JSaxonApiException e) {
                throw new StaticError(e);
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
파일: XQuery.cs 프로젝트: orbeon/saxon-he
        /// <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);
            }
        }
예제 #5
0
        /// <summary>
		/// Factory method to get an <c>AtomicType</c> object representing the atomic type with a given <c>QName</c>.
        /// </summary>
        /// <remarks>
		/// It is undefined whether two calls on this method supplying the same <c>QName</c> will return the same
        /// <c>XdmAtomicType</c> object instance.
        /// </remarks>
		/// <param name="qname">The <c>QName</c> of the required type</param>
        /// <returns>An <c>AtomicType</c> object representing this type if it is present in this schema (and is an
        /// atomic type); otherwise, null. </returns>

        public XdmAtomicType GetAtomicType(QName qname)
        {
			JSchemaType type = config.getSchemaType(qname.ToStructuredQName());
            if (type is JBuiltInAtomicType)
            {
                return XdmAtomicType.BuiltInAtomicType(qname);
            }
            else if (type is JAtomicType)
            {
                JItemTypeFactory factory = new JItemTypeFactory(processor.JProcessor);
                return new XdmAtomicType(factory.getAtomicType(qname.UnderlyingQName()));
            }
            else
            {
                return null;
            }
        }
예제 #6
0
        /// <summary>
        /// Declare a variable for use by the XPath expression. If the expression
        /// refers to any variables, then they must be declared here, unless the
        /// <c>AllowUndeclaredVariables</c> property has been set to true.
        /// </summary>
        /// <param name="name">The name of the variable, as a <c>QName</c></param>


        public void DeclareVariable(QName name)
        {
            compiler.declareVariable(name.UnderlyingQName());
        }
예제 #7
0
        /// <summary>Set a serialization property</summary>
        /// <remarks>In the case of XSLT, properties set within the serializer override
        /// any properties set in <c>xsl:output</c> declarations in the stylesheet.
        /// Similarly, with XQuery, they override any properties set in the Query
        /// prolog using <c>declare option saxon:output</c>.</remarks>
        /// <example>
        ///   <code>
        ///     Serializer qout = new Serializer();
        ///     qout.SetOutputProperty(Serializer.METHOD, "xml");
        ///     qout.SetOutputProperty(Serializer.INDENT, "yes");
        ///     qout.SetOutputProperty(Serializer.SAXON_INDENT_SPACES, "1");
        ///   </code>
        /// </example>
        /// <param name="name">The name of the serialization property to be set</param>
        /// <param name="value">The value to be set for the serialization property. May be null
        /// to unset the property (that is, to set it back to the default value).</param>

        public void SetOutputProperty(QName name, String value)
        {
            props.setProperty(name.ClarkName, value);
            serializer.setOutputProperty(net.sf.saxon.s9api.Serializer.getProperty(name.UnderlyingQName()), value);
        }
예제 #8
0
파일: Schema.cs 프로젝트: orbeon/saxon-he
 /// <summary>
 /// Get the value that has set for a schema processor (a parameter defined in the schema using the <c>saxon:param</c>
 /// extension)
 /// </summary>
 /// <param name="name">the parameter whose name is required</param>
 /// <returns>the value that has been set for the parameter, or the EmptySequence if no value has been set</returns>
 public XdmValue GetParameter(QName name)
 {
     net.sf.saxon.s9api.XdmValue value = schemaValidator.getParameter(name.UnderlyingQName());
     return(value == null ? null : XdmValue.Wrap(value.getUnderlyingValue()));
 }