URI::N...paceMap(3pm)
๐ URI::NamespaceMap ๐
okay so bestie, welcome to URI::NamespaceMap โ it's a Perl module (a User Contributed Perl Documentation situation, iykyk) and it's literally just a class that holds a whole collection of namespaces. like a little friend group of namespaces. a group chat, if you will. ๐ซถ
โจ VERSION โจ
Version 1.12 โ she's grown, she's evolved, she's serving. ๐
๐ธ SYNOPSIS ๐ธ
here's the vibe, no cap:
use URI::NamespaceMap;
my $map = URI::NamespaceMap->new( { xsd => 'http://www.w3.org/2001/XMLSchema#' } );
$map->namespace_uri('xsd')->as_string;
my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' );
$map->add_mapping(foaf => $foaf);
$map->add_mapping(rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' );
$map->list_prefixes; # ( 'foaf', 'rdf', 'xsd' )
$map->foaf; # Returns URI::Namespace object
while (my ($prefix, $nsURI) = $map->each_map) {
$node->setNamespace($nsURI->as_string, $prefix); # For use with XML::LibXML
}
look at her go. main character energy fr. ๐
๐ฆ DESCRIPTION ๐ฆ
This module provides an object to manage multiple namespaces for creating URI::Namespace objects and for serializing.
that's it. that's the whole thing. she manages your namespaces so you don't have to, and then she serializes. iconic behaviour honestly. โจ
๐ METHODS ๐
new ( [ \%namespaces | @prefixes | @uris ] )
Returns a new namespace map object. You can pass a hash reference with mappings from local names to namespace URIs (given as string or RDF::Trine::Node::Resource) or namespaces_map with a hashref.
You may also pass an arrayref containing just prefixes and/or namespace URIs, and the module will try to guess the missing part. To use this feature, you need RDF::NS::Curated, RDF::NS, XML::CommonNS or RDF::Prefixes, or preferably all of them. With that, you can do e.g.
my $map = URI::NamespaceMap->new( 'rdf', 'xsd', 'foaf' );
and have the correct mappings added automatically. the guessing?? the slay?? ๐ง
add_mapping ( $name => $uri )
Adds a new namespace to the map. The namespace URI can be passed as string or a URI::Namespace object.
remove_mapping ( $name )
Removes a namespace from the map given a prefix. bye bestie ๐๐
namespace_uri ( $name )
Returns the URI::Namespace object (if any) associated with the given prefix.
$name
This module creates a method for all the prefixes, so you can say e.g.
$map->foaf
and get a URI::Namespace object for the FOAF namespace. Since URI::Namespace does the same for local names, you can then say e.g.
$map->foaf->name
to get a full URI. chain them like jewellery, bestie ๐
list_namespaces
Returns an array of URI::Namespace objects with all the namespaces.
list_prefixes
Returns an array of prefixes.
each_map
Returns an 2-element list where the first element is a prefix and the second is the corresponding URI::Namespace object.
guess_and_add ( @string_or_uri )
Like in the constructor, an array of strings can be given, and the module will attempt to guess appropriate mappings, and add them to the map. ๐ฎ
uri ( $prefixed_name )
Returns a URI for an abbreviated string such as 'foaf:Person'.
prefix_for "uri ($uri)"
Returns the associated prefix (or potentially multiple prefixes, when called in list context) for the given URI.
abbreviate "uri ($uri)"
Complement to "namespace_uri". Returns the given URI in "foo:bar" format or "undef" if it wasn't matched, therefore the idiom
my $str = $nsmap->abbreviate($uri_node) || $uri->as_string;
may be useful for certain serialization tasks. that || fallback?? chef's kiss, ate and left no crumbs ๐ญ
โ ๏ธ WARNING โ ๏ธ
Avoid using the names'can','isa','VERSION', and'DOES'as namespace prefix, because these names are defined as method for every Perl object by default. The method names'new'and'uri'are also forbidden. Names of methods ofMoose::Objectmust also be avoided.
Using them will result in an error. ๐จ do NOT do this. like actually do not. it will break and it will be your fault and we will all see it. ๐
๐ AUTHORS ๐
Chris Prather, "<chris@prather.org>" Kjetil Kjernsmo, "<kjetilk@cpan.org>" Gregory Todd Williams, "<gwilliams@cpan.org>" Toby Inkster, "<tobyink@cpan.org>"
the founding mothers and fathers of this whole operation. legends only. ๐
๐ซถ CONTRIBUTORS ๐ซถ
Dorian Taylor Paul Williams Zakariyya Mughal Chris Prather
the supporting cast, the ensemble, the ones who carried. ๐ฌ
๐ BUGS ๐
Please report any bugs using github <https://github.com/kjetilk/URI-NamespaceMap/issues>
not me asking you to file an issue... but like, fr fr, please do. ๐ฅบ
๐ SUPPORT ๐
You can find documentation for this module with the perldoc command.
perldoc URI::NamespaceMap
go read it. it's right there. it's free. ๐
๐ COPYRIGHT & LICENSE ๐
Copyright 2012,2013,2014,2015,2016,2017,2018,2019 Gregory Todd Williams, Chris Prather and Kjetil Kjernsmo
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
that's a whole decade of copyright years btw. the longevity. the commitment. the way that she's been here since 2012 and is still serving 1.12. periodt. โจ
and that's the page bestie โ brought to you by perl v5.38.2, dated 2024-08-03, straight out of the URI::NamespaceMap(3pm) archives. go forth and namespace responsibly ๐๐ธ๐ฆ
๐ฆ where this page comes from
- debian trixie: liburi-namespacemap-perl 1.12-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liburi-namespacemap-perl 1.12-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liburi-namespacemap-perl 1.12-1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms