ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-XMPP2/lib/Net/XMPP2/Namespaces.pm
Revision: 1.6
Committed: Wed Apr 25 13:18:36 2007 UTC (19 years, 5 months ago) by elmex
Branch: MAIN
Changes since 1.5: +14 -13 lines
Log Message:
added Disco support!

File Contents

# User Rev Content
1 elmex 1.1 package Net::XMPP2::Namespaces;
2     use warnings;
3     use strict;
4     require Exporter;
5     our @EXPORT_OK = qw/xmpp_ns set_xmpp_ns_alias/;
6     our @ISA = qw/Exporter/;
7    
8     our %NAMESPACES = (
9 elmex 1.6 client => 'jabber:client',
10     stream => 'http://etherx.jabber.org/streams',
11     streams => 'urn:ietf:params:xml:ns:xmpp-streams',
12     stanzas => 'urn:ietf:params:xml:ns:xmpp-stanzas',
13     sasl => 'urn:ietf:params:xml:ns:xmpp-sasl',
14     bind => 'urn:ietf:params:xml:ns:xmpp-bind',
15     tls => 'urn:ietf:params:xml:ns:xmpp-tls',
16     roster => 'jabber:iq:roster',
17     version => 'jabber:iq:version',
18     session => 'urn:ietf:params:xml:ns:xmpp-session',
19     xml => 'http://www.w3.org/XML/1998/namespace',
20     disco_info => 'http://jabber.org/protocol/disco#info',
21     disco_items => 'http://jabber.org/protocol/disco#items',
22     register => 'http://jabber.org/features/iq-register',
23 elmex 1.1 );
24    
25     =head1 NAME
26    
27     Net::XMPP2::Namespaces - A XMPP namespace collection and aliasing class
28    
29     =head1 SYNOPSIS
30    
31     use Net::XMPP2::Namespaces qw/xmpp_ns set_xmpp_ns_alias/;
32    
33     set_xmpp_ns_alias (stanzas => 'urn:ietf:params:xml:ns:xmpp-stanzas');
34     $node->find_all ($p, [xmpp_ns ('stanzas'), 'iq']);
35    
36     =head1 DESCRIPTION
37    
38     This module represents a simple namespaces aliasing mechanism to ease handling
39     of namespaces when traversing Net::XMPP2::Node objects and writing XML
40     with Net::XMPP2::Writer.
41    
42     =head1 XMPP NAMESPACES
43    
44     There are already some aliases defined for the XMPP XML namespaces
45     which make handling of namepsaces a bit easier:
46    
47     stream => http://etherx.jabber.org/streams
48     xml => http://www.w3.org/XML/1998/namespace
49    
50     streams => urn:ietf:params:xml:ns:xmpp-streams
51     session => urn:ietf:params:xml:ns:xmpp-session
52     stanzas => urn:ietf:params:xml:ns:xmpp-stanzas
53     sasl => urn:ietf:params:xml:ns:xmpp-sasl
54     bind => urn:ietf:params:xml:ns:xmpp-bind
55 elmex 1.2 tls => urn:ietf:params:xml:ns:xmpp-tls
56 elmex 1.1
57     client => jabber:client
58     roster => jabber:iq:roster
59     version => jabber:iq:version
60    
61 elmex 1.5 register => http://jabber.org/features/iq-register
62    
63 elmex 1.1 =head1 FUNCTIONS
64    
65     =head2 xmpp_ns ($alias)
66    
67     Returns am uri for the registered C<$alias> or undef if none exists.
68    
69     =cut
70    
71     sub xmpp_ns { return $NAMESPACES{$_[0]} }
72    
73     =head2 set_xmpp_ns_alias ($alias, $namespace_uri)
74    
75     Sets an C<$alias> for the C<$namespace_uri>.
76    
77     =cut
78    
79     sub set_xmpp_ns_alias { return $NAMESPACES{$_[0]} }
80    
81     =head1 AUTHOR
82    
83     Robin Redeker, C<< <elmex at ta-sa.org> >>
84    
85     =head1 COPYRIGHT & LICENSE
86    
87     Copyright 2007 Robin Redeker, all rights reserved.
88    
89     This program is free software; you can redistribute it and/or modify it
90     under the same terms as Perl itself.
91    
92     =cut
93    
94     1; # End of Net::XMPP2