SemWeb.RdfWriter

SemWeb : SemWeb Namespace
RdfWriter Class

The base class of types that write statements to a stream.

public abstract class RdfWriter : StatementSink, IDisposable

#### Remarks

This is an abstract class. Two subclasses are provided: SemWeb.N3Writer and SemWeb.RdfXmlWriter.

## Members

See Also: Inherited members from object.

### Protected Constructors

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

### Properties

BaseUri | string . Gets or sets the base URI for the output document.
Namespaces [read-only] abstract | NamespaceManager . The NamespaceManager that manages namespace URIs and their prefixes.

### Methods

abstract | Add (Statement) Writes a statement to the stream.
| Close () Completes writing the data and closes the stream.
static | Create (string, System.IO.TextWriter) : RdfWriter Creates a new RdfWriter whose type is specified by a string constant.
static | Create (string, string) : RdfWriter Creates a new RdfWriter whose type is specified by a string constant.
| Write (StatementSource) Writes out the contents of the StatementSource.

### Protected Methods

| GetResourceKey (Resource) : object See SemWeb.Store.GetResourceKey(SemWeb.Resource).
| SetResourceKey (Resource, object) See SemWeb.Store.SetResourceKey(SemWeb.Resource).

## Member Details

### RdfWriter Constructor

protected RdfWriter ()

The protected no-arg constructor used by derived classes.

#### Remarks

None.

### Add Method

public abstract void Add (Statement statement)

Writes a statement to the stream.

#### Parameters

statement
  The statement to write.

#### Remarks

None.

### Close Method

public virtual void Close ()

Completes writing the data and closes the stream.

#### Remarks

None.

### Namespaces Property

public abstract NamespaceManager Namespaces { get; }

The NamespaceManager that manages namespace URIs and their prefixes.

#### Value

A NamespaceManager.

#### Remarks

For some parsers, it is necessary to give a prefix for all namespaces that occur in the data model being written before the writing begins.

### BaseUri Property

public string BaseUri { set; get; }

Gets or sets the base URI for the output document.

#### Value

A string containing the base URI of the output document, or `null` if the output document base URI is unknown or not applicable.

#### Remarks

A writer may choose to abbreviate URIs in the output according to the base URI.

### GetResourceKey Method

protected object GetResourceKey (Resource resource)

See SemWeb.Store.GetResourceKey(SemWeb.Resource).

#### Parameters

resource
  A resource.

#### Returns

A resource key associated with the resource and this writer.

#### Remarks

See SemWeb.Store.GetResourceKey(SemWeb.Resource).

### SetResourceKey Method

protected void SetResourceKey (Resource resource, object value)

See SemWeb.Store.SetResourceKey(SemWeb.Resource).

#### Parameters

resource
  A resource.
value
  A key to associate with the resource and the writer.

#### Remarks

See SemWeb.Store.SetResourceKey(SemWeb.Resource).

### Write Method

public virtual void Write (StatementSource source)

Writes out the contents of the StatementSource.

#### Parameters

source
  A source containing statements to write.

#### Remarks

None.

### Create Method

public static RdfWriter Create (string type, System.IO.TextWriter output)

Creates a new RdfWriter whose type is specified by a string constant.

#### Parameters

type
  The type of the writer to create. See below for possible values.
output
  A TextWriter to output to.

#### Returns

A new RdfWriter.

#### Remarks

The possible values for type are:

type | Reader
--- | ---
"xml", "text/xml", "application/xml", "application/rdf+xml" | SemWeb.RdfXmlWriter
"n3", "text/n3", "application/n3", "application/turtle", "application/x-turtle" | SemWeb.N3Writer

### Create Method

public static RdfWriter Create (string type, string file)

Creates a new RdfWriter whose type is specified by a string constant.

#### Parameters

type
  The type of the writer to create. See below for possible values.
file
  The name of a file to output to, or "-" to output to Standard Output.

#### Returns

A new RdfWriter.

#### Remarks

The possible values for type are listed in the Remarks section of SemWeb.RdfWriter.Create(System.String,System.IO.TextWriter)