1 | // |
---|---|
2 | // DTDMap.cpp |
3 | // |
4 | // Library: XML |
5 | // Package: DOM |
6 | // Module: DOM |
7 | // |
8 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/DOM/DTDMap.h" |
16 | #include "Poco/DOM/DocumentType.h" |
17 | #include "Poco/DOM/Document.h" |
18 | #include "Poco/DOM/DOMException.h" |
19 | |
20 | |
21 | namespace Poco { |
22 | namespace XML { |
23 | |
24 | |
25 | DTDMap::DTDMap(const DocumentType* pDocumentType, unsigned short type): |
26 | _pDocumentType(pDocumentType), |
27 | _type(type) |
28 | { |
29 | poco_check_ptr (pDocumentType->ownerDocument()); |
30 | } |
31 | |
32 | |
33 | DTDMap::~DTDMap() |
34 | { |
35 | } |
36 | |
37 | |
38 | Node* DTDMap::getNamedItem(const XMLString& name) const |
39 | { |
40 | Node* pCur = _pDocumentType->firstChild(); |
41 | while (pCur) |
42 | { |
43 | if (pCur->nodeType() == _type && pCur->nodeName() == name) |
44 | return pCur; |
45 | pCur = pCur->nextSibling(); |
46 | } |
47 | return pCur; |
48 | } |
49 | |
50 | |
51 | Node* DTDMap::setNamedItem(Node* arg) |
52 | { |
53 | throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); |
54 | } |
55 | |
56 | |
57 | Node* DTDMap::removeNamedItem(const XMLString& name) |
58 | { |
59 | throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); |
60 | } |
61 | |
62 | |
63 | Node* DTDMap::item(unsigned long index) const |
64 | { |
65 | unsigned long n = 0; |
66 | Node* pCur = _pDocumentType->firstChild(); |
67 | while (pCur) |
68 | { |
69 | if (pCur->nodeType() == _type) |
70 | { |
71 | if (n == index) return pCur; |
72 | ++n; |
73 | } |
74 | pCur = pCur->nextSibling(); |
75 | } |
76 | return pCur; |
77 | } |
78 | |
79 | |
80 | unsigned long DTDMap::length() const |
81 | { |
82 | unsigned long n = 0; |
83 | Node* pCur = _pDocumentType->firstChild(); |
84 | while (pCur) |
85 | { |
86 | if (pCur->nodeType() == _type) ++n; |
87 | pCur = pCur->nextSibling(); |
88 | } |
89 | return n; |
90 | } |
91 | |
92 | |
93 | Node* DTDMap::getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const |
94 | { |
95 | return 0; |
96 | } |
97 | |
98 | |
99 | Node* DTDMap::setNamedItemNS(Node* arg) |
100 | { |
101 | throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); |
102 | } |
103 | |
104 | |
105 | Node* DTDMap::removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) |
106 | { |
107 | throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR); |
108 | } |
109 | |
110 | |
111 | void DTDMap::autoRelease() |
112 | { |
113 | _pDocumentType->ownerDocument()->autoReleasePool().add(this); |
114 | } |
115 | |
116 | |
117 | } } // namespace Poco::XML |
118 |