Class

EasyRdf_Namespace

class EasyRdf_Namespace

A namespace registry and manipulation class.

Methods

static array namespaces()

Return all the namespaces registered

static string get(string $prefix)

Return a namespace given its prefix.

static  set(string $prefix, string $long)

Register a new namespace.

static string getDefault()

Get the default namespace

static  setDefault(string $namespace)

Set the default namespace

static  delete(string $prefix)

Delete an existing namespace.

static  reset()

Delete the anonymous namespaces and reset the counter to 0

static array splitUri(string $uri, bool $createNamespace = false)

Try and breakup a URI into a prefix and local part

static string prefixOfUri(string $uri)

Return the prefix namespace that a URI belongs to.

static string shorten(string $uri, bool $createNamespace = false)

Shorten a URI by substituting in the namespace prefix.

static string expand(string $shortUri)

Expand a shortened URI (qname) back into a full URI.

Details

at line 105
static public array namespaces()

Return all the namespaces registered

Return Value

array Associative array of all the namespaces.

at line 116
static public string get(string $prefix)

Return a namespace given its prefix.

Parameters

string $prefix The namespace prefix (eg 'foaf')

Return Value

string The namespace URI (eg 'http://xmlns.com/foaf/0.1/')

at line 144
static public set(string $prefix, string $long)

Register a new namespace.

Parameters

string $prefix The namespace prefix (eg 'foaf')
string $long The namespace URI (eg 'http://xmlns.com/foaf/0.1/')

at line 176
static public string getDefault()

Get the default namespace

Returns the URI of the default namespace or null if no default namespace is defined.

Return Value

string The URI of the default namespace

at line 192
static public setDefault(string $namespace)

Set the default namespace

Set the default namespace to either a URI or the prefix of an already defined namespace.

Example: EasyRdf_Namespace::setDefault('http://schema.org/');

Parameters

string $namespace The URI or prefix of a namespace (eg 'og')

at line 214
static public delete(string $prefix)

Delete an existing namespace.

Parameters

string $prefix The namespace prefix (eg 'foaf')

at line 231
static public reset()

Delete the anonymous namespaces and reset the counter to 0

at line 252
static public array splitUri(string $uri, bool $createNamespace = false)

Try and breakup a URI into a prefix and local part

If $createNamespace is true, and the URI isn't part of an existing namespace, then EasyRdf will attempt to create a new namespace and return the name of the new prefix (for example 'ns0', 'term').

If it isn't possible to split the URI, then null will be returned.

Parameters

string $uri The full URI (eg 'http://xmlns.com/foaf/0.1/name')
bool $createNamespace If true, a new namespace will be created

Return Value

array The split URI (eg 'foaf', 'name') or null

at line 293
static public string prefixOfUri(string $uri)

Return the prefix namespace that a URI belongs to.

Parameters

string $uri A full URI (eg 'http://xmlns.com/foaf/0.1/name')

Return Value

string The prefix namespace that it is a part of(eg 'foaf')

at line 313
static public string shorten(string $uri, bool $createNamespace = false)

Shorten a URI by substituting in the namespace prefix.

If $createNamespace is true, and the URI isn't part of an existing namespace, then EasyRdf will attempt to create a new namespace and use that namespace to shorten the URI (for example ns0:term).

If it isn't possible to shorten the URI, then null will be returned.

Parameters

string $uri The full URI (eg 'http://xmlns.com/foaf/0.1/name')
bool $createNamespace If true, a new namespace will be created

Return Value

string The shortened URI (eg 'foaf:name') or null

at line 329
static public string expand(string $shortUri)

Expand a shortened URI (qname) back into a full URI.

If it isn't possible to expand the qname, for example if the namespace isn't registered, then the original string will be returned.

Parameters

string $shortUri The short URI (eg 'foaf:name')

Return Value

string The full URI (eg 'http://xmlns.com/foaf/0.1/name')