sgvizler.namespace Class
Static class for handling prefixes and namespaces. Use for storing prefixes used in SPARQL queries and for formatting result sets, i.e., replacing namespaces with prefixes, which many chart functions automatically do.
Already defined prefixes are rdf
, rdfs
, owl
and xsd
.
Dependencies:
- sgvizler.util
Item Index
Methods
get
-
prefix
Get a namespace.
See also set.
Parameters:
-
prefix
StringThe prefix to get the namespace for.
Returns:
The namespace set for 'prefix'; undefined if 'prefix' does not exist.
Example:
get('xsd'); // returns "http://www.w3.org/2001/XMLSchema#"
getBaseURL
()
String
protected
Get Base URL value.
See also setBaseURL.
Returns:
The base URL.
getBaseURL
-
url
Set Base URL value.
See also setBaseURL.
Parameters:
-
url
StringThe base URL.
prefixesSPARQL
()
String
protected
Get all prefixes in SPARQL format.
Returns:
An SPARQL formatted prefix declaration text block containing all set prefixes.
prefixify
-
url
Replace a namespace with its prefix, for string which starts with a namespace. Typically used for URLs of resources.
Leaves other strings untouched.
See also unprefixify.
Parameters:
-
url
String
Returns:
Example:
prefixify("http://www.w3.org/2002/07/owl#Class"); // returns "owl:Class"
prefixify("Hello World!"); // returns "Hello World!"
set
-
prefix
-
namespace
Set a namespace.
See also get.
Example:
set('foaf', "http://xmlns.com/foaf/0.1/");
sets 'foaf'
as prefix for the FOAF namespace.
unprefixify
-
qname
Replace a prefix with its namespace, for string which starts with a prefix: Typically used for prefixed URLs (QNames) of resources.
Leaves other strings untouched.
See also prefixify.
Parameters:
-
qname
String
Returns:
Example:
unprefixify("owl:Class"); // returns "http://www.w3.org/2002/07/owl#Class"
unprefixify("Hello World!"); // returns "Hello World!"