SemWeb : SemWeb Namespace
RdfReader Class

The base class of types that read statements from streams.

public abstract class RdfReader : StatementSource, IDisposable

Remarks

This is an abstract class. Two subclasses are provided: SemWeb.N3Reader and SemWeb.RdfXmlReader.

RdfReader.LoadFromUri(Uri) can be used to load RDF data, in either N3 or XML format, from a web address.

RdfReader.Create(string, string) can be used to create a reader in the factory paradigm.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.0, 1.0.6.2

Members

See Also: Inherited members from object.

Public Constructors

The protected no-arg constructor used by derived classes.

Public Properties

BaseUri string . The base URI for resolving relative URIs found in the stream. If a base URI is provided within the stream, this property may be updated to indicate the base URI found.
Meta Entity . An entity to assign as the meta entity for statements loaded by this reader.
[read-only]
Namespaces NamespaceManager . Gets the NamespaceManager that contains all of the namespace-prefix mappings used in the input stream.
ReuseEntities bool . Determines whether the reader must reuse Entity objects that it creates.
ValidateLiterals bool . Gets or sets whether literal values should be validated. If set, warnings are issued for invalid literal values.
[read-only]
Variables ICollection<Variable> . A list of SemWeb.Variables found in the stream.
[read-only]
Warnings ICollection<string> . Gets a list of warnings generated while parsing the input stream.

Public Methods

static
Create (string, System.IO.Stream) : RdfReader
Creates a RdfReader in the factory paradigm for the given Stream.
static
Create (string, string) : RdfReader
Creates a RdfReader in the factory paradigm for the given file.
static
LoadFromUri (Uri) : RdfReader
Loads an RDF document from the Internet.
abstract
Select (StatementSink)
Reads the stream into the statement sink.

Protected Methods

AddVariable (Variable)
Adds a Variable to the Variables collection.
Dispose ()
Disposes the reader.
OnWarning (string)
Implementors of RdfReader may call this method to indicate a parsing warning.
ValidateLiteral (Literal)
If ValidateLiterals is true, checks that the literal's value is in the value space of the literal's datatype, if recognized, and issues a warning if not.

Explicitly Implemented Interface Members

IDisposable.Dispose Documentation for this section has not yet been entered.
[read-only]
SemWeb.StatementSource.Distinct bool . Documentation for this section has not yet been entered.

Member Details

RdfReader Constructor

The protected no-arg constructor used by derived classes.

public RdfReader ()

Remarks

None.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

AddVariable Method

Adds a Variable to the Variables collection.

protected void AddVariable (Variable variable)

Parameters

variable
A variable.

Remarks

Used by RdfReader implementations to add a variable into the Variables collection.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

BaseUri Property

The base URI for resolving relative URIs found in the stream. If a base URI is provided within the stream, this property may be updated to indicate the base URI found.

public string BaseUri { set; get; }

Value

The base URI for resolving relative URIs found in the stream. May be, and is initially, null.

Remarks

When this property is null, the reader will not correctly resolve relative URIs in the stream. Always set this property before beginning reading when the base URI of the document is known.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Create Method

Creates a RdfReader in the factory paradigm for the given Stream.

public static RdfReader Create (string type, System.IO.Stream source)

Parameters

type
The stream type.
source
A stream to read from.

Returns

The type of reader returned is given in the following table.

type Reader
"xml", "text/xml", "application/xml", "application/rdf+xml" SemWeb.RdfXmlReader
"n3", "text/n3", "text/rdf+n3", "application/n3", "turtle", "text/turtle", "application/turtle", "application/x-turtle", "nt", "ntriples" SemWeb.N3Reader

Remarks

None.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Create Method

Creates a RdfReader in the factory paradigm for the given file.

public static RdfReader Create (string type, string source)

Parameters

type
The stream type.
source
The name of the source stream, as a file name, or "-" for standard input.

Returns

The type of reader returned is given in the following table.

type Reader
"xml", "text/xml", "application/xml", "application/rdf+xml" SemWeb.RdfXmlReader
"n3", "text/n3", "text/rdf+n3", "application/n3", "turtle", "text/turtle", "application/turtle", "application/x-turtle", "nt", "ntriples" SemWeb.N3Reader

Remarks

None.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Dispose Method

Disposes the reader.

protected virtual void Dispose ()

Remarks

The resources associated with the reader are freed.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

LoadFromUri Method

Loads an RDF document from the Internet.

public static RdfReader LoadFromUri (Uri webresource)

Parameters

webresource
The URI of the RDF document.

Returns

An RdfReader over the remote document.

Remarks

The document is fetched with System.Net.WebRequest and must be in RDF/XML or Notation3 (NTriples/Turtle/N3) format.

The format of the document is detected as follows. If the document has a mime-type of text/xml, application/xml, application/rss+xml, or application/rdf+xml, the document is treated as an RDF/XML document. If the document has a mime-type of text/rdf+n3, application/n3, application/turtle, or application/x-turtle, the document is treated as a Notation3 document. If the mime-type is not recognized, the document's file name extension is checked. If it is .xml or .rss, it is treated as an RDF/XML document. If it is .n3, .ttl, or .nt, it is treated as a Notation3 document.

If the format could not be determined, a InvalidOperationException is thrown.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Meta Property

An entity to assign as the meta entity for statements loaded by this reader.

public Entity Meta { set; get; }

Value

An entity to use for meta information. Cannot be null.

Remarks

The value of this property is used as the meta argument in calls to the Statement constructor Statement(Entity, Entity, Resource, Entity). The use of Statement.Meta is up to the application.

The default value of this property is Statement.DefaultMeta, which is also the meta value used in the three-arg constructor for SemWeb.Statement. If the meta field is not important for the application, this field should be left unchanged.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Namespaces Property

Gets the NamespaceManager that contains all of the namespace-prefix mappings used in the input stream.

public NamespaceManager Namespaces { get; }

Value

A NamespaceManager that contains all of the namespace-prefix mappings used in the input stream.

Remarks

None.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

OnWarning Method

Implementors of RdfReader may call this method to indicate a parsing warning.

protected void OnWarning (string message)

Parameters

message
A warning message.

Remarks

This is not currently used for anything.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

ReuseEntities Property

Determines whether the reader must reuse Entity objects that it creates.

public bool ReuseEntities { set; get; }

Value

If false (the default), the reader may create a new Entity object each time an entity is encoutered in the stream. If true, the reader must return the same Entity object each time it encounters a reference to the same entity.

Remarks

Setting this property to true may slow down the performance of the reader, as it may need to consult a hashtable each time a URI is read mapping the URI to an Entity it has previously created.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Select Method

Reads the stream into the statement sink.

public abstract void Select (StatementSink sink)

Parameters

sink
Each statement found in the stream is added to the statement sink via StatementSink.Add(Statement).

Remarks

User code should call Store.Import(StatementSource) rather than calling this method directly.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

SemWeb.StatementSource.Distinct Property

Documentation for this section has not yet been entered.

bool SemWeb.StatementSource.Distinct { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

System.IDisposable.Dispose Method

Documentation for this section has not yet been entered.

void System.IDisposable.Dispose ()

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

ValidateLiteral Method

If ValidateLiterals is true, checks that the literal's value is in the value space of the literal's datatype, if recognized, and issues a warning if not.

protected void ValidateLiteral (Literal literal)

Parameters

literal
A literal whose lexical value is to be checked.

Remarks

Nothing happens if RdfReader.ValidateLiterals is false. If it is true, Literal.ParseValue is called. Any FormatException raised is recorded as a warning (see RdfReader.Warnings).

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

ValidateLiterals Property

Gets or sets whether literal values should be validated. If set, warnings are issued for invalid literal values.

public bool ValidateLiterals { set; get; }

Value

Whether warnings should be issued for literals of recognized datatypes with invalid lexical values.

Remarks

The recognized datatypes are those listed in Literal.ParseValue. (See RdfReader.Warnings.)

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Variables Property

A list of SemWeb.Variables found in the stream.

public ICollection<Variable> Variables { get; }

Value

A list of SemWeb.Variables found in the stream.

Remarks

Not all readers support variables. (N3-formatted RDF does, but XML formatted RDF doesn't.)

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2

Warnings Property

Gets a list of warnings generated while parsing the input stream.

public ICollection<string> Warnings { get; }

Value

A list of warnings generated while parsing the input stream. Each element of the list is a string.

Remarks

None.

Requirements

Namespace: SemWeb
Assembly: SemWeb (in SemWeb.dll)
Assembly Versions: 1.0.6.2