Esempio n. 1
0
        /// <summary>
        /// Doc operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:doc 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 doc(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence doc(ICollection args, EvaluationContext ec)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            // get args
            IEnumerator argiter = cargs.GetEnumerator();

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

            if (arg1 == null || arg1.empty())
            {
                return(ResultSequenceFactory.create_new());
            }

            string uri = ((XSString)arg1.item(0)).value();

            DynamicContext dc       = ec.DynamicContext;
            var            resolved = dc.resolveUri(uri);

            if (resolved == null)
            {
                throw DynamicError.invalid_doc(null);
            }

            Document doc = dc.getDocument(resolved);

            if (doc == null)
            {
                throw DynamicError.doc_not_found(null);
            }

            return(new DocType(doc, ec.StaticContext.TypeModel));
        }
Esempio n. 2
0
        /// <summary>
        /// Doc operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:doc 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 collection(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence collection(ICollection args, EvaluationContext ec)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            // get args
            IEnumerator    argiter = cargs.GetEnumerator();
            ResultSequence arg1    = null;

            string uri = DEFAULT_COLLECTION_URI;

            if (argiter.MoveNext())
            {
                arg1 = (ResultSequence)argiter.Current;
                uri  = ((XSString)arg1.first()).value();
            }

            try
            {
                new URI(uri);
            }
            catch
            {
                throw DynamicError.doc_not_found(null);
            }

            if (uri.IndexOf(":", StringComparison.Ordinal) < 0)
            {
                throw DynamicError.invalidCollectionArgument();
            }


            URI resolved = ec.DynamicContext.resolveUri(uri);

            if (resolved == null)
            {
                throw DynamicError.invalid_doc(null);
            }

            ResultSequence rs = getCollection(uri, ec);

            if (rs.empty())
            {
                throw DynamicError.doc_not_found(null);
            }

            return(rs);
        }