Show / Hide Table of Contents

Class NamespaceMapper

Class for representing Mappings between Prefixes and Namespace URIs.

Inheritance
object
NamespaceMapper
QNameOutputMapper
Implements
INamespaceMapper
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: VDS.RDF
Assembly: dotNetRdf.dll
Syntax
public class NamespaceMapper : INamespaceMapper, IDisposable

Constructors

| Edit this page View Source

NamespaceMapper()

Constructs a new Namespace Map.

Declaration
public NamespaceMapper()
Remarks

The Prefixes rdf, rdfs and xsd are automatically defined.

| Edit this page View Source

NamespaceMapper(bool)

Constructs a new Namespace Map which is optionally empty.

Declaration
public NamespaceMapper(bool empty)
Parameters
Type Name Description
bool empty

Whether the Namespace Map should be empty, if set to false the Prefixes rdf, rdfs and xsd are automatically defined.

| Edit this page View Source

NamespaceMapper(INamespaceMapper, IUriFactory)

Constructs a new Namespace Map which is based on an existing map.

Declaration
protected NamespaceMapper(INamespaceMapper nsmapper, IUriFactory uriFactory = null)
Parameters
Type Name Description
INamespaceMapper nsmapper
IUriFactory uriFactory

The factory to use internally when creating new Uri intances. If not specified, defaults to Root.

| Edit this page View Source

NamespaceMapper(IUriFactory, bool)

Constructs a new namespace map with the specified URI factory.

Declaration
public NamespaceMapper(IUriFactory uriFactory, bool empty = false)
Parameters
Type Name Description
IUriFactory uriFactory

The URI factory for the namespace map to use.

bool empty

Whether the namespace map should be empty. If set to false, the prefixes rdf, rdfs and xsd are automatically defined.

Fields

| Edit this page View Source

OWL

Constant Uri for the OWL Namespace.

Declaration
public const string OWL = "http://www.w3.org/2002/07/owl#"
Field Value
Type Description
string
| Edit this page View Source

RDF

Constant Uri for the RDF Namespace.

Declaration
public const string RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
Field Value
Type Description
string
| Edit this page View Source

RDFS

Constant Uri for the RDF Scheme Namespace.

Declaration
public const string RDFS = "http://www.w3.org/2000/01/rdf-schema#"
Field Value
Type Description
string
| Edit this page View Source

XMLSCHEMA

Constant Uri for the XML Scheme Namespace.

Declaration
public const string XMLSCHEMA = "http://www.w3.org/2001/XMLSchema#"
Field Value
Type Description
string
| Edit this page View Source

_prefixes

Mapping of URIs to Prefixes.

Declaration
protected Dictionary<int, List<string>> _prefixes
Field Value
Type Description
Dictionary<int, List<string>>
| Edit this page View Source

_uriFactory

URI factory to use.

Declaration
protected readonly IUriFactory _uriFactory
Field Value
Type Description
IUriFactory
| Edit this page View Source

_uris

Mapping of Prefixes to URIs.

Declaration
protected Dictionary<string, Uri> _uris
Field Value
Type Description
Dictionary<string, Uri>

Properties

| Edit this page View Source

Prefixes

Gets a Enumerator of all the Prefixes.

Declaration
public IEnumerable<string> Prefixes { get; }
Property Value
Type Description
IEnumerable<string>

Methods

| Edit this page View Source

AddNamespace(string, Uri)

Adds a Namespace to the Namespace Map.

Declaration
public virtual void AddNamespace(string prefix, Uri uri)
Parameters
Type Name Description
string prefix

Namespace Prefix.

Uri uri

Namespace Uri.

| Edit this page View Source

Clear()

Clears the Namespace Map.

Declaration
public void Clear()
| Edit this page View Source

DefaultQNameValidationFunction(string)

Provides a default validation function for QNames generated by the ReduceToQName(string, out string, Func<string, bool>) method.

Declaration
public static bool DefaultQNameValidationFunction(string qname)
Parameters
Type Name Description
string qname

The QName to be validated.

Returns
Type Description
bool

False if the QName contains a '#' or '/' character, true otherwise.

| Edit this page View Source

Dispose()

Disposes of a Namespace Map.

Declaration
public void Dispose()
| Edit this page View Source

GetNamespaceUri(string)

Returns the Namespace URI associated with the given Prefix.

Declaration
public virtual Uri GetNamespaceUri(string prefix)
Parameters
Type Name Description
string prefix

The Prefix to lookup the Namespace URI for.

Returns
Type Description
Uri

URI for the Namespace.

| Edit this page View Source

GetPrefix(Uri)

Returns the Prefix associated with the given Namespace URI.

Declaration
public virtual string GetPrefix(Uri uri)
Parameters
Type Name Description
Uri uri

The Namespace URI to lookup the Prefix for.

Returns
Type Description
string

String prefix for the Namespace.

| Edit this page View Source

HasNamespace(string)

Method which checks whether a given Namespace Prefix is defined.

Declaration
public virtual bool HasNamespace(string prefix)
Parameters
Type Name Description
string prefix

Prefix to test.

Returns
Type Description
bool
| Edit this page View Source

HasNamespace(Uri)

Method which checks whether a given Namespace is defined.

Declaration
public virtual bool HasNamespace(Uri ns)
Parameters
Type Name Description
Uri ns

Namespace to test.

Returns
Type Description
bool
| Edit this page View Source

Import(INamespaceMapper)

Imports the contents of another Namespace Map into this Namespace Map.

Declaration
public virtual void Import(INamespaceMapper nsmap)
Parameters
Type Name Description
INamespaceMapper nsmap

Namespace Map to import.

Remarks

Prefixes in the imported Map which are already defined in this Map are ignored, this may change in future releases.

| Edit this page View Source

OnNamespaceAdded(string, Uri)

Internal Helper for the NamespaceAdded Event which raises it only when a Handler is registered.

Declaration
protected virtual void OnNamespaceAdded(string prefix, Uri uri)
Parameters
Type Name Description
string prefix

Namespace Prefix.

Uri uri

Namespace Uri.

| Edit this page View Source

OnNamespaceModified(string, Uri)

Internal Helper for the NamespaceModified Event which raises it only when a Handler is registered.

Declaration
protected virtual void OnNamespaceModified(string prefix, Uri uri)
Parameters
Type Name Description
string prefix

Namespace Prefix.

Uri uri

Namespace Uri.

| Edit this page View Source

OnNamespaceRemoved(string, Uri)

Internal Helper for the NamespaceRemoved Event which raises it only when a Handler is registered.

Declaration
protected virtual void OnNamespaceRemoved(string prefix, Uri uri)
Parameters
Type Name Description
string prefix

Namespace Prefix.

Uri uri

Namespace Uri.

| Edit this page View Source

ReduceToQName(string, out string, Func<string, bool>)

A Function which attempts to reduce a Uri to a QName.

Declaration
public virtual bool ReduceToQName(string uri, out string qname, Func<string, bool> validationFunction = null)
Parameters
Type Name Description
string uri

The Uri to attempt to reduce.

string qname

The value to output the QName to if possible.

Func<string, bool> validationFunction

A validation function to use to validate the QName. Only a QName value for which the validation function return true will be returned.

Returns
Type Description
bool
Remarks

This function will return a Boolean indicated whether it succeeded in reducing the Uri to a QName. If it did then the out parameter qname will contain the reduction, otherwise it will be the empty string.

| Edit this page View Source

RemoveNamespace(string)

Removes a Namespace from the NamespaceMapper.

Declaration
public virtual void RemoveNamespace(string prefix)
Parameters
Type Name Description
string prefix

Namespace Prefix of the Namespace to remove.

Events

| Edit this page View Source

NamespaceAdded

Event which is raised when a Namespace is Added

Declaration
public event NamespaceChanged NamespaceAdded
Event Type
Type Description
NamespaceChanged
| Edit this page View Source

NamespaceModified

Event which is raised when a Namespace is Modified

Declaration
public event NamespaceChanged NamespaceModified
Event Type
Type Description
NamespaceChanged
| Edit this page View Source

NamespaceRemoved

Event which is raised when a Namespace is Removed

Declaration
public event NamespaceChanged NamespaceRemoved
Event Type
Type Description
NamespaceChanged

Implements

INamespaceMapper
IDisposable

Extension Methods

Extensions.ToSafeString(object)
Extensions.AsEnumerable<T>(T)
  • Edit this page
  • View Source
In this article
  • Constructors
    • NamespaceMapper()
    • NamespaceMapper(bool)
    • NamespaceMapper(INamespaceMapper, IUriFactory)
    • NamespaceMapper(IUriFactory, bool)
  • Fields
    • OWL
    • RDF
    • RDFS
    • XMLSCHEMA
    • _prefixes
    • _uriFactory
    • _uris
  • Properties
    • Prefixes
  • Methods
    • AddNamespace(string, Uri)
    • Clear()
    • DefaultQNameValidationFunction(string)
    • Dispose()
    • GetNamespaceUri(string)
    • GetPrefix(Uri)
    • HasNamespace(string)
    • HasNamespace(Uri)
    • Import(INamespaceMapper)
    • OnNamespaceAdded(string, Uri)
    • OnNamespaceModified(string, Uri)
    • OnNamespaceRemoved(string, Uri)
    • ReduceToQName(string, out string, Func<string, bool>)
    • RemoveNamespace(string)
  • Events
    • NamespaceAdded
    • NamespaceModified
    • NamespaceRemoved
  • Implements
  • Extension Methods
Back to top Generated by DocFX