コード例 #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));
        }