deprecated/buildtools/buildsystemtools/lib/XML/DOM/NamedNodeMap.pod
author lorewang
Thu, 11 Nov 2010 11:26:32 +0800
changeset 677 44e49837144a
parent 655 3f65fd25dfd4
permissions -rw-r--r--
update release info
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     1
=head1 NAME
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     3
XML::DOM::NamedNodeMap - A hash table interface for XML::DOM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     5
=head1 DESCRIPTION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     6
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     7
Objects implementing the NamedNodeMap interface are used to represent
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     8
collections of nodes that can be accessed by name. Note that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     9
NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    10
maintained in any particular order. Objects contained in an object
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    11
implementing NamedNodeMap may also be accessed by an ordinal index, but
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    12
this is simply to allow convenient enumeration of the contents of a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    13
NamedNodeMap, and does not imply that the DOM specifies an order to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    14
these Nodes.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    15
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    16
Note that in this implementation, the objects added to a NamedNodeMap
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    17
are kept in order.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    18
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    19
=head2 METHODS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    20
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    21
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    22
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    23
=item getNamedItem (name)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    24
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    25
Retrieves a node specified by name.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    26
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    27
Return Value: A Node (of any type) with the specified name, or undef if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    28
the specified name did not identify any node in the map.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    29
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    30
=item setNamedItem (arg)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    31
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    32
Adds a node using its nodeName attribute.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    33
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    34
As the nodeName attribute is used to derive the name which
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    35
the node must be stored under, multiple nodes of certain
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    36
types (those that have a "special" string value) cannot be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    37
stored as the names would clash. This is seen as preferable
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    38
to allowing nodes to be aliased.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    39
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    40
Parameters:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    41
 I<arg>  A node to store in a named node map. 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    42
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    43
The node will later be accessible using the value of the nodeName
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    44
attribute of the node. If a node with that name is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    45
already present in the map, it is replaced by the new one.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    46
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    47
Return Value: If the new Node replaces an existing node with the same
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    48
name the previously existing Node is returned, otherwise undef is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    49
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    50
DOMExceptions:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    51
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    52
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    53
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    54
=item * WRONG_DOCUMENT_ERR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    55
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    56
Raised if arg was created from a different document than the one that 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    57
created the NamedNodeMap.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    58
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    59
=item * NO_MODIFICATION_ALLOWED_ERR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    60
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    61
Raised if this NamedNodeMap is readonly.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    62
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    63
=item * INUSE_ATTRIBUTE_ERR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    64
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    65
Raised if arg is an Attr that is already an attribute of another Element object.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    66
The DOM user must explicitly clone Attr nodes to re-use them in other elements.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    67
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    68
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    69
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    70
=item removeNamedItem (name)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    71
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    72
Removes a node specified by name. If the removed node is an
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    73
Attr with a default value it is immediately replaced.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    74
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    75
Return Value: The node removed from the map or undef if no node with
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    76
such a name exists.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    77
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    78
DOMException:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    79
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    80
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    81
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    82
=item * NOT_FOUND_ERR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    83
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    84
Raised if there is no node named name in the map.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    85
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    86
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    87
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    88
=item item (index)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    89
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    90
Returns the indexth item in the map. If index is greater than
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    91
or equal to the number of nodes in the map, this returns undef.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    92
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    93
Return Value: The node at the indexth position in the NamedNodeMap, or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    94
undef if that is not a valid index.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    95
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    96
=item getLength
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    97
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    98
Returns the number of nodes in the map. The range of valid child node
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    99
indices is 0 to length-1 inclusive.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   100
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   101
=back
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   102
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   103
=head2 Additional methods not in the DOM Spec
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   104
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   105
=over 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   106
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   107
=item getValues
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   108
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   109
Returns a NodeList with the nodes contained in the NamedNodeMap.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   110
The NodeList is "live", in that it reflects changes made to the NamedNodeMap.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   111
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   112
When this method is called in a list context, it returns a regular perl list
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   113
containing the values. Note that this list is not "live". E.g.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   114
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   115
 @list = $map->getValues;	 # returns a perl list
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   116
 $nodelist = $map->getValues;    # returns a NodeList (object ref.)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   117
 for my $val ($map->getValues)   # iterate over the values
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   118
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   119
=item getChildIndex (node)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   120
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   121
Returns the index of the node in the NodeList as returned by getValues, or -1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   122
if the node is not in the NamedNodeMap.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   123
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   124
=item dispose
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   125
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   126
Removes all circular references in this NamedNodeMap and its descendants so the 
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   127
objects can be claimed for garbage collection. The objects should not be used
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   128
afterwards.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   130
=back