示例#1
0
        /// <summary>
        /// Document-Uri operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:document-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 document_uri(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence document_uri(ICollection args)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());
            var         i     = cargs.GetEnumerator();

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

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

            NodeType nt = (NodeType)arg1.first();

            if (!(nt is DocType))
            {
                return(ResultBuffer.EMPTY);
            }

            DocType dt          = (DocType)nt;
            string  documentURI = dt.value().DocumentURI;

            if (!string.ReferenceEquals(documentURI, null))
            {
                XSAnyURI docUri = new XSAnyURI(documentURI);
                return(docUri);
            }
            return(ResultBuffer.EMPTY);
        }
示例#2
0
        /*
         * Helper function for base-uri support
         */
        public static ResultSequence getBaseUri(Item att)
        {
            ResultBuffer rs      = new ResultBuffer();
            XSAnyURI     baseUri = null;

            // depending on the node type, we get the base-uri for the node.
            // if base-uri property in DOM is null, we set the base-uri as string "null". This
            // avoids null pointer exception while comparing xs:anyURI values.

            if (att is NodeType)
            {
                NodeType node    = (NodeType)att;
                Node     domNode = node.node_value();
                string   buri    = domNode.BaseURI;
                if (!string.ReferenceEquals(buri, null))
                {
                    baseUri = new XSAnyURI(buri);
                }
                else
                {
                    baseUri = new XSAnyURI("null");
                }
            }

            if (baseUri != null)
            {
                rs.add(baseUri);
            }

            return(rs.Sequence);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="schema">
        ///            Schema information from document. May be null. </param>
        public DefaultStaticContext(TypeModel model)
        {
            _xpath1_compatible = false;

            _default_namespace          = null;
            _default_function_namespace = FnFunctionLibrary.XPATH_FUNCTIONS_NS;
            _model       = model;
            builtinTypes = new XSCtrLibrary();

            _functions  = new Dictionary <string, FunctionLibrary>(20); // allow null keys: null namespace
            _namespaces = new Hashtable(20);                            // ditto

            _cntxt_item_type = null;

            _scopes = new Stack();
            new_scope();

            if (_model != null)
            {
                init_schema(model);
            }

            _base_uri = new XSAnyURI();

            // XXX wildcard prefix
            add_namespace("*", "*");
        }
 /// <summary>
 /// Set the Base URI for the static context.
 /// </summary>
 public virtual void set_base_uri(string baseuri)
 {
     _base_uri = new XSAnyURI(baseuri);
 }