Class Loader
A class providing utility methods for loading RDF data from URIS.
Inherited Members
Namespace: VDS.RDF.Parsing
Assembly: dotNetRdf.dll
Syntax
public class Loader
Constructors
| Edit this page View SourceLoader()
Create a new Loader instance with a new default HTTP client.
Declaration
public Loader()
Loader(HttpClient)
Create a new Loader instance with the specified HTTP client.
Declaration
public Loader(HttpClient httpClient)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | httpClient | The HTTP client instance to use. Must not be null. |
Properties
| Edit this page View SourceFollowRedirects
Get or set a value that indicates the Loader should follow redirection responses from the underlying HttpClient.
Declaration
public bool FollowRedirects { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The .NET HttpClient should automatically follow redirects unless configured not to. However, we have encountered issues with the default HttpClient not following HTTPS to HTTPS redirects on commonly used endpoints like DBPedia.org.
To support easier loading from endpoints that redirect in ways that the underlying HttpClientHandler does not support the Loader class implements its own redirect following layered on top of the HttpClient redirect following.
This flag can be used to enable or disable that additional level of redirect following. It is enabled by default.
To disable all redirect following you must both disable this flag and also construct the Loader with an HttpClient instance that has been initialised with an HttpClientHandler instance with AllowAutoRedirect set to false.
// Construct a loader that will never follow redirect responses
var loader = new Loader(new HttpClient(new HttpClientHandler { AllowAutoRedirects = false })) { FollowRedirects = false };
HttpClient
Get or set the client to use for making HTTP requests.
Declaration
public HttpClient HttpClient { get; set; }
Property Value
Type | Description |
---|---|
HttpClient |
Remarks
This property must not be set to null.
MaxRedirects
Get or set the maximum number of redirects that the Loader will follow.
Declaration
public int MaxRedirects { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The number of redirects followed by the Loader will be in addition to any redirects followed by the underlying HttpClient. Defaults to 10.
Methods
| Edit this page View SourceLoadDataset(IRdfHandler, Uri, IStoreReader)
Attempts to load a RDF dataset from the given URI using a RDF Handler.
Declaration
public void LoadDataset(IRdfHandler handler, Uri uri, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | uri | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
LoadDataset(ITripleStore, Uri)
Attempts to load a RDF dataset from the given URI into the given Triple Store.
Declaration
public void LoadDataset(ITripleStore store, Uri uri)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | uri | URI to attempt to get a RDF dataset from. |
Remarks
Attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
LoadDataset(ITripleStore, Uri, IStoreReader)
Attempts to load a RDF dataset from the given URI into the given Triple Store.
Declaration
public void LoadDataset(ITripleStore store, Uri uri, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | uri | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
LoadDatasetAsync(IRdfHandler, Uri)
Attempts to load a RDF dataset from the given URI using a RDF Handler.
Declaration
public Task LoadDatasetAsync(IRdfHandler handler, Uri u)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to attempt to get a RDF dataset from. |
Returns
Type | Description |
---|---|
Task |
Remarks
Attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
LoadDatasetAsync(IRdfHandler, Uri, IStoreReader)
Attempts to load a RDF dataset from the given URI using a RDF Handler.
Declaration
public Task LoadDatasetAsync(IRdfHandler handler, Uri uri, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | uri | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
Returns
Type | Description |
---|---|
Task |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
LoadDatasetAsync(IRdfHandler, Uri, IStoreReader, CancellationToken)
Attempts to load a RDF dataset from the given URI using a RDF Handler.
Declaration
public Task LoadDatasetAsync(IRdfHandler handler, Uri uri, IStoreReader parser, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | uri | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
CancellationToken | cancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
Task |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
LoadDatasetAsync(ITripleStore, Uri)
Attempts to load a RDF dataset from the given URI into the given Triple Store.
Declaration
public Task LoadDatasetAsync(ITripleStore store, Uri uri)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | uri | URI to attempt to get a RDF dataset from. |
Returns
Type | Description |
---|---|
Task |
Remarks
Attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
LoadDatasetAsync(ITripleStore, Uri, IStoreReader)
Attempts to load a RDF dataset from the given URI into the given Triple Store.
Declaration
public Task LoadDatasetAsync(ITripleStore store, Uri uri, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | uri | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
Returns
Type | Description |
---|---|
Task |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
LoadDatasetAsync(ITripleStore, Uri, IStoreReader, CancellationToken)
Attempts to load a RDF dataset from the given URI into the given Triple Store.
Declaration
public Task LoadDatasetAsync(ITripleStore store, Uri uri, IStoreReader parser, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | uri | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
CancellationToken | cancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
Task |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
LoadGraph(IGraph, Uri)
Load RDF data from the specified URI into the specified graph.
Declaration
public void LoadGraph(IGraph graph, Uri uri)
Parameters
Type | Name | Description |
---|---|---|
IGraph | graph | The target graph to load RDF data into. |
Uri | uri | The URI of the RDF data to be loaded. |
Remarks
If uri
is a data: URI, the DataUriLoader will be used to load the content.
If uri
is a reference to a local file, the FileLoader will be used to load the content.
Otherwise the loader will attempt to dereference the URI using the HttpClient.
The loader will attempt to automatically determine the parser to be used from the Content Type header returned by the remote server (or by the file extension if the URI is a local file URI).
LoadGraph(IGraph, Uri, IRdfReader)
Load RDF data from the specified URI into the specified graph.
Declaration
public void LoadGraph(IGraph graph, Uri uri, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IGraph | graph | The target graph to load RDF data into. |
Uri | uri | The URI of the RDF data to be loaded. |
IRdfReader | parser | The parser to use when loading data. |
Remarks
If uri
is a data: URI, the DataUriLoader will be used to load the content.
If uri
is a reference to a local file, the FileLoader will be used to load the content.
Otherwise the loader will attempt to dereference the URI using the HttpClient.
If parser
is null, the loader will attempt to automatically determine the parser to be used from the Content Type header returned by the remote server (or by the file extension if the URI is a local file URI).
If parser
is not null, then this parser will always be used regardless of the Content Type header returned by the remote server.
LoadGraphAsync(IGraph, Uri)
Load RDF data from the specified URI into the specified graph.
Declaration
public Task LoadGraphAsync(IGraph graph, Uri uri)
Parameters
Type | Name | Description |
---|---|---|
IGraph | graph | The target graph to load RDF data into. |
Uri | uri | The URI of the RDF data to be loaded. |
Returns
Type | Description |
---|---|
Task |
Remarks
If uri
is a data: URI, the DataUriLoader will be used to load the content.
If uri
is a reference to a local file, the FileLoader will be used to load the content.
Otherwise the loader will attempt to dereference the URI using the HttpClient.
The loader will attempt to automatically determine the parser to be used from the Content Type header returned by the remote server (or by the file extension if the URI is a local file URI).
LoadGraphAsync(IGraph, Uri, IRdfReader)
Load RDF data from the specified URI into the specified graph.
Declaration
public Task LoadGraphAsync(IGraph graph, Uri uri, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IGraph | graph | The target graph to load RDF data into. |
Uri | uri | The URI of the RDF data to be loaded. |
IRdfReader | parser | The parser to use when loading data. |
Returns
Type | Description |
---|---|
Task |
Remarks
If uri
is a data: URI, the DataUriLoader will be used to load the content.
If uri
is a reference to a local file, the FileLoader will be used to load the content.
Otherwise the loader will attempt to dereference the URI using the HttpClient.
If parser
is null, the loader will attempt to automatically determine the parser to be used from the Content Type header returned by the remote server (or by the file extension if the URI is a local file URI).
If parser
is not null, then this parser will always be used regardless of the Content Type header returned by the remote server.
LoadGraphAsync(IGraph, Uri, IRdfReader, CancellationToken)
Load RDF data from the specified URI into the specified graph.
Declaration
public Task LoadGraphAsync(IGraph graph, Uri uri, IRdfReader parser, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IGraph | graph | The target graph to load RDF data into. |
Uri | uri | The URI of the RDF data to be loaded. |
IRdfReader | parser | The parser to use when loading data. |
CancellationToken | cancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
Task |
Remarks
If uri
is a data: URI, the DataUriLoader will be used to load the content.
If uri
is a reference to a local file, the FileLoader will be used to load the content.
Otherwise the loader will attempt to dereference the URI using the HttpClient.
If parser
is null, the loader will attempt to automatically determine the parser to be used from the Content Type header returned by the remote server (or by the file extension if the URI is a local file URI).
If parser
is not null, then this parser will always be used regardless of the Content Type header returned by the remote server.
LoadGraphAsync(IRdfHandler, Uri, IRdfReader, CancellationToken)
Parse RDF data from the specified URI and pass the resulting triples to the specified handler.
Declaration
public Task LoadGraphAsync(IRdfHandler handler, Uri uri, IRdfReader parser, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | The handler to receive the parsed RDF triples. |
Uri | uri | The URI of the RDF data to be loaded. |
IRdfReader | parser | The parser to use when loading data. |
CancellationToken | cancellationToken | A cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
Task |
Remarks
If uri
is a data: URI, the DataUriLoader will be used to load the content.
If uri
is a reference to a local file, the FileLoader will be used to load the content.
Otherwise the loader will attempt to dereference the URI using the HttpClient.
If parser
is null, the loader will attempt to automatically determine the parser to be used from the Content Type header returned by the remote server (or by the file extension if the URI is a local file URI).
If parser
is not null, then this parser will always be used regardless of the Content Type header returned by the remote server.
Events
| Edit this page View SourceStoreWarning
Event which is raised when a store parser that is invoked by the UriLoader notices a non-fatal issue with the RDF dataset syntax
Declaration
public static event StoreReaderWarning StoreWarning
Event Type
Type | Description |
---|---|
StoreReaderWarning |
Warning
Event which is raised when a parser that is invoked by the UriLoader notices a non-fatal issue with the RDF syntax
Declaration
public static event RdfReaderWarning Warning
Event Type
Type | Description |
---|---|
RdfReaderWarning |