2
URI::NamespaceMap - Class holding a collection of namespaces
9
my $map = URI::NamespaceMap->new( { xsd => 'http://www.w3.org/2001/XMLSchema#' } );
10
$map->namespace_uri('xsd')->as_string;
11
my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' );
12
$map->add_mapping(foaf => $foaf);
13
$map->add_mapping(rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' );
14
$map->list_prefixes; # ( 'foaf', 'rdf', 'xsd' )
17
This module provides an object to manage multiple namespaces for
18
creating URI::Namespace objects and for serializing.
21
"new ( [ \%namespaces ] )"
22
Returns a new namespace map object. You can pass a hash reference
23
with mappings from local names to namespace URIs (given as string or
24
RDF::Trine::Node::Resource) or namespaces_map with a hashref.
26
"add_mapping ( $name => $uri )"
27
Adds a new namespace to the map. The namespace URI can be passed as
28
string or a URI::Namespace object.
30
"remove_mapping ( $name )"
31
Removes a namespace from the map given a prefix.
33
"namespace_uri ( $name )"
34
Returns the namespace object (if any) associated with the given
38
Returns an array of URI::Namespace objects with all the namespaces.
41
Returns an array of prefixes.
43
"uri ( $prefixed_name )"
44
Returns a URI for an abbreviated string such as 'foaf:Person'.
46
prefix_for "uri ($uri)"
47
Returns the associated prefix (or potentially multiple prefixes,
48
when called in list context) for the given URI.
50
abbreviate "uri ($uri)"
51
Complement to "namespace_uri". Returns the given URI in "foo:bar"
52
format or "undef" if it wasn't matched, therefore the idiom
54
my $str = $nsmap->abbreviate($uri_node) || $uri->as_string;
56
may be useful for certain serialization tasks.
59
Avoid using the names 'can', 'isa', 'VERSION', and 'DOES' as namespace
60
prefix, because these names are defined as method for every Perl object
61
by default. The method names 'new' and 'uri' are also forbidden. Names
62
of methods of Moose::Object must also be avoided.
65
Chris Prather, "<chris@prather.org>" Kjetil Kjernsmo,
66
"<kjetilk@cpan.org>" Gregory Todd Williams, "<gwilliams@cpan.org>"
72
Please report any bugs using github
73
<https://github.com/kjetilk/URI-NamespaceMap/issues>
76
You can find documentation for this module with the perldoc command.
78
perldoc URI::NamespaceMap
81
Copyright 2012 Gregory Todd Williams, Chris Prather and Kjetil Kjernsmo
83
This program is free software; you can redistribute it and/or modify it
84
under the same terms as Perl itself.