1//
2// NamedNodeMap.h
3//
4// Library: XML
5// Package: DOM
6// Module: DOM
7//
8// Definition of the DOM NamedNodeMap interface.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef DOM_NamedNodeMap_INCLUDED
18#define DOM_NamedNodeMap_INCLUDED
19
20
21#include "Poco/XML/XML.h"
22#include "Poco/DOM/DOMObject.h"
23#include "Poco/XML/XMLString.h"
24
25
26namespace Poco {
27namespace XML {
28
29
30class Node;
31
32
33class XML_API NamedNodeMap: public DOMObject
34 /// Objects implementing the NamedNodeMap interface are used to represent collections
35 /// of nodes that can be accessed by name. Note that NamedNodeMap does not inherit
36 /// from NodeList; NamedNodeMaps are not maintained in any particular order.
37 /// Objects contained in an object implementing NamedNodeMap may also be accessed
38 /// by an ordinal index, but this is simply to allow convenient enumeration
39 /// of the contents of a NamedNodeMap, and does not imply that the DOM specifies
40 /// an order to these Nodes.
41 ///
42 /// NamedNodeMap objects in the DOM are live.
43 ///
44 /// A NamedNodeMap returned from a method must be released with a call to
45 /// release() when no longer needed.
46{
47public:
48 virtual Node* getNamedItem(const XMLString& name) const = 0;
49 /// Retrieves a node specified by name.
50
51 virtual Node* setNamedItem(Node* arg) = 0;
52 /// Adds a node using its nodeName attribute. If a node with that name is already
53 /// present in this map, it is replaced by the new one.
54 /// As the nodeName attribute is used to derive the name which the node must
55 /// be stored under, multiple nodes of certain types (those that have a "special"
56 /// string value) cannot be stored as the names would clash. This is seen as
57 /// preferable to allowing nodes to be aliased.
58
59 virtual Node* removeNamedItem(const XMLString& name) = 0;
60 /// Removes a node specified by name. When this map contains the attributes
61 /// attached to an element, if the removed attribute is known to have a default
62 /// value, an attribute immediately appears containing the default value.
63
64 virtual Node* item(unsigned long index) const = 0;
65 /// Returns the index'th item in the map. If index is greater
66 /// than or equal to the number of nodes in the map, this
67 /// returns null.
68
69 virtual unsigned long length() const = 0;
70 /// Returns the number of nodes in the map. The range of valid
71 /// child node indices is 0 to length - 1 inclusive.
72
73 // DOM Level 2
74 virtual Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const = 0;
75 /// Retrieves a node specified by name.
76
77 virtual Node* setNamedItemNS(Node* arg) = 0;
78 /// Adds a node using its nodeName attribute.
79 /// If a node with that namespace URI and that local name is already
80 /// present in this map, it is replaced by the new one.
81
82 virtual Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) = 0;
83 /// Removes a node specified by name.
84
85protected:
86 virtual ~NamedNodeMap();
87};
88
89
90} } // namespace Poco::XML
91
92
93#endif // DOM_NamedNodeMap_INCLUDED
94