예제 #1
0
파일: XPath.cs 프로젝트: orbeon/saxon-he
        /// <summary>
        /// Get the required cardinality of a declared variable in the static context of the expression.
        /// The occurrence indicator, one of '?' (zero-or-one),
        /// '*' (zero-or-more), '+' (one-or-more), ' ' (a single space) (exactly one),
        /// or 'º' (masculine ordinal indicator, xBA) (exactly zero). The type empty-sequence()
        /// can be represented by an occurrence indicator of 'º' with any item type.
        /// If the variable was explicitly declared, this will be the occurrence indicator that was set when the
        /// variable was declared. If no item type was set, it will be <see cref="net.sf.saxon.s9api.OccurrenceIndicator#ZERO_OR_MORE"/>.
        /// If the variable was implicitly declared by reference (which can happen only when the
        /// allowUndeclaredVariables option is set), the returned type will be
        /// <see cref="net.sf.saxon.s9api.OccurrenceIndicator#ZERO_OR_MORE"/>.
        /// If no variable with the specified QName has been declared either explicitly or implicitly,
        /// the method returns 0.
        /// </summary>
        /// <param name="variableName">the name of a declared variable</param>
        /// <returns>the required cardinality.</returns>


        public char GetRequiredCardinalityForVariable(QName variableName)
        {
            JXPathVariable var = env.getExternalVariable(variableName.ToStructuredQName());

            if (var == null)
            {
                return('0');
            }
            else
            {
                return(GetOccurrenceIndicator(var.getRequiredType().getCardinality()));
            }
        }
예제 #2
0
        /// <summary>
        /// Factory method to get an <c>AtomicType</c> object representing the atomic type with a given QName.
        /// </summary>
        /// <remarks>
        /// It is undefined whether two calls on this method supplying the same QName will return the same
        /// <c>XdmAtomicType</c> object instance.
        /// </remarks>
        /// <param name="qname">The QName 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)
            {
                return(new XdmAtomicType((JAtomicType)type));
            }
            else
            {
                return(null);
            }
        }
예제 #3
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;
            }
        }
예제 #4
0
파일: XQuery.cs 프로젝트: orbeon/saxon-he
        /// <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 QName. 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)
        {
            context.setParameter(name.ToStructuredQName(), value.Unwrap());
        }
예제 #5
0
        /// <summary>
        /// Get the required cardinality of a declared variable in the static context of the expression.
        /// </summary>
        /// <remarks>
        /// <para>The result is given as an occurrence indicator, one of:</para>
        /// <list>
        /// <item>'?' (zero-or-one)</item>
        /// <item>'*' (zero-or-more)</item>
        /// <item>'+' (one-or-more)</item>
        /// <item>' ' (a single space) (exactly one)</item>
        /// <item>'º' (masculine ordinal indicator, xBA) (exactly zero)</item>
        /// </list>
        /// <para>The type <c>empty-sequence()</c> can be represented by an occurrence indicator of 'º' with
        /// any item type.</para>
        /// <para>If the variable was explicitly declared, this will be the occurrence indicator that was set when the
        /// variable was declared. If no item type was set, it will be
        /// <see cref="net.sf.saxon.s9api.OccurrenceIndicator#ZERO_OR_MORE"/>.</para>
        /// <para>If the variable was implicitly declared by reference (which can happen only when the
        /// <c>allowUndeclaredVariables</c> option is set), the returned type will be
        /// <see cref="net.sf.saxon.s9api.OccurrenceIndicator#ZERO_OR_MORE"/>.</para>
        /// <para>If no variable with the specified <c>QName</c> has been declared either explicitly or implicitly,
        /// the method returns '0'.</para>
        /// </remarks>
        /// <param name="variableName">the name of a declared variable</param>
        /// <returns>The required cardinality, in the form of an occurrence indicator.</returns>


        public char GetRequiredCardinalityForVariable(QName variableName)
        {
            JXPathVariable var = ((JIndependentContext)executable.getUnderlyingStaticContext()).getExternalVariable(variableName.ToStructuredQName());

            if (var == null)
            {
                return('0');
            }
            else
            {
                return(GetOccurrenceIndicator(var.getRequiredType().getCardinality()));
            }
        }
예제 #6
0
파일: XQuery.cs 프로젝트: orbeon/saxon-he
        /// <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));
        }