SemWeb : SemWeb Namespace
N3Reader Class

Reads RDF statements from a Notation 3 (N3, Turtle, or NTriples) stream.

public class N3Reader : RdfReader


Remarks

Most of the N3 specification is supported, including everything in NTriples and Turtle. Statements are streamed as soon as they are read from the stream.

N3 formula notation with { and } is supported in the following way. For every formula, an anonymous entity is created to represent that graph. Every statement in the formula is imported with the SemWeb.Statement.Meta property set to the anonymous entity (unless it is recursively embedded in another formula, in which case it uses the innermost formula's anonymous entity).

The following example reads a N-Triples, Turtle, or N3 file from disk:

C# Example
using (RdfReader data = new N3Reader("filename.n3")) {
    store.Import(data);
}  

Once the document is fully read, all namespace declarations in the document are available in the SemWeb.RdfReader.Namespaces property and can be copied into the namespace manager of a SemWeb.RdfWriter using the SemWeb.NamespaceManager.AddFrom(SemWeb.NamespaceManager) method.

Members

See Also: Inherited members from RdfReader.

Constructors

Creates a new N3 parser for a stream.
Creates a new N3 parser for the given file.

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. (Inherited from RdfReader.)
Meta
Entity . An entity to assign as the meta entity for statements loaded by this reader. (Inherited from RdfReader.)
Namespaces [read-only]
NamespaceManager . Gets the NamespaceManager that contains all of the namespace-prefix mappings used in the input stream. (Inherited from RdfReader.)
ReuseEntities
bool . Determines whether the reader must reuse Entity objects that it creates. (Inherited from RdfReader.)
Variables [read-only]
System.Collections.Generic.ICollection<SemWeb.Variable> . A list of SemWeb.Variables found in the stream. (Inherited from RdfReader.)
Warnings [read-only]
System.Collections.Generic.ICollection<System.String> . Gets a list of warnings generated while parsing the input stream. (Inherited from RdfReader.)

Methods

Dispose ()
Disposes the reader. (Inherited from RdfReader.)
abstract Select (StatementSink)
Reads the stream into the statement sink. (Inherited from RdfReader.)

Protected Methods

AddVariable (Variable)
Adds a Variable to the Variables collection. (Inherited from RdfReader.)
OnWarning (string)
Implementors of RdfReader may call this method to indicate a parsing warning. (Inherited from RdfReader.)

Member Details

N3Reader Constructor

public N3Reader (System.IO.TextReader source)

Creates a new N3 parser for a stream.

Parameters

source
The N3 stream to read.

Remarks

None.

N3Reader Constructor

public N3Reader (string sourcefile)

Creates a new N3 parser for the given file.

Parameters

sourcefile
The name of a file, or "-" to read from Console.In.

Remarks

None.