| 1 |
=head1 NAME |
| 2 |
|
| 3 |
XML::LibXML::Namespace - XML::LibXML Namespace Implementation |
| 4 |
|
| 5 |
=head1 SYNOPSIS |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
use XML::LibXML; |
| 10 |
# Only methods specific to Namespace nodes are listed here, |
| 11 |
# see the XML::LibXML::Node manpage for other methods |
| 12 |
|
| 13 |
my $ns = XML::LibXML::Namespace->new($nsURI); |
| 14 |
print $ns->nodeName(); |
| 15 |
print $ns->name(); |
| 16 |
$localname = $ns->getLocalName(); |
| 17 |
print $ns->getData(); |
| 18 |
print $ns->getValue(); |
| 19 |
print $ns->value(); |
| 20 |
$known_uri = $ns->getNamespaceURI(); |
| 21 |
$known_prefix = $ns->getPrefix(); |
| 22 |
$key = $ns->unique_key(); |
| 23 |
|
| 24 |
=head1 DESCRIPTION |
| 25 |
|
| 26 |
Namespace nodes are returned by both $element->findnodes('namespace::foo') or |
| 27 |
by $node->getNamespaces(). |
| 28 |
|
| 29 |
The namespace node API is not part of any current DOM API, and so it is quite |
| 30 |
minimal. It should be noted that namespace nodes are I<<<<<< not >>>>>> a sub class of L<<<<<< XML::LibXML::Node >>>>>>, however Namespace nodes act a lot like attribute nodes, and similarly named |
| 31 |
methods will return what you would expect if you treated the namespace node as |
| 32 |
an attribute. Note that in order to fix several inconsistencies between the API |
| 33 |
and the documentation, the behavior of some functions have been changed in |
| 34 |
1.64. |
| 35 |
|
| 36 |
|
| 37 |
=head1 METHODS |
| 38 |
|
| 39 |
=over 4 |
| 40 |
|
| 41 |
=item new |
| 42 |
|
| 43 |
my $ns = XML::LibXML::Namespace->new($nsURI); |
| 44 |
|
| 45 |
Creates a new Namespace node. Note that this is not a 'node' as an attribute or |
| 46 |
an element node. Therefore you can't do call all L<<<<<< XML::LibXML::Node >>>>>> Functions. All functions available for this node are listed below. |
| 47 |
|
| 48 |
Optionally you can pass the prefix to the namespace constructor. If this second |
| 49 |
parameter is omitted you will create a so called default namespace. Note, the |
| 50 |
newly created namespace is not bound to any document or node, therefore you |
| 51 |
should not expect it to be available in an existing document. |
| 52 |
|
| 53 |
|
| 54 |
=item declaredURI |
| 55 |
|
| 56 |
Returns the URI for this namespace. |
| 57 |
|
| 58 |
|
| 59 |
=item declaredPrefix |
| 60 |
|
| 61 |
Returns the prefix for this namespace. |
| 62 |
|
| 63 |
|
| 64 |
=item nodeName |
| 65 |
|
| 66 |
print $ns->nodeName(); |
| 67 |
|
| 68 |
Returns "xmlns:prefix", where prefix is the prefix for this namespace. |
| 69 |
|
| 70 |
|
| 71 |
=item name |
| 72 |
|
| 73 |
print $ns->name(); |
| 74 |
|
| 75 |
Alias for nodeName() |
| 76 |
|
| 77 |
|
| 78 |
=item getLocalName |
| 79 |
|
| 80 |
$localname = $ns->getLocalName(); |
| 81 |
|
| 82 |
Returns the local name of this node as if it were an attribute, that is, the |
| 83 |
prefix associated with the namespace. |
| 84 |
|
| 85 |
|
| 86 |
=item getData |
| 87 |
|
| 88 |
print $ns->getData(); |
| 89 |
|
| 90 |
Returns the URI of the namespace, i.e. the value of this node as if it were an |
| 91 |
attribute. |
| 92 |
|
| 93 |
|
| 94 |
=item getValue |
| 95 |
|
| 96 |
print $ns->getValue(); |
| 97 |
|
| 98 |
Alias for getData() |
| 99 |
|
| 100 |
|
| 101 |
=item value |
| 102 |
|
| 103 |
print $ns->value(); |
| 104 |
|
| 105 |
Alias for getData() |
| 106 |
|
| 107 |
|
| 108 |
=item getNamespaceURI |
| 109 |
|
| 110 |
$known_uri = $ns->getNamespaceURI(); |
| 111 |
|
| 112 |
Returns the string "http://www.w3.org/2000/xmlns/" |
| 113 |
|
| 114 |
|
| 115 |
=item getPrefix |
| 116 |
|
| 117 |
$known_prefix = $ns->getPrefix(); |
| 118 |
|
| 119 |
Returns the string "xmlns" |
| 120 |
|
| 121 |
|
| 122 |
=item unique_key |
| 123 |
|
| 124 |
$key = $ns->unique_key(); |
| 125 |
|
| 126 |
This method returns a key guaranteed to be unique for this namespace, and to |
| 127 |
always be the same value for this namespace. Two namespace objects return the |
| 128 |
same key if and only if they have the same prefix and the same URI. The |
| 129 |
returned key value is useful as a key in hashes. |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
=back |
| 134 |
|
| 135 |
=head1 AUTHORS |
| 136 |
|
| 137 |
Matt Sergeant, |
| 138 |
Christian Glahn, |
| 139 |
Petr Pajas |
| 140 |
|
| 141 |
|
| 142 |
=head1 VERSION |
| 143 |
|
| 144 |
2.0134 |
| 145 |
|
| 146 |
=head1 COPYRIGHT |
| 147 |
|
| 148 |
2001-2007, AxKit.com Ltd. |
| 149 |
|
| 150 |
2002-2006, Christian Glahn. |
| 151 |
|
| 152 |
2006-2009, Petr Pajas. |
| 153 |
|
| 154 |
=cut |
| 155 |
|
| 156 |
|
| 157 |
=head1 LICENSE |
| 158 |
|
| 159 |
This program is free software; you can redistribute it and/or modify it under |
| 160 |
the same terms as Perl itself. |
| 161 |
|