Saxon.Api

 

 

Saxon.Api

Class SimpleUriResolver


public class SimpleUriResolver
extends XmlResolver

A simple implementation of XmlResolver that supplies a delegate function accepting an absolute URI as its argument and returning a Stream.

Although this class implements XmlResolver, there is nothing specific to XML in its function; it can equally be used for resolving URIs for other media types.

Example:

XmlResolver resolver = new SimpleUriResolver(uri => new WebClient().OpenRead(uri))

Constructor Summary

SimpleUriResolver (Func<UriStream> fetcher)

Create a SimpleUriResolver that wraps a function from URIs to Streams

 

Method Summary

 object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)

Maps a URI to the content of the retrieved resource.

 

Constructor Detail

SimpleUriResolver

public SimpleUriResolver(Func<UriStream> fetcher)

Create a SimpleUriResolver that wraps a function from URIs to Streams

Parameters:

fetcher - A function (typically supplied as a lambda expression) that takes a Uri as input and delivers the content at that Uri as a Stream.

Method Detail

GetEntity

public override object GetEntity(Uri absoluteUri,
string role,
Type ofObjectToReturn)

Maps a URI to the content of the retrieved resource.

Implements the .NET-defined XmlResolver interface, with all its quirks. This implementation simply calls the function that was supplied as the argument to the constructor.

Parameters:

absoluteUri - The absolute URI of the resource
role - Not used
ofObjectToReturn - Not used

Returns:

Returns the resource contents as a Stream.