コード例 #1
0
        /// <summary>
        /// Adds a type into the functions library.
        /// </summary>
        /// <param name="at">
        ///            input of any atomic type. </param>
        public virtual void add_type(CtrType at)
        {
            QName name = new QName(at.type_name());

            name.set_namespace(@namespace());

            _types[name] = at;

            add_function(new Constructor(at));
        }
コード例 #2
0
        /// <summary>
        /// Convert-Operand operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fs: operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence convert_operand(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence convert_operand(ICollection args)
        {
            Debug.Assert(args.Count == 2);

            IEnumerator iter = args.GetEnumerator();

            iter.MoveNext();
            ResultSequence actual = (ResultSequence)iter.Current;

            iter.MoveNext();
            ResultSequence expected = (ResultSequence)iter.Current;

            if (expected == null || expected.size() != 1)
            {
                DynamicError.throw_type_error();
            }

            Item at = expected.first();

            if (!(at is AnyAtomicType))
            {
                DynamicError.throw_type_error();
            }

            AnyAtomicType exp_aat = (AnyAtomicType)at;

            ResultBuffer result = new ResultBuffer();

            // 1
            if (actual.empty())
            {
                return(result.Sequence);
            }

            // convert sequence
            for (var i = actual.iterator(); i.MoveNext();)
            {
                AnyType item = (AnyType)i.Current;

                // 2
                if (item is XSUntypedAtomic)
                {
                    // a
                    if (exp_aat is XSUntypedAtomic)
                    {
                        result.add(new XSString(item.StringValue));
                    }
                    // b
                    else if (exp_aat is NumericType)
                    {
                        result.add(new XSDouble(item.StringValue));
                    }
                    // c
                    else
                    {
                        Debug.Assert(exp_aat is CtrType);
                        CtrType cons = (CtrType)exp_aat;
                        result.concat(cons.constructor(new XSString(item.StringValue)));
                    }
                }
                // 4
                else
                {
                    result.add(item);
                }
            }

            return(result.Sequence);
        }
コード例 #3
0
 /// <summary>
 /// Constructor for Constructor class.
 /// </summary>
 /// <param name="aat">
 ///            input of any atomic type. </param>
 public Constructor(CtrType aat) : base(new QName(aat.type_name()), 1)
 {
     _atomic_type = aat;
 }