Esempio n. 1
0
        /// <summary>
        /// Converts arguments to values.
        /// </summary>
        /// <param name="args">
        ///            Result from expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of conversion. </returns>
        private static ICollection value_convert_args(ICollection args)
        {
            var result = new ArrayList(args.Count);

            // atomize arguments
            for (IEnumerator i = args.GetEnumerator(); i.MoveNext();)
            {
                ResultSequence rs = (ResultSequence)i.Current;

                //FnData.fast_atomize(rs);
                rs = FnData.atomize(rs);

                if (rs.empty())
                {
                    return(new ArrayList());
                }

                if (rs.size() > 1)
                {
                    throw new DynamicError(TypeError.invalid_type(null));
                }

                Item arg = rs.first();

                if (arg is XSUntypedAtomic)
                {
                    arg = new XSString(arg.StringValue);
                }

                result.Add(arg);
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Join the arguments.
        /// </summary>
        /// <param name="args">
        ///            are joined. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> The result of the arguments being joined together. </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 string_join(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence string_join(ICollection args)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            IEnumerator argi = cargs.GetEnumerator();

            argi.MoveNext();
            ResultSequence arg1 = (ResultSequence)argi.Current;

            argi.MoveNext();
            ResultSequence arg2 = (ResultSequence)argi.Current;

            string result    = "";
            string separator = ((XSString)arg2.first()).value();

            StringBuilder buf   = new StringBuilder();
            bool          first = false;

            for (var i = arg1.iterator(); i.MoveNext();)
            {
                if (!first)
                {
                    buf.Append(separator);
                }
                first = false;
                XSString item = (XSString)i.Current;
                buf.Append(item.value());
            }

            result = buf.ToString();
            return(new XSString(result));
        }
        /// <summary>
        /// Base-Uri operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:base-uri 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 string_to_codepoints(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence string_to_codepoints(ICollection args)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            var i = cargs.GetEnumerator();

            i.MoveNext();
            ResultSequence arg1 = (ResultSequence)i.Current;

            if (arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            XSString xstr = (XSString)arg1.first();

            CodePointIterator cpi = new StringCodePointIterator(xstr.value());

            ResultBuffer rs = new ResultBuffer();

            for (int codePoint = cpi.current(); codePoint != org.eclipse.wst.xml.xpath2.processor.@internal.utils.CodePointIterator_Fields.DONE; codePoint = cpi.next())
            {
                rs.add(new XSInteger(new System.Numerics.BigInteger(codePoint)));
            }
            return(rs.Sequence);
        }
Esempio n. 4
0
        /// <summary>
        /// Compare the arguments.
        /// </summary>
        /// <param name="args">
        ///            are compared (optional 3rd argument is the collation) </param>
        /// <param name="dynamicContext">
        ///            Current dynamic context </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> The result of the comparison of the arguments. </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 compare(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence compare(ICollection args, DynamicContext context)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1 = (ResultSequence)argiter.Current;

            argiter.MoveNext();
            ResultSequence arg2 = (ResultSequence)argiter.Current;

            string collationUri = context.CollationProvider.DefaultCollation;

            if (argiter.MoveNext())
            {
                ResultSequence collArg = (ResultSequence)argiter.Current;
                collationUri = collArg.first().StringValue;
            }

            XSString xstr1 = arg1.empty() ? null : (XSString)arg1.first();
            XSString xstr2 = arg2.empty() ? null : (XSString)arg2.first();

            System.Numerics.BigInteger result = compare_string(collationUri, xstr1, xstr2, context);
            if (result != null)
            {
                return(ResultSequenceFactory.create_new(new XSInteger(result)));
            }
            else
            {
                return(ResultSequenceFactory.create_new());
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Compare the arguments as codepoints
        /// </summary>
        /// <param name="args">
        ///            are compared. </param>
        /// <param name="dynamicContext">
        ///            The current dynamic context </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> The result of the comparison of the arguments. </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 codepoint_equals(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence codepoint_equals(ICollection args, DynamicContext dynamicContext)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            ResultBuffer rs = new ResultBuffer();

            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1  = (ResultSequence)argiter.Current;
            XSString       xstr1 = arg1 == null || arg1.empty() ? null : (XSString)arg1.first();

            argiter.MoveNext();
            ResultSequence arg2  = (ResultSequence)argiter.Current;
            XSString       xstr2 = arg2 == null || arg2.empty() ? null : (XSString)arg2.first();

            // This delegates to FnCompare
            System.Numerics.BigInteger result = FnCompare.compare_string(org.eclipse.wst.xml.xpath2.api.CollationProvider_Fields.CODEPOINT_COLLATION, xstr1, xstr2, dynamicContext);
            if (result != null)
            {
                rs.add(new XSBoolean(System.Numerics.BigInteger.Zero.Equals(result)));
            }

            return(rs.Sequence);
        }
Esempio n. 6
0
        /// <summary>
        /// Distinct-values operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:distinct-values 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 distinct_values(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence distinct_values(ICollection args, DynamicContext context)
        {
            ResultBuffer rs = new ResultBuffer();

            // get args
            IEnumerator citer = args.GetEnumerator();

            citer.MoveNext();
            ResultSequence arg1 = (ResultSequence)citer.Current;
            ResultSequence arg2 = ResultBuffer.EMPTY;

            if (citer.MoveNext())
            {
                arg2 = (ResultSequence)citer.Current;
            }

            string collationURI = context.CollationProvider.DefaultCollation;

            if (!(arg2 == null || arg2.empty()))
            {
                XSString collation = (XSString)arg2.item(0);
                collationURI = collation.StringValue;
            }

            for (var iter = arg1.iterator(); iter.MoveNext();)
            {
                AnyAtomicType atomizedItem = (AnyAtomicType)FnData.atomize((Item)iter.Current);
                if (!contains(rs, atomizedItem, context, collationURI))
                {
                    rs.add(atomizedItem);
                }
            }

            return(rs.Sequence);
        }
Esempio n. 7
0
        public static System.Numerics.BigInteger compare_string(string collationUri, XSString xstr1, XSString xstr2, DynamicContext context)
        {
            var collator = context.CollationProvider.getCollation(collationUri);

            if (collator == null)
            {
                throw DynamicError.unsupported_collation(collationUri);
            }

            if (xstr1 == null || xstr2 == null)
            {
                return(default);
Esempio n. 8
0
        /// <summary>
        /// Deep-Equal boolean operation for inputs of any atomic type.
        /// </summary>
        /// <param name="one">
        ///            input1 xpath expression/variable. </param>
        /// <param name="two">
        ///            input2 xpath expression/variable. </param>
        /// <returns> Result of fn:deep-equal operation. </returns>
        public static bool deep_equal_atomic(AnyAtomicType one, AnyAtomicType two, DynamicContext context, string collationURI)
        {
            if (!(one is CmpEq))
            {
                return(false);
            }
            if (!(two is CmpEq))
            {
                return(false);
            }

            CmpEq a = (CmpEq)one;

            try
            {
                if (isNumeric(one, two))
                {
                    NumericType numeric = (NumericType)one;
                    if (numeric.eq(two, context))
                    {
                        return(true);
                    }
                    else
                    {
                        XSString value1 = new XSString(one.StringValue);
                        if (value1.eq(two, context))
                        {
                            return(true);
                        }
                    }
                }

                if (a.eq(two, context))
                {
                    return(true);
                }

                if (needsStringComparison(one, two))
                {
                    XSString xstr1 = new XSString(one.StringValue);
                    XSString xstr2 = new XSString(two.StringValue);
                    if (FnCompare.compare_string(collationURI, xstr1, xstr2, context).Equals(System.Numerics.BigInteger.Zero))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (DynamicError)
            {
                return(false);                // XXX ???
            }
        }
Esempio n. 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected static boolean hasValue(org.eclipse.wst.xml.xpath2.api.ResultBuffer rs, org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType item, org.eclipse.wst.xml.xpath2.api.DynamicContext context, String collationURI) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        protected internal static bool hasValue(ResultBuffer rs, AnyAtomicType item, DynamicContext context, string collationURI)
        {
            XSString itemStr = new XSString(item.StringValue);

            for (IEnumerator i = rs.iterator(); i.MoveNext();)
            {
                AnyType at = (AnyType)i.Current;

                if (!(at is CmpEq))
                {
                    continue;
                }

                if (isBoolean(item, at))
                {
                    XSBoolean boolat = (XSBoolean)at;
                    if (boolat.eq(item, context))
                    {
                        return(true);
                    }
                }

                if (isNumeric(item, at))
                {
                    NumericType numericat = (NumericType)at;
                    if (numericat.eq(item, context))
                    {
                        return(true);
                    }
                }

                if (isDuration(item, at))
                {
                    XSDuration durat = (XSDuration)at;
                    if (durat.eq(item, context))
                    {
                        return(true);
                    }
                }

                if (needsStringComparison(item, at))
                {
                    XSString xstr1 = new XSString(at.StringValue);
                    if (FnCompare.compare_string(collationURI, xstr1, itemStr, context).Equals(System.Numerics.BigInteger.Zero))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 10
0
        /// <summary>
        /// Obtain a comparable type.
        /// </summary>
        /// <param name="at">
        ///            expression of any type. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static CmpEq get_comparable(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType at) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        private static CmpEq get_comparable(AnyType at)
        {
            if (at is NodeType)
            {
                XSString nodeString = new XSString(at.StringValue);
                return(nodeString);
            }

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

            if (!(at is CmpEq))
            {
                throw DynamicError.not_cmp(null);
            }

            return((CmpEq)at);
        }
Esempio n. 11
0
        /// <summary>
        /// Trace operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:trace 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 trace(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence trace(ICollection args)
        {
            // sanity check args
            if (args.Count != 2)
            {
                DynamicError.throw_type_error();
            }

            IEnumerator argsi = args.GetEnumerator();

            argsi.MoveNext();
            ResultSequence arg1 = (ResultSequence)argsi.Current;

            argsi.MoveNext();
            ResultSequence arg2 = (ResultSequence)argsi.Current;

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

            Item at = arg2.first();

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

            XSString label = (XSString)at;

            int index = 1;

            for (var i = arg1.iterator(); i.MoveNext(); index++)
            {
                at = (AnyType)i.Current;

                Console.WriteLine(label.value() + " [" + index + "] " + ((AnyType)at).string_type() + ":" + at.StringValue);
            }

            return(arg1);
        }
Esempio n. 12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected static boolean hasValue(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType itema, org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType itemb, org.eclipse.wst.xml.xpath2.api.DynamicContext context, String collationURI) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        protected internal static bool hasValue(AnyType itema, AnyType itemb, DynamicContext context, string collationURI)
        {
            XSString itemStr = new XSString(itema.StringValue);

            if (isBoolean(itema, itemb))
            {
                XSBoolean boolat = (XSBoolean)itema;
                if (boolat.eq(itemb, context))
                {
                    return(true);
                }
            }

            if (isNumeric(itema, itemb))
            {
                NumericType numericat = (NumericType)itema;
                if (numericat.eq(itemb, context))
                {
                    return(true);
                }
            }

            if (isDuration(itema, itemb))
            {
                XSDuration durat = (XSDuration)itema;
                if (durat.eq(itemb, context))
                {
                    return(true);
                }
            }

            if (needsStringComparison(itema, itemb))
            {
                XSString xstr1 = new XSString(itema.StringValue);
                if (FnCompare.compare_string(collationURI, xstr1, itemStr, context).Equals(System.Numerics.BigInteger.Zero))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 13
0
        /// <summary>
        /// A fast Equality operation, no conversion for the inputs performed.
        /// </summary>
        /// <param name="one">
        ///            input1 of any type. </param>
        /// <param name="two">
        ///            input2 of any type. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of Equality operation. </returns>
        public static bool fs_eq_fast(AnyType one, AnyType two, DynamicContext context)
        {
            one = FnData.atomize((Item)one);
            two = FnData.atomize((Item)two);

            if (one is XSUntypedAtomic)
            {
                one = new XSString(one.StringValue);
            }

            if (two is XSUntypedAtomic)
            {
                two = new XSString(two.StringValue);
            }

            if (!(one is CmpEq))
            {
                DynamicError.throw_type_error();
            }

            CmpEq cmpone = (CmpEq)one;

            return(cmpone.eq(two, context));
        }
Esempio n. 14
0
        /// <summary>
        /// Making sure that the types are the same before comparing the inputs.
        /// </summary>
        /// <param name="a">
        ///            input1 of any type. </param>
        /// <param name="b">
        ///            input2 of any type. </param>
        /// <param name="dc">
        ///              Dynamic Context </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of Equality operation. </returns>
        private static bool do_general_pair(AnyType a, AnyType b,
                                            MethodBase comparator, DynamicContext ec)
        {
            // section 3.5.2

            // rule a
            // if one is untyped and other is numeric, cast untyped to
            // double
            if ((a is XSUntypedAtomic && b is NumericType) || (b is XSUntypedAtomic && a is NumericType))
            {
                if (a is XSUntypedAtomic)
                {
                    a = new XSDouble(a.StringValue);
                }
                else
                {
                    b = new XSDouble(b.StringValue);
                }
            }

            // rule b
            // if one is untyped and other is string or untyped, then cast
            // untyped to string
            else if ((a is XSUntypedAtomic && (b is XSString || b is XSUntypedAtomic) || (b is XSUntypedAtomic && (a is XSString || a is XSUntypedAtomic))))
            {
                if (a is XSUntypedAtomic)
                {
                    a = new XSString(a.StringValue);
                }
                if (b is XSUntypedAtomic)
                {
                    b = new XSString(b.StringValue);
                }
            }

            // rule c
            // if one is untyped and other is not string,untyped,numeric
            // cast untyped to dynamic type of other

            // XXX?
            // TODO: This makes no sense as implemented before
            else if (a is XSUntypedAtomic)
            {
                //ResultSequence converted = ResultSequenceFactory.create_new(a);
                //Debug.Assert(converted.size() == 1);
                //a = (AnyType)converted.first();
            }
            else if (b is XSUntypedAtomic)
            {
                //ResultSequence converted = ResultSequenceFactory.create_new(b);
                //Debug.Assert(converted.size() == 1);
                //b = (AnyType) converted.first();
            }

            // rule d
            // if value comparison is true, return true.

            ResultSequence one = ResultSequenceFactory.create_new(a);
            ResultSequence two = ResultSequenceFactory.create_new(b);

            var args = new ArrayList();

            args.Add(one);
            args.Add(two);

            object[] margs = new object[] { args, ec };

            ResultSequence result = null;

            try
            {
                result = (ResultSequence)comparator.Invoke(null, margs);
            }
            catch (Exception)
            {
                throw;
            }

            if (((XSBoolean)result.first()).value())
            {
                return(true);
            }

            return(false);
        }
Esempio n. 15
0
 /// <summary>
 /// Constructor for StringLiteral
 /// </summary>
 /// <param name="value">
 ///            string value </param>
 public StringLiteral(string value)
 {
     _value = new XSString(value);
 }
Esempio n. 16
0
        /// <summary>
        /// Index-Of operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dynamicContext"> </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:index-of operation. </returns>
        public static ResultSequence index_of(ICollection args, DynamicContext dc)
        {
            Function.convert_arguments(args, expected_args());

            // get args
            IEnumerator citer = args.GetEnumerator();

            citer.MoveNext();
            ResultSequence arg1 = (ResultSequence)citer.Current;

            citer.MoveNext();
            ResultSequence arg2 = (ResultSequence)citer.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            // sanity chex
            if (arg2 == null || arg2.size() != 1)
            {
                DynamicError.throw_type_error();
            }

            string collationUri = dc.CollationProvider.DefaultCollation;

            if (citer.MoveNext())
            {
                ResultSequence arg3 = (ResultSequence)citer.Current;
                if (!arg3.empty())
                {
                    XSString collation = (XSString)arg3.first();
                    collationUri = collation.StringValue;
                }
            }

            ResultBuffer  rb = new ResultBuffer();
            AnyAtomicType at = (AnyAtomicType)arg2.first();

            get_comparable(at);

            int index = 1;

            for (var i = arg1.iterator(); i.MoveNext();)
            {
                AnyType cmptype = (AnyType)i.Current;
                get_comparable(cmptype);

                if (!(at is CmpEq))
                {
                    continue;
                }

                if (isBoolean(cmptype, at))
                {
                    XSBoolean boolat = (XSBoolean)cmptype;
                    if (boolat.eq(at, dc))
                    {
                        rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                    }
                }
                else
                {
                    if (isNumeric(cmptype, at))
                    {
                        NumericType numericat = (NumericType)at;
                        if (numericat.eq(cmptype, dc))
                        {
                            rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                        }
                    }
                    else
                    {
                        if (isDuration(cmptype, at))
                        {
                            XSDuration durat = (XSDuration)at;
                            if (durat.eq(cmptype, dc))
                            {
                                rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                            }
                        }
                        else
                        {
                            if (at is QName && cmptype is QName)
                            {
                                QName qname = (QName)at;
                                if (qname.eq(cmptype, dc))
                                {
                                    rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                                }
                            }
                            else
                            {
                                if (needsStringComparison(cmptype, at))
                                {
                                    XSString xstr1   = new XSString(cmptype.StringValue);
                                    XSString itemStr = new XSString(at.StringValue);
                                    if (FnCompare.compare_string(collationUri, xstr1, itemStr, dc).Equals(System.Numerics.BigInteger.Zero))
                                    {
                                        rb.add(new XSInteger(new System.Numerics.BigInteger(index)));
                                    }
                                }
                            }
                        }
                    }
                }

                index++;
            }

            return(rb.Sequence);
        }
Esempio n. 17
0
        // convert argument according to section 3.1.5 of xpath 2.0 spec
        /// <summary>
        /// Convert the input argument according to section 3.1.5 of specification.
        /// </summary>
        /// <param name="arg">
        ///            input argument. </param>
        /// <param name="expected">
        ///            Expected Sequence type. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Converted argument. </returns>
        public static org.eclipse.wst.xml.xpath2.api.ResultSequence convert_argument(org.eclipse.wst.xml.xpath2.api.ResultSequence arg, SeqType expected)
        {
            ResultBuffer result = new ResultBuffer();

            // XXX: Should use type_class instead and use item.getClass().isAssignableTo(expected.type_class())
            AnyType expected_type = expected.type();

            // expected is atomic
            if (expected_type is AnyAtomicType)
            {
                AnyAtomicType expected_aat = (AnyAtomicType)expected_type;

                // atomize
                org.eclipse.wst.xml.xpath2.api.ResultSequence rs = FnData.atomize(arg);

                // cast untyped to expected type
                for (var i = rs.iterator(); i.MoveNext();)
                {
                    AnyType item = (AnyType)i.Current;

                    if (item is XSUntypedAtomic)
                    {
                        // create a new item of the expected
                        // type initialized with from the string
                        // value of the item
                        ResultSequence converted = null;
                        if (expected_aat is XSString)
                        {
                            XSString strType = new XSString(item.StringValue);
                            converted = ResultSequenceFactory.create_new(strType);
                        }
                        else
                        {
                            converted = ResultSequenceFactory.create_new(item);
                        }

                        result.concat(converted);
                    }
                    // xs:anyURI promotion to xs:string
                    else if (item is XSAnyURI && expected_aat is XSString)
                    {
                        result.add(new XSString(item.StringValue));
                    }
                    // numeric type promotion
                    else if (item is NumericType)
                    {
                        if (expected_aat is XSDouble)
                        {
                            XSDouble doubleType = new XSDouble(item.StringValue);
                            result.add(doubleType);
                        }
                        else
                        {
                            result.add(item);
                        }
                    }
                    else
                    {
                        result.add(item);
                    }
                }
                // do sequence type matching on converted arguments
                return(expected.match(result.Sequence));
            }
            else
            {
                // do sequence type matching on converted arguments
                return(expected.match(arg));
            }
        }