]> err.no Git - sope/blob - sope-xml/DOM/DOMProtocols.h
code reorgs
[sope] / sope-xml / DOM / DOMProtocols.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __DOM_DOMProtocols_H__
23 #define __DOM_DOMProtocols_H__
24
25 /*
26   Protocols for DOM objects ...
27   
28   IDL taken from
29     http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010913/DOM3-Core.html
30 */
31
32 typedef enum {
33   DOM_UNKNOWN_NODE                = 0,
34   DOM_ATTRIBUTE_NODE              = 1,
35   DOM_CDATA_SECTION_NODE          = 2,
36   DOM_COMMENT_NODE                = 3,
37   DOM_DOCUMENT_FRAGMENT_NODE      = 4,
38   DOM_DOCUMENT_NODE               = 5,
39   DOM_DOCUMENT_TYPE_NODE          = 6,
40   DOM_ELEMENT_NODE                = 7,
41   DOM_ENTITY_NODE                 = 8,
42   DOM_ENTITY_REFERENCE_NODE       = 9,
43   DOM_NOTATION_NODE               = 10,
44   DOM_PROCESSING_INSTRUCTION_NODE = 11,
45   DOM_TEXT_NODE                   = 12
46 } DOMNodeType;
47
48 // TODO: find out which GCC version started to have forward protocols decls ...
49 //#define HAVE_FORWARD_PROTOCOLS 1
50
51 #if HAVE_FORWARD_PROTOCOLS
52 @protocol DOMNode;
53 @protocol DOMAttr, DOMCDATASection, DOMComment, DOMDocumentFragment;
54 @protocol DOMDocument, DOMDocumentType, DOMElement, DOMEntity;
55 @protocol DOMEntityReference, DOMNotation, DOMProcessingInstruction;
56 @protocol DOMText;
57
58 // NOTE: _ONLY_ use those defines for forward declarations!
59
60 #define IDOMNode     id<NSObject,DOMNode>
61 #define IDOMDocument id<NSObject,DOMDocument>
62 #define IDOMElement  id<NSObject,DOMElement>
63
64 #else
65 #define IDOMNode     id
66 #define IDOMDocument id
67 #define IDOMElement  id
68 #endif
69
70 @protocol DOMNodeList
71
72 - (unsigned)length;
73 - (id)objectAtIndex:(unsigned)_idx; // returns the proper attribute node
74
75 @end /* DOMNodeList */
76
77 @protocol DOMNamedNodeMap
78
79 - (unsigned)length;
80 - (id)objectAtIndex:(unsigned)_idx; // returns the proper attribute node
81
82 - (IDOMNode)namedItem:(NSString *)_name;
83 - (IDOMNode)setNamedItem:(IDOMNode)_node;
84 - (IDOMNode)removeNamedItem:(NSString *)_name;
85
86 /* DOM2 access */
87
88 - (IDOMNode)namedItem:(NSString *)_name namespaceURI:(NSString *)_uri;
89 - (IDOMNode)setNamedItemNS:(IDOMNode)_node;
90 - (IDOMNode)removeNamedItem:(NSString *)_name namespaceURI:(NSString *)_uri;
91
92 @end /* DOMNamedNodeMap */
93
94 @protocol DOMNode
95
96 - (DOMNodeType)nodeType;
97 - (NSString *)nodeName;
98 - (NSString *)nodeValue;
99
100 - (NSString *)localName;
101 - (NSString *)namespaceURI;
102 - (void)setPrefix:(NSString *)_prefix;
103 - (NSString *)prefix;
104
105 /* element attributes */
106
107 - (id<NSObject,DOMNamedNodeMap>)attributes;
108
109 /* navigation */
110
111 - (id<NSObject,DOMNode>)parentNode;
112 - (id<NSObject,DOMNode>)previousSibling;
113 - (id<NSObject,DOMNode>)nextSibling;
114
115 - (id<NSObject,DOMNodeList>)childNodes;
116 - (BOOL)hasChildNodes;
117 - (id<NSObject,DOMNode>)firstChild;
118 - (id<NSObject,DOMNode>)lastChild;
119
120 /* modification */
121
122 - (id<NSObject,DOMNode>)appendChild:(id<NSObject,DOMNode>)_node;
123 - (id<NSObject,DOMNode>)removeChild:(id<NSObject,DOMNode>)_node;
124
125 /* owner */
126
127 - (IDOMDocument)ownerDocument;
128
129 @end /* DOMNode */
130
131 @protocol DOMDocumentFragment < DOMNode >
132 @end
133
134 @protocol DOMAttr < DOMNode >
135
136 - (NSString *)name;
137 - (BOOL)specified;
138 - (void)setValue:(NSString *)_value;
139 - (NSString *)value;
140
141 /* owner */
142
143 - (IDOMElement)ownerElement;
144
145 @end /* DOMAttr */
146
147 @protocol DOMCharacterData < DOMNode >
148
149 - (void)setData:(NSString *)_data;
150 - (NSString *)data;
151 - (unsigned)length;
152
153 - (NSString *)substringData:(unsigned)_offset count:(unsigned)_count;
154 - (void)appendData:(NSString *)_data;
155 - (void)insertData:(NSString *)_data offset:(unsigned)_offset;
156 - (void)deleteData:(unsigned)_offset count:(unsigned)_count;
157 - (void)replaceData:(unsigned)_offs count:(unsigned)_count with:(NSString *)_s;
158
159 @end /* DOMCharacterData */
160
161 @protocol DOMComment < DOMCharacterData >
162 @end /* DOMComment */
163
164 @protocol DOMText < DOMCharacterData >
165
166 - (id<NSObject,DOMText>)splitText:(unsigned)_offset;
167
168 /* DOM Level 3 */
169
170 - (BOOL)isWhitespaceInElementContent;
171 - (NSString *)wholeText;
172 - (id<NSObject,DOMText>)replaceWholeText:(NSString *)_content;
173
174 @end
175
176 @protocol DOMCDATASection < DOMText >
177 @end
178
179 @protocol DOMElement < DOMNode >
180
181 /* attributes */
182
183 - (NSString *)tagName;
184
185 /* lookup */
186
187 - (id<NSObject,DOMNodeList>)getElementsByTagName:(NSString *)_tagName;
188 - (id<NSObject,DOMNodeList>)getElementsByTagName:(NSString *)_tagName
189   namespaceURI:(NSString *)_uri;
190
191 /* element attributes */
192
193 - (BOOL)hasAttribute:(NSString *)_attrName;
194 - (BOOL)hasAttribute:(NSString *)_localName namespaceURI:(NSString *)_ns;
195
196 - (void)setAttribute:(NSString *)_attrName value:(NSString *)_value;
197 - (void)setAttribute:(NSString *)_localName namespaceURI:(NSString *)_ns
198   value:(NSString *)_value;
199
200 - (NSString *)attribute:(NSString *)_attrName;
201 - (NSString *)attribute:(NSString *)_localName namespaceURI:(NSString *)_ns;
202 - (void)removeAttribute:(NSString *)_attrName;
203 - (void)removeAttribute:(NSString *)_attrName namespaceURI:(NSString *)_ns;
204
205 - (id<NSObject,DOMAttr>)setAttributeNode:(id<NSObject,DOMAttr>)_attrNode;
206 - (id<NSObject,DOMAttr>)removeAttributeNode:(id<NSObject,DOMAttr>)_attrNode;
207 - (id<NSObject,DOMAttr>)setAttributeNodeNS:(id<NSObject,DOMAttr>)_attrNode;
208 - (id<NSObject,DOMAttr>)removeAttributeNodeNS:(id<NSObject,DOMAttr>)_attrNode;
209
210 @end /* DOMElement */
211
212 @protocol DOMDocumentType < DOMNode >
213 @end /* DOMDocumentType */
214
215 @protocol DOMProcessingInstruction < DOMNode >
216
217 - (NSString *)target;
218 - (NSString *)data;
219
220 @end /* DOMProcessingInstruction */
221
222 @protocol DOMEntityReference < DOMNode >
223 @end
224
225 @class NGDOMImplementation;
226
227 @protocol DOMDocument < DOMNode >
228
229 - (id<NSObject,DOMDocumentType>)doctype;
230 - (NGDOMImplementation *)implementation;
231 - (id<NSObject,DOMElement>)documentElement;
232
233 - (id<NSObject,DOMNodeList>)getElementsByTagName:(NSString *)_tagName;
234 - (id<NSObject,DOMNodeList>)getElementsByTagName:(NSString *)_tagName
235   namespaceURI:(NSString *)_uri;
236 - (id<NSObject,DOMElement>)getElementById:(NSString *)_eid;
237
238 /* creation */
239
240 - (id<NSObject,DOMElement>)createElement:(NSString *)_tagName;
241 - (id<NSObject,DOMElement>)createElement:(NSString *)_tagName
242   namespaceURI:(NSString *)_uri;
243
244 - (id<NSObject,DOMDocumentFragment>)createDocumentFragment;
245 - (id<NSObject,DOMText>)createTextNode:(NSString *)_data;
246 - (id<NSObject,DOMComment>)createComment:(NSString *)_data;
247 - (id<NSObject,DOMCDATASection>)createCDATASection:(NSString *)_data;
248
249 - (id<NSObject,DOMProcessingInstruction>)
250   createProcessingInstruction:(NSString *)_target data:(NSString *)_data;
251
252 - (id<NSObject,DOMAttr>)createAttribute:(NSString *)_name;
253 - (id<NSObject,DOMAttr>)createAttribute:(NSString *)_name
254   namespaceURI:(NSString *)_uri;
255
256 - (id<NSObject,DOMEntityReference>)createEntityReference:(NSString *)_name;
257
258 @end /* DOMDocument */
259
260 #endif /* __DOM_DOMProtocols_H__ */