34 |
return $attr; |
return $attr; |
35 |
}, |
}, |
36 |
attr_get => { |
attr_get => { |
37 |
|
first_child => undef, |
38 |
|
last_child => undef, |
39 |
|
local_name => 'a', |
40 |
|
manakai_local_name => 'a', |
41 |
|
namespace_uri => undef, |
42 |
|
next_sibling => undef, |
43 |
node_name => 'a', |
node_name => 'a', |
44 |
name => 'a', |
name => 'a', |
45 |
node_value => 'b', |
node_value => 'b', |
46 |
|
owner_document => $doc, |
47 |
|
parent_node => undef, |
48 |
|
prefix => undef, |
49 |
|
previous_sibling => undef, |
50 |
value => 'b', |
value => 'b', |
51 |
attributes => undef, |
attributes => undef, |
52 |
}, |
}, |
58 |
return $attr; |
return $attr; |
59 |
}, |
}, |
60 |
attr_get => { |
attr_get => { |
61 |
|
first_child => undef, |
62 |
|
last_child => undef, |
63 |
|
local_name => 'a', |
64 |
|
manakai_local_name => 'a', |
65 |
|
namespace_uri => undef, |
66 |
|
next_sibling => undef, |
67 |
node_name => 'a', |
node_name => 'a', |
68 |
name => 'a', |
name => 'a', |
69 |
node_value => 'b', |
node_value => 'b', |
70 |
|
owner_document => $doc, |
71 |
|
parent_node => undef, |
72 |
|
prefix => undef, |
73 |
value => 'b', |
value => 'b', |
74 |
attributes => undef, |
attributes => undef, |
75 |
|
previous_sibling => undef, |
76 |
}, |
}, |
77 |
}, |
}, |
78 |
attr_ns_prefixed => { |
attr_ns_prefixed => { |
82 |
return $attr; |
return $attr; |
83 |
}, |
}, |
84 |
attr_get => { |
attr_get => { |
85 |
|
first_child => undef, |
86 |
|
last_child => undef, |
87 |
|
local_name => 'b', |
88 |
|
manakai_local_name => 'b', |
89 |
|
namespace_uri => 'http://test/', |
90 |
|
next_sibling => undef, |
91 |
node_name => 'a:b', |
node_name => 'a:b', |
92 |
name => 'a:b', |
name => 'a:b', |
93 |
node_value => 'c', |
node_value => 'c', |
94 |
|
owner_document => $doc, |
95 |
|
parent_node => undef, |
96 |
|
prefix => 'a', |
97 |
value => 'c', |
value => 'c', |
98 |
attributes => undef, |
attributes => undef, |
99 |
|
previous_sibling => undef, |
100 |
}, |
}, |
101 |
}, |
}, |
102 |
cdatasection => { |
cdatasection => { |
103 |
node => sub { return $doc->create_cdata_section ('cdatadata') }, |
node => sub { return $doc->create_cdata_section ('cdatadata') }, |
104 |
attr_get => { |
attr_get => { |
105 |
|
first_child => undef, |
106 |
|
last_child => undef, |
107 |
|
local_name => undef, |
108 |
|
manakai_local_name => undef, |
109 |
|
namespace_uri => undef, |
110 |
|
next_sibling => undef, |
111 |
node_name => '#cdata-section', |
node_name => '#cdata-section', |
112 |
node_value => 'cdatadata', |
node_value => 'cdatadata', |
113 |
|
owner_document => $doc, |
114 |
|
parent_node => undef, |
115 |
|
prefix => undef, |
116 |
data => 'cdatadata', |
data => 'cdatadata', |
117 |
attributes => undef, |
attributes => undef, |
118 |
|
previous_sibling => undef, |
119 |
}, |
}, |
120 |
}, |
}, |
121 |
cdatasectionmde => { |
cdatasectionmde => { |
122 |
node => sub { return $doc->create_cdata_section ('cdata]]>data') }, |
node => sub { return $doc->create_cdata_section ('cdata]]>data') }, |
123 |
attr_get => { |
attr_get => { |
124 |
|
first_child => undef, |
125 |
|
last_child => undef, |
126 |
|
local_name => undef, |
127 |
|
manakai_local_name => undef, |
128 |
|
namespace_uri => undef, |
129 |
|
next_sibling => undef, |
130 |
node_name => '#cdata-section', |
node_name => '#cdata-section', |
131 |
node_value => 'cdata]]>data', |
node_value => 'cdata]]>data', |
132 |
|
owner_document => $doc, |
133 |
|
parent_node => undef, |
134 |
|
prefix => undef, |
135 |
data => 'cdata]]>data', |
data => 'cdata]]>data', |
136 |
attributes => undef, |
attributes => undef, |
137 |
|
previous_sibling => undef, |
138 |
}, |
}, |
139 |
}, |
}, |
140 |
comment => { |
comment => { |
141 |
node => sub { return $doc->create_comment ('commentdata') }, |
node => sub { return $doc->create_comment ('commentdata') }, |
142 |
attr_get => { |
attr_get => { |
143 |
|
first_child => undef, |
144 |
|
last_child => undef, |
145 |
|
local_name => undef, |
146 |
|
manakai_local_name => undef, |
147 |
|
namespace_uri => undef, |
148 |
|
next_sibling => undef, |
149 |
node_name => '#comment', |
node_name => '#comment', |
150 |
node_value => 'commentdata', |
node_value => 'commentdata', |
151 |
|
owner_document => $doc, |
152 |
|
parent_node => undef, |
153 |
|
prefix => undef, |
154 |
data => 'commentdata', |
data => 'commentdata', |
155 |
attributes => undef, |
attributes => undef, |
156 |
|
previous_sibling => undef, |
157 |
}, |
}, |
158 |
}, |
}, |
159 |
commentcom1 => { |
commentcom1 => { |
160 |
node => sub { return $doc->create_comment ('comment--data') }, |
node => sub { return $doc->create_comment ('comment--data') }, |
161 |
attr_get => { |
attr_get => { |
162 |
|
first_child => undef, |
163 |
|
last_child => undef, |
164 |
|
local_name => undef, |
165 |
|
manakai_local_name => undef, |
166 |
|
namespace_uri => undef, |
167 |
|
next_sibling => undef, |
168 |
node_name => '#comment', |
node_name => '#comment', |
169 |
node_value => 'comment--data', |
node_value => 'comment--data', |
170 |
|
owner_document => $doc, |
171 |
|
parent_node => undef, |
172 |
|
prefix => undef, |
173 |
data => 'comment--data', |
data => 'comment--data', |
174 |
attributes => undef, |
attributes => undef, |
175 |
|
previous_sibling => undef, |
176 |
}, |
}, |
177 |
}, |
}, |
178 |
commentcom2 => { |
commentcom2 => { |
179 |
node => sub { return $doc->create_comment ('commentdata-') }, |
node => sub { return $doc->create_comment ('commentdata-') }, |
180 |
attr_get => { |
attr_get => { |
181 |
|
first_child => undef, |
182 |
|
last_child => undef, |
183 |
|
local_name => undef, |
184 |
|
manakai_local_name => undef, |
185 |
|
namespace_uri => undef, |
186 |
|
next_sibling => undef, |
187 |
node_name => '#comment', |
node_name => '#comment', |
188 |
node_value => 'commentdata-', |
node_value => 'commentdata-', |
189 |
|
owner_document => $doc, |
190 |
|
parent_node => undef, |
191 |
|
prefix => undef, |
192 |
data => 'commentdata-', |
data => 'commentdata-', |
193 |
attributes => undef, |
attributes => undef, |
194 |
|
previous_sibling => undef, |
195 |
}, |
}, |
196 |
}, |
}, |
197 |
document => { |
document => { |
198 |
node => sub { return $doc }, |
node => sub { return $doc }, |
199 |
attr_get => { |
attr_get => { |
200 |
attributes => undef, |
attributes => undef, |
201 |
|
first_child => undef, |
202 |
|
implementation => $dom, |
203 |
|
last_child => undef, |
204 |
local_name => undef, |
local_name => undef, |
205 |
|
manakai_local_name => undef, |
206 |
namespace_uri => undef, |
namespace_uri => undef, |
207 |
|
next_sibling => undef, |
208 |
node_name => '#document', |
node_name => '#document', |
209 |
node_value => undef, |
node_value => undef, |
210 |
|
owner_document => undef, |
211 |
parent_node => undef, |
parent_node => undef, |
212 |
prefix => undef, |
prefix => undef, |
213 |
|
previous_sibling => undef, |
214 |
}, |
}, |
215 |
}, |
}, |
216 |
document_fragment => { |
document_fragment => { |
217 |
node => sub { return $doc->create_document_fragment }, |
node => sub { return $doc->create_document_fragment }, |
218 |
attr_get => { |
attr_get => { |
219 |
attributes => undef, |
attributes => undef, |
220 |
|
first_child => undef, |
221 |
|
last_child => undef, |
222 |
|
local_name => undef, |
223 |
|
manakai_local_name => undef, |
224 |
|
namespace_uri => undef, |
225 |
|
next_sibling => undef, |
226 |
node_name => '#document-fragment', |
node_name => '#document-fragment', |
227 |
node_value => undef, |
node_value => undef, |
228 |
|
owner_document => $doc, |
229 |
|
parent_node => undef, |
230 |
|
prefix => undef, |
231 |
|
previous_sibling => undef, |
232 |
}, |
}, |
233 |
}, |
}, |
234 |
document_type => { |
document_type => { |
235 |
node => sub { return $doc->implementation->create_document_type ('n') }, |
node => sub { return $doc->implementation->create_document_type ('n') }, |
236 |
attr_get => { |
attr_get => { |
237 |
attributes => undef, |
attributes => undef, |
238 |
|
first_child => undef, |
239 |
|
implementation => $dom, |
240 |
|
last_child => undef, |
241 |
|
local_name => undef, |
242 |
|
manakai_local_name => undef, |
243 |
|
namespace_uri => undef, |
244 |
|
next_sibling => undef, |
245 |
node_name => 'n', |
node_name => 'n', |
246 |
node_value => undef, |
node_value => undef, |
247 |
|
owner_document => undef, |
248 |
|
parent_node => undef, |
249 |
|
prefix => undef, |
250 |
|
previous_sibling => undef, |
251 |
}, |
}, |
252 |
}, |
}, |
253 |
document_type_definition => { |
document_type_definition => { |
254 |
node => sub { return $doc->create_document_type_definition ('n') }, |
node => sub { return $doc->create_document_type_definition ('n') }, |
255 |
attr_get => { |
attr_get => { |
256 |
attributes => undef, |
attributes => undef, |
257 |
|
first_child => undef, |
258 |
|
implementation => $dom, |
259 |
|
last_child => undef, |
260 |
|
local_name => undef, |
261 |
|
manakai_local_name => undef, |
262 |
|
namespace_uri => undef, |
263 |
|
next_sibling => undef, |
264 |
node_name => 'n', |
node_name => 'n', |
265 |
node_value => undef, |
node_value => undef, |
266 |
|
owner_document => $doc, |
267 |
|
parent_node => undef, |
268 |
|
prefix => undef, |
269 |
|
previous_sibling => undef, |
270 |
}, |
}, |
271 |
}, |
}, |
272 |
element => { |
element => { |
273 |
node => sub { return $doc->create_element ('e') }, |
node => sub { return $doc->create_element ('e') }, |
274 |
attr_get => { |
attr_get => { |
275 |
## TODO: attributes => |
## TODO: attributes => |
276 |
|
first_child => undef, |
277 |
|
last_child => undef, |
278 |
|
local_name => 'e', |
279 |
|
manakai_local_name => 'e', |
280 |
|
namespace_uri => undef, |
281 |
|
next_sibling => undef, |
282 |
node_name => 'e', |
node_name => 'e', |
283 |
node_value => undef, |
node_value => undef, |
284 |
|
owner_document => $doc, |
285 |
|
parent_node => undef, |
286 |
|
prefix => undef, |
287 |
|
previous_sibling => undef, |
288 |
}, |
}, |
289 |
}, |
}, |
290 |
element_ns_default => { |
element_ns_default => { |
291 |
node => sub { return $doc->create_element_ns ('http://test/', 'f') }, |
node => sub { return $doc->create_element_ns ('http://test/', 'f') }, |
292 |
attr_get => { |
attr_get => { |
293 |
## TODO: attributes => |
## TODO: attributes => |
294 |
|
first_child => undef, |
295 |
|
last_child => undef, |
296 |
|
local_name => 'f', |
297 |
|
manakai_local_name => 'f', |
298 |
|
namespace_uri => 'http://test/', |
299 |
|
next_sibling => undef, |
300 |
node_name => 'f', |
node_name => 'f', |
301 |
node_value => undef, |
node_value => undef, |
302 |
|
owner_document => $doc, |
303 |
|
parent_node => undef, |
304 |
|
prefix => undef, |
305 |
|
previous_sibling => undef, |
306 |
}, |
}, |
307 |
}, |
}, |
308 |
element_ns_prefiexed => { |
element_ns_prefiexed => { |
309 |
node => sub { return $doc->create_element_ns ('http://test/', 'e:f') }, |
node => sub { return $doc->create_element_ns ('http://test/', 'e:f') }, |
310 |
attr_get => { |
attr_get => { |
311 |
## TODO: attributes => |
## TODO: attributes => |
312 |
|
first_child => undef, |
313 |
|
last_child => undef, |
314 |
|
local_name => 'f', |
315 |
|
manakai_local_name => 'f', |
316 |
|
namespace_uri => 'http://test/', |
317 |
|
next_sibling => undef, |
318 |
node_name => 'e:f', |
node_name => 'e:f', |
319 |
node_value => undef, |
node_value => undef, |
320 |
|
owner_document => $doc, |
321 |
|
parent_node => undef, |
322 |
|
prefix => 'e', |
323 |
|
previous_sibling => undef, |
324 |
}, |
}, |
325 |
}, |
}, |
326 |
entity => { |
entity => { |
327 |
node => sub { return $doc->create_general_entity ('e') }, |
node => sub { return $doc->create_general_entity ('e') }, |
328 |
attr_get => { |
attr_get => { |
329 |
attributes => undef, |
attributes => undef, |
330 |
|
first_child => undef, |
331 |
|
last_child => undef, |
332 |
|
next_sibling => undef, |
333 |
node_name => 'e', |
node_name => 'e', |
334 |
node_value => undef, |
node_value => undef, |
335 |
|
owner_document => $doc, |
336 |
|
parent_node => undef, |
337 |
|
previous_sibling => undef, |
338 |
}, |
}, |
339 |
}, |
}, |
340 |
entity_reference => { |
entity_reference => { |
341 |
node => sub { return $doc->create_entity_reference ('e') }, |
node => sub { return $doc->create_entity_reference ('e') }, |
342 |
attr_get => { |
attr_get => { |
343 |
attributes => undef, |
attributes => undef, |
344 |
|
first_child => undef, |
345 |
|
last_child => undef, |
346 |
|
local_name => undef, |
347 |
|
manakai_local_name => undef, |
348 |
|
namespace_uri => undef, |
349 |
|
next_sibling => undef, |
350 |
node_name => 'e', |
node_name => 'e', |
351 |
node_value => undef, |
node_value => undef, |
352 |
|
owner_document => $doc, |
353 |
|
parent_node => undef, |
354 |
|
prefix => undef, |
355 |
|
previous_sibling => undef, |
356 |
}, |
}, |
357 |
}, |
}, |
358 |
notation => { |
notation => { |
359 |
node => sub { return $doc->create_notation ('e') }, |
node => sub { return $doc->create_notation ('e') }, |
360 |
attr_get => { |
attr_get => { |
361 |
attributes => undef, |
attributes => undef, |
362 |
|
first_child => undef, |
363 |
|
last_child => undef, |
364 |
|
local_name => undef, |
365 |
|
manakai_local_name => undef, |
366 |
|
namespace_uri => undef, |
367 |
|
next_sibling => undef, |
368 |
node_name => 'e', |
node_name => 'e', |
369 |
node_value => undef, |
node_value => undef, |
370 |
|
owner_document => $doc, |
371 |
|
parent_node => undef, |
372 |
|
prefix => undef, |
373 |
|
previous_sibling => undef, |
374 |
}, |
}, |
375 |
}, |
}, |
376 |
processing_instruction => { |
processing_instruction => { |
377 |
node => sub { return $doc->create_processing_instruction ('t', 'd') }, |
node => sub { return $doc->create_processing_instruction ('t', 'd') }, |
378 |
attr_get => { |
attr_get => { |
379 |
attributes => undef, |
attributes => undef, |
380 |
|
first_child => undef, |
381 |
|
last_child => undef, |
382 |
|
local_name => undef, |
383 |
|
manakai_local_name => undef, |
384 |
|
namespace_uri => undef, |
385 |
|
next_sibling => undef, |
386 |
node_name => 't', |
node_name => 't', |
387 |
node_value => 'd', |
node_value => 'd', |
388 |
|
owner_document => $doc, |
389 |
|
parent_node => undef, |
390 |
|
prefix => undef, |
391 |
|
previous_sibling => undef, |
392 |
}, |
}, |
393 |
}, |
}, |
394 |
text => { |
text => { |
395 |
node => sub { return $doc->create_text_node ('textdata') }, |
node => sub { return $doc->create_text_node ('textdata') }, |
396 |
attr_get => { |
attr_get => { |
397 |
attributes => undef, |
attributes => undef, |
398 |
|
first_child => undef, |
399 |
|
last_child => undef, |
400 |
|
local_name => undef, |
401 |
|
manakai_local_name => undef, |
402 |
|
namespace_uri => undef, |
403 |
|
next_sibling => undef, |
404 |
node_name => '#text', |
node_name => '#text', |
405 |
node_value => 'textdata', |
node_value => 'textdata', |
406 |
|
owner_document => $doc, |
407 |
|
parent_node => undef, |
408 |
|
prefix => undef, |
409 |
|
previous_sibling => undef, |
410 |
}, |
}, |
411 |
}, |
}, |
412 |
element_type_definition => { |
element_type_definition => { |
413 |
node => sub { return $doc->create_element_type_definition ('e') }, |
node => sub { return $doc->create_element_type_definition ('e') }, |
414 |
attr_get => { |
attr_get => { |
415 |
attributes => undef, |
attributes => undef, |
416 |
|
first_child => undef, |
417 |
|
last_child => undef, |
418 |
|
local_name => undef, |
419 |
|
manakai_local_name => undef, |
420 |
|
namespace_uri => undef, |
421 |
|
next_sibling => undef, |
422 |
node_name => 'e', |
node_name => 'e', |
423 |
node_value => undef, |
node_value => undef, |
424 |
|
owner_document => $doc, |
425 |
|
parent_node => undef, |
426 |
|
prefix => undef, |
427 |
|
previous_sibling => undef, |
428 |
}, |
}, |
429 |
}, |
}, |
430 |
attribute_definition => { |
attribute_definition => { |
431 |
node => sub { return $doc->create_attribute_definition ('e') }, |
node => sub { return $doc->create_attribute_definition ('e') }, |
432 |
attr_get => { |
attr_get => { |
433 |
attributes => undef, |
attributes => undef, |
434 |
|
first_child => undef, |
435 |
|
last_child => undef, |
436 |
|
local_name => undef, |
437 |
|
manakai_local_name => undef, |
438 |
|
namespace_uri => undef, |
439 |
|
next_sibling => undef, |
440 |
node_name => 'e', |
node_name => 'e', |
441 |
node_value => undef, |
node_value => undef, |
442 |
|
owner_document => $doc, |
443 |
|
parent_node => undef, |
444 |
|
prefix => undef, |
445 |
|
previous_sibling => undef, |
446 |
}, |
}, |
447 |
}, |
}, |
448 |
}; |
}; |
465 |
} |
} |
466 |
} |
} |
467 |
|
|
468 |
|
## Child node accessors' tests |
469 |
|
for my $parent (create_parent_nodes ()) { |
470 |
|
my $node1; |
471 |
|
my $node2; |
472 |
|
my $node3; |
473 |
|
if ($parent->node_type == $parent->DOCUMENT_TYPE_NODE) { |
474 |
|
$node1 = $doc->create_processing_instruction ('pi1', 'data1'); |
475 |
|
$node2 = $doc->create_processing_instruction ('pi2', 'data2'); |
476 |
|
$node3 = $doc->create_processing_instruction ('pi3', 'data3'); |
477 |
|
} elsif ($parent->node_type == $parent->DOCUMENT_NODE) { |
478 |
|
$node1 = $doc->create_comment ('comment1'); |
479 |
|
$node2 = $doc->create_comment ('comment2'); |
480 |
|
$node3 = $doc->create_comment ('comment3'); |
481 |
|
} else { |
482 |
|
$node1 = $doc->create_text_node ('text1'); |
483 |
|
$node2 = $doc->create_text_node ('text2'); |
484 |
|
$node3 = $doc->create_text_node ('text3'); |
485 |
|
} |
486 |
|
|
487 |
|
$parent->append_child ($node1); |
488 |
|
ok $parent->first_child, $node1, $parent->node_name."->first_child [1]"; |
489 |
|
ok $parent->last_child, $node1, $parent->node_name."->last_child [1]"; |
490 |
|
ok $node1->next_sibling, undef, $parent->node_name."->next_sibling [1]"; |
491 |
|
ok $node1->previous_sibling, undef, $parent->node_name."->previous_sibling [1]"; |
492 |
|
|
493 |
|
$parent->append_child ($node2); |
494 |
|
ok $parent->first_child, $node1, $parent->node_name."->first_child [2]"; |
495 |
|
ok $parent->last_child, $node2, $parent->node_name."->last_child [2]"; |
496 |
|
ok $node1->next_sibling, $node2, $parent->node_name."1->next_sibling [2]"; |
497 |
|
ok $node1->previous_sibling, undef, $parent->node_name."1->previous_sibling [2]"; |
498 |
|
ok $node2->next_sibling, undef, $parent->node_name."2->next_sibling [2]"; |
499 |
|
ok $node2->previous_sibling, $node1, $parent->node_name."2->previous_sibling [2]"; |
500 |
|
|
501 |
|
$parent->append_child ($node3); |
502 |
|
ok $parent->first_child, $node1, $parent->node_name."->first_child [3]"; |
503 |
|
ok $parent->last_child, $node3, $parent->node_name."->last_child [3]"; |
504 |
|
ok $node1->next_sibling, $node2, $parent->node_name."1->next_sibling [3]"; |
505 |
|
ok $node1->previous_sibling, undef, $parent->node_name."1->previous_sibling [3]"; |
506 |
|
ok $node2->next_sibling, $node3, $parent->node_name."2->next_sibling [3]"; |
507 |
|
ok $node2->previous_sibling, $node1, $parent->node_name."2->previous_sibling [3]"; |
508 |
|
ok $node3->next_sibling, undef, $parent->node_name."3->next_sibling [3]"; |
509 |
|
ok $node3->previous_sibling, $node2, $parent->node_name."3->previous_sibling [3]"; |
510 |
|
} |
511 |
|
|
512 |
|
## TODO: parent_node tests, as with append_child tests |
513 |
|
|
514 |
|
sub create_nodes () { |
515 |
|
( |
516 |
|
$doc->create_attribute ('attr1'), |
517 |
|
$doc->create_attribute_definition ('at1'), |
518 |
|
$doc->create_cdata_section ('cdata1'), |
519 |
|
$doc->create_comment ('comment1'), |
520 |
|
$doc->create_element ('element1'), |
521 |
|
$doc->create_element_type_definition ('et1'), |
522 |
|
$doc->create_general_entity ('entity1'), |
523 |
|
$doc->create_entity_reference ('entity-reference1'), |
524 |
|
$doc->implementation->create_document, |
525 |
|
$doc->create_document_fragment, |
526 |
|
$doc->create_document_type_definition ('dt1'), |
527 |
|
$doc->create_notation ('notation1'), |
528 |
|
$doc->create_processing_instruction ('pi1', 'pi1data'), |
529 |
|
$doc->create_text_node ('text1'), |
530 |
|
); |
531 |
|
} # create_nodes |
532 |
|
|
533 |
|
sub create_parent_nodes () { |
534 |
|
( |
535 |
|
$doc->create_attribute ('attr1'), |
536 |
|
$doc->create_attribute_definition ('at1'), |
537 |
|
$doc->create_element ('element1'), |
538 |
|
$doc->create_general_entity ('entity1'), |
539 |
|
$doc->create_entity_reference ('entity-reference1'), |
540 |
|
$doc->implementation->create_document, |
541 |
|
$doc->create_document_fragment, |
542 |
|
$doc->create_document_type_definition ('dt1'), |
543 |
|
); |
544 |
|
} # create_parent_nodes |
545 |
|
|
546 |
## License: Public Domain. |
## License: Public Domain. |
547 |
## $Date$ |
## $Date$ |