SemWeb.RdfParser

SemWeb : SemWeb Namespace
RdfParser

The base class of types that read statements from streams.

public abstract class RdfParser : IDisposable

Remarks
This is an abstract class. See the classes in SemWeb.IO for implementations of parsers.
Members

See Also: Inherited members from object.

Protected Constructors

RdfParser () The protected no-arg constructor used by derived classes.

Properties

BaseUri | string . The base URI for resolving relative URIs found in the stream.
Meta | Entity . An entity to assign as the meta entity for statements loaded by this parser.
Variables [read-only] | ICollection . A list of SemWeb.Entity objects found in the strem that were marked as being variables (e.g. for queries).

Methods

static | Create (string, string) : RdfParser Creates a parser in the factory paradigm.
| Dispose () Disposes the parser.
abstract | Parse (StatementSinkEx) Parses the stream into the statement sink.

Protected Methods

| AddVariable (Entity) Called by parser implementations to indicate that the entity was marked in the stream as being a variable for a query.
| OnWarning (string) Implementors of RdfParser may call this method to indicate a parsing warning.

Member Details
RdfParser Constructor
protected RdfParser ()

The protected no-arg constructor used by derived classes.

Remarks
None.

Dispose
public virtual void Dispose ()

Disposes the parser.

Remarks
The resources associated with the parser are freed.

Create
public static RdfParser Create (string type, string source)

Creates a parser in the factory paradigm.

Parameters

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

Returns

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

type | Parser
--- | ---
"xml" or "text/xml" | SemWeb.IO.RdfXmlParser
"n3" or "text/n3" | SemWeb.IO.N3Parser

Remarks
None.

Meta
public Entity Meta { set; get; }

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

Value
An entity to use for meta information, or `null`.
Remarks
The value of this property is used as the meta argument in calls to SemWeb.Statement(SemWeb.Entity,SemWeb.Entity,SemWeb.Resource,SemWeb.Entity). The use of SemWeb.Statement.Meta is up to the application.

BaseUri
public string BaseUri { set; get; }

The base URI for resolving relative URIs found in the stream.

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 parser may not be able to parse streams containing relative URIs.

OnWarning
protected void OnWarning (string message)

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

Parameters

message
  A warning message.

Remarks
This is not currently used for anything.

Variables
public ICollection Variables { get; }

A list of SemWeb.Entity objects found in the strem that were marked as being variables (e.g. for queries).

Value
A list of SemWeb.Entity objects found in the strem that were marked as being variables (e.g. for queries).
Remarks
The list of variables is set by the parser implementation. Not all parsers support variables. (N3-formatted RDF does, but XML formatted RDF doesn't.)

Parse
public abstract void Parse (StatementSinkEx storage)

Parses the stream into the statement sink.

Parameters

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

Remarks
User code should call SemWeb.Store.Import(SemWeb.RdfParser) rather than calling this method directly.

AddVariable
protected void AddVariable (Entity variable)

Called by parser implementations to indicate that the entity was marked in the stream as being a variable for a query.

Parameters

variable
  An entity that was marked as being a variable.

Remarks
None.