System.Xml.Xsl.Runtime.XmlQueryContext.GetDataSource C# (CSharp) Method

GetDataSource() public method

Fetch the data source specified by "uriRelative" and "uriBase" from the XmlResolver that the user provided. If the resolver returns a stream or reader, create an instance of XPathDocument. If the resolver returns an XPathNavigator, return the navigator. Throw an exception if no data source was found.
public GetDataSource ( string uriRelative, string uriBase ) : XPathNavigator
uriRelative string
uriBase string
return System.Xml.XPath.XPathNavigator
        public XPathNavigator GetDataSource(string uriRelative, string uriBase) {
            object input;
            Uri uriResolvedBase, uriResolved;
            XPathNavigator nav = null;

            try {
                // If the data source has already been retrieved, then return the data source from the cache.
                uriResolvedBase = (uriBase != null) ? this.dataSources.ResolveUri(null, uriBase) : null;
                uriResolved = this.dataSources.ResolveUri(uriResolvedBase, uriRelative);
                if (uriResolved != null)
                    nav = this.dataSourceCache[uriResolved] as XPathNavigator;

                if (nav == null) {
                    // Get the entity from the resolver and ensure it is cached as a document
                    input = this.dataSources.GetEntity(uriResolved, null, null);

                    if (input != null) {
                        // Construct a document from the entity and add the document to the cache
                        nav = ConstructDocument(input, uriRelative, uriResolved);
                        this.dataSourceCache.Add(uriResolved, nav);
                    }
                }
            }
            catch (XslTransformException) {
                // Don't need to wrap XslTransformException
                throw;
            }
            catch (Exception e) {
                if (!XmlException.IsCatchableException(e)) {
                    throw;
                }
                throw new XslTransformException(e, Res.XmlIl_DocumentLoadError, uriRelative);
            }

            return nav;
        }