SemWeb.NamespaceManager

SemWeb : SemWeb Namespace
NamespaceManager Class

A class that maintains a mapping between namespace prefixes and URIs.

public class NamespaceManager

#### Remarks

None.

## Members

See Also: Inherited members from object.

### Constructors

NamespaceManager () Creates a new namespace manager.
NamespaceManager (NamespaceManager) Creates a new namespace manager who will look in another namespace manager when it cannot find a matching prefix or URI.

### Methods

| AddFrom (NamespaceManager) Adds all of the namespace declarations from another NamespaceManager.
| AddNamespace (string, string) Adds a prefix-URI mapping to the table.
| GetNamespace (string) : string Returns the namespace associated with a prefix.
| GetNamespaces () : ICollection Gets all of the namespace URIs known to the namespace manager.
| GetPrefix (string) : string Gets the prefix associated with a namespace URI.
| GetPrefixes () : ICollection Gets all of the prefixes known to the namespace manager.
| Normalize (string) : string Normalizes a URI in N3 format.
| Normalize (string, out string, out string) : bool Splits a URI into a prefix and local name.
| Resolve (string) : string Converts a QName into a full URI.

## Member Details

### NamespaceManager Constructor

public NamespaceManager ()

Creates a new namespace manager.

#### Remarks

None.

### NamespaceManager Constructor

public NamespaceManager (NamespaceManager parent)

Creates a new namespace manager who will look in another namespace manager when it cannot find a matching prefix or URI.

#### Parameters

parent
  Another namespace manager.

#### Remarks

When the new namespace manager cannot find a prefix or URI in its own table, it will consult parent's table.

### AddNamespace Method

public virtual void AddNamespace (string uri, string prefix)

Adds a prefix-URI mapping to the table.

#### Parameters

uri
  A URI.
prefix
  A namespace prefix for the URI.

#### Remarks

If prefix was already used in a call to this method, the previous prefix-to-URI mapping will be overwritten. Likewise, if uri was used before, the previous uri-to-prefix mapping will be overwritten.

### GetNamespace Method

public virtual string GetNamespace (string prefix)

Returns the namespace associated with a prefix.

#### Parameters

prefix
  The prefix to look up.

#### Returns

The corresponding namespace, or `null` if the prefix is not in the table.

#### Remarks

None.

### GetPrefix Method

public virtual string GetPrefix (string uri)

Gets the prefix associated with a namespace URI.

#### Parameters

uri
  A URI.

#### Returns

The prefix associated with this namespace, or `null` if the URI is not associated with a prefix.

#### Remarks

None.

### Normalize Method

public bool Normalize (string uri, out string prefix, out string localname)

Splits a URI into a prefix and local name.

#### Parameters

uri
  The URI to split.
prefix
  This parameter is set to a namespace prefix.
localname
  This parameter is set to a local name.

#### Returns

True if the URI could be split into a prefix and local name, false otherwise.

#### Remarks

None.

### Normalize Method

public string Normalize (string uri)

Normalizes a URI in N3 format.

#### Parameters

uri
  A URI to normalize.

#### Returns

If a namespace matches part of this URI, a QName (prefix:localname) is returned. Otherwise, the URI is returned in angled brackets (<uri>).

#### Remarks

A QName will only be returned if the localname consists only of valid characters for a QName.

### Resolve Method

public string Resolve (string qname)

Converts a QName into a full URI.

#### Parameters

qname
  A QName, e.g. "dc:title."

#### Returns

A URI equivalent to the QName.

#### Remarks

The QName is split on its colon. The prefix and colon are replaced by the namespace corresponding to the prefix. An exception is thrown if the prefix is not known to the namespace manager.

### GetNamespaces Method

public ICollection GetNamespaces ()

Gets all of the namespace URIs known to the namespace manager.

#### Returns

A collection of all namespace URIs known to this namespace manager.

#### Remarks

None.

### GetPrefixes Method

public ICollection GetPrefixes ()

Gets all of the prefixes known to the namespace manager.

#### Returns

A collection of all prefixes known to this namespace manager.

#### Remarks

None.

### AddFrom Method

public void AddFrom (NamespaceManager nsmgr)

Adds all of the namespace declarations from another NamespaceManager.

#### Parameters

nsmgr
  The NamespaceManager to copy the declarations from.

#### Remarks

None.