SemWeb.RdfXmlReader

SemWeb : SemWeb Namespace
RdfXmlReader Class

Reads RDF statements from an RDF/XML file.

public class RdfXmlReader : RdfReader

#### Remarks

The RdfXmlReader streams the statements to the StatementSink as they are read from the XML stream. The entire XML document will not be loaded into memory.

The following example reads a RDF/XML file from disk:

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

It is strongly recommended that you use one of the constructors that takes a Base URI argument, or else set the Base URI of the reader before reading statements from it, so that relative URIs found in the document can be interpreted. If a BaseURI has not been set and a relative URI is encountered, parsing the document will fail.

The stream is begun to be read as soon as the constructor is called. Any namespace declarations found on the document element of the RDF/XML document will be available in the SemWeb.RdfXmlReader.Namespaces property once the constructor returns. 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

RdfXmlReader (System.IO.Stream) Creates a parser from a stream.
RdfXmlReader (System.IO.TextReader) Creates a parser from a TextReader.
RdfXmlReader (string) Creates a parser for a file.
RdfXmlReader (System.Xml.XmlDocument) Creates a parser for an XML document already loaded.
RdfXmlReader (System.Xml.XmlReader) Creates a parser for an XmlReader.
RdfXmlReader (System.IO.Stream, string) Creates a parser from a stream with the given base URI.
RdfXmlReader (System.IO.TextReader, string) Creates a parser from a TextReader with the given base URI.
RdfXmlReader (string, string) Creates a parser from a file with the given base URI.

### 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

### RdfXmlReader Constructor

public RdfXmlReader (System.Xml.XmlDocument document)

Creates a parser for an XML document already loaded.

#### Parameters

document
  The RDF/XML document.

#### Remarks

None.

### RdfXmlReader Constructor

public RdfXmlReader (System.Xml.XmlReader document)

Creates a parser for an XmlReader.

#### Parameters

document
  A stream containing the RDF/XML file.

#### Remarks

None.

### RdfXmlReader Constructor

public RdfXmlReader (System.IO.TextReader document)

Creates a parser from a TextReader.

#### Parameters

document
  The stream containing the RDF/XML file.

#### Remarks

None.

### RdfXmlReader Constructor

public RdfXmlReader (System.IO.Stream document)

Creates a parser from a stream.

#### Parameters

document
  The stream containing the RDF/XML file.

#### Remarks

None.

### RdfXmlReader Constructor

public RdfXmlReader (string file)

Creates a parser for a file.

#### Parameters

file
  The path of the file containing RDF/XML, or "-" to read from Console.In.

#### Remarks

None.

### RdfXmlReader Constructor

public RdfXmlReader (System.IO.TextReader document, string baseUri)

Creates a parser from a TextReader with the given base URI.

#### Parameters

document
  A TextReader containing the RDF/XML document.
baseUri
  The URI of the document itself, to be taken as the Base URI for relative URIs encoutered in the document.

#### Remarks

None.

### RdfXmlReader Constructor

public RdfXmlReader (System.IO.Stream document, string baseUri)

Creates a parser from a stream with the given base URI.

#### Parameters

document
  The stream containing the RDF/XML file.
baseUri
  The URI of the document itself, to be taken as the Base URI for relative URIs encoutered in the document.

#### Remarks

None.

### RdfXmlReader Constructor

public RdfXmlReader (string file, string baseUri)

Creates a parser from a file with the given base URI.

#### Parameters

file
  The path of the file containing RDF/XML, or "-" to read from Console.In.
baseUri
  The URI of the document itself, to be taken as the Base URI for relative URIs encoutered in the document.

#### Remarks

None.