You are here

public static function EasyRdf_Namespace::shorten in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php \EasyRdf_Namespace::shorten()

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

11 calls to EasyRdf_Namespace::shorten()
EasyRdf_Graph::dumpResource in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Return a human readable view of a resource and its properties
EasyRdf_Graph::properties in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get a list of all the shortened property names (qnames) for a resource.
EasyRdf_Graph::type in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get the resource type of the graph
EasyRdf_Graph::types in vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Get a list of types for a resource
EasyRdf_Literal::getDatatype in vendor/easyrdf/easyrdf/lib/EasyRdf/Literal.php
Returns the shortened datatype URI of the literal.

... See full list

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Namespace.php, line 378

Class

EasyRdf_Namespace
A namespace registry and manipulation class.

Code

public static function shorten($uri, $createNamespace = false) {
  if ($parts = self::splitUri($uri, $createNamespace)) {
    return implode(':', $parts);
  }
}