Class FileLoader
Static Helper Class for loading RDF Files into Graphs/Triple Stores.
Inheritance
Inherited Members
Namespace: VDS.RDF.Parsing
Assembly: dotNetRdf.dll
Syntax
public static class FileLoader
Methods
| Improve this Doc View SourceLoad(IGraph, string, IRdfReader)
Loads the contents of the given File into a Graph using the given RDF Parser.
Declaration
public static void Load(IGraph g, string filename, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | filename | File to load from. |
IRdfReader | parser | Parser to use. |
Remarks
Note: FileLoader will assign the Graph a file URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
If a File URI is assigned it will always be an absolute URI for the file.
Load(IGraph, string)
Loads the contents of the given File into a Graph providing the RDF format can be determined.
Declaration
public static void Load(IGraph g, string filename)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | filename | File to load from. |
Remarks
The FileLoader first attempts to select a RDF Parser by examining the file extension to select the most likely MIME type for the file. This assumes that the file extension corresponds to one of the recognized file extensions for a RDF format the library supports. If this suceeds then a parser is chosen and will be used to attempt to parse the input.
Should this fail then the contents of the file will be read into a String, the StringParser is then used to attempt to parse it. The StringParser uses some simple rules to guess which format the input is likely to be and chooses a parser based on it's guess.
Note: FileLoader will assign the Graph a file URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
If a File URI is assigned it will always be an absolute URI for the file.
Load(IRdfHandler, string, IRdfReader)
Loads the contents of the given File using a RDF Handler using the given RDF Parser.
Declaration
public static void Load(IRdfHandler handler, string filename, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
string | filename | File to load from. |
IRdfReader | parser | Parser to use. |
Remarks
Note: FileLoader will assign the Graph a file URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
If a File URI is assigned it will always be an absolute URI for the file.
Load(IRdfHandler, string, IStoreReader)
Loads the contents of the given File using a RDF Handler providing the RDF dataset format can be determined.
Declaration
public static void Load(IRdfHandler handler, string filename, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
string | filename | File to load from. |
IStoreReader | parser | Parser to use to parse the given file. |
Remarks
If the parser
parameter is set to null then the FileLoader attempts to select a Store Parser by examining the file extension to select the most likely MIME type for the file. This assume that the file extension corresponds to one of the recognized file extensions for a RDF dataset format the library supports. If this suceeds then a parser is chosen and used to parse the input file.
Load(IRdfHandler, string)
Loads the contents of the given File using a RDF Handler providing the RDF format can be determined.
Declaration
public static void Load(IRdfHandler handler, string filename)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
string | filename | File to load from. |
Remarks
The FileLoader first attempts to select a RDF Parser by examining the file extension to select the most likely MIME type for the file. This assumes that the file extension corresponds to one of the recognized file extensions for a RDF format the library supports. If this suceeds then a parser is chosen and will be used to attempt to parse the input.
Should this fail then the contents of the file will be read into a String, the StringParser is then used to attempt to parse it. The StringParser uses some simple rules to guess which format the input is likely to be and chooses a parser based on it's guess.
Load(ITripleStore, string, IStoreReader)
Loads the contents of the given File into a Triple Store providing the RDF dataset format can be determined.
Declaration
public static void Load(ITripleStore store, string filename, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
string | filename | File to load from. |
IStoreReader | parser | Parser to use to parse the given file. |
Remarks
If the parser
parameter is set to null then the FileLoader attempts to select a Store Parser by examining the file extension to select the most likely MIME type for the file. This assume that the file extension corresponds to one of the recognized file extensions for a RDF dataset format the library supports. If this suceeds then a parser is chosen and used to parse the input file.
Load(ITripleStore, string)
Loads the contents of the given File into a Triple Store providing the RDF dataset format can be determined.
Declaration
public static void Load(ITripleStore store, string filename)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
string | filename | File to load from. |
Remarks
The FileLoader attempts to select a Store Parser by examining the file extension to select the most likely MIME type for the file. This assume that the file extension corresponds to one of the recognized file extensions for a RDF dataset format the library supports. If this suceeds then a parser is chosen and used to parse the input file.
LoadDataset(IRdfHandler, string)
Loads the contents of the given File using a RDF Handler providing the RDF dataset format can be determined.
Declaration
public static void LoadDataset(IRdfHandler handler, string filename)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
string | filename | File to load from. |
Remarks
The FileLoader attempts to select a Store Parser by examining the file extension to select the most likely MIME type for the file. This assume that the file extension corresponds to one of the recognized file extensions for a RDF dataset format the library supports. If this suceeds then a parser is chosen and used to parse the input file.
Events
| Improve this Doc View SourceStoreWarning
Event which is raised when the Store parser invoked by the FileLoader detects a non-fatal issue with the RDF syntax
Declaration
public static event StoreReaderWarning StoreWarning
Event Type
Type | Description |
---|---|
StoreReaderWarning |
Warning
Event which is raised when the parser invoked by the FileLoader detects a non-fatal issue with the RDF syntax
Declaration
public static event RdfReaderWarning Warning
Event Type
Type | Description |
---|---|
RdfReaderWarning |