58 |
[NOTATION_NODE => 12], |
[NOTATION_NODE => 12], |
59 |
[ELEMENT_TYPE_DEFINITION_NODE => 81001], |
[ELEMENT_TYPE_DEFINITION_NODE => 81001], |
60 |
[ATTRIBUTE_DEFINITION_NODE => 81002], |
[ATTRIBUTE_DEFINITION_NODE => 81002], |
61 |
|
|
62 |
|
[DOCUMENT_POSITION_DISCONNECTED => 0x01], |
63 |
|
[DOCUMENT_POSITION_PRECEDING => 0x02], |
64 |
|
[DOCUMENT_POSITION_FOLLOWING => 0x04], |
65 |
|
[DOCUMENT_POSITION_CONTAINS => 0x08], |
66 |
|
[DOCUMENT_POSITION_CONTAINED_BY => 0x10], |
67 |
|
[DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC => 0x20], |
68 |
]; |
]; |
69 |
|
|
70 |
my $tests = { |
my $tests = { |
73 |
attr_get => { |
attr_get => { |
74 |
manakai_attribute_type => 0, |
manakai_attribute_type => 0, |
75 |
base_uri => undef, |
base_uri => undef, |
76 |
|
manakai_expanded_uri => 'a', |
77 |
first_child => undef, |
first_child => undef, |
78 |
last_child => undef, |
last_child => undef, |
79 |
local_name => 'a', |
local_name => 'a', |
91 |
attributes => undef, |
attributes => undef, |
92 |
}, |
}, |
93 |
attr_get_bool => { |
attr_get_bool => { |
94 |
|
has_attributes => 0, |
95 |
|
has_child_nodes => 0, |
96 |
specified => 1, |
specified => 1, |
97 |
}, |
}, |
98 |
}, |
}, |
105 |
attr_get => { |
attr_get => { |
106 |
manakai_attribute_type => 0, |
manakai_attribute_type => 0, |
107 |
base_uri => undef, |
base_uri => undef, |
108 |
|
manakai_expanded_uri => 'a', |
109 |
local_name => 'a', |
local_name => 'a', |
110 |
manakai_local_name => 'a', |
manakai_local_name => 'a', |
111 |
namespace_uri => undef, |
namespace_uri => undef, |
121 |
attributes => undef, |
attributes => undef, |
122 |
}, |
}, |
123 |
attr_get_bool => { |
attr_get_bool => { |
124 |
|
has_attributes => 0, |
125 |
|
has_child_nodes => 1, |
126 |
specified => 1, |
specified => 1, |
127 |
}, |
}, |
128 |
}, |
}, |
130 |
node => sub { return $doc->create_attribute_ns (undef, 'a') }, |
node => sub { return $doc->create_attribute_ns (undef, 'a') }, |
131 |
attr_get => { |
attr_get => { |
132 |
base_uri => undef, |
base_uri => undef, |
133 |
|
manakai_expanded_uri => 'a', |
134 |
local_name => 'a', |
local_name => 'a', |
135 |
manakai_local_name => 'a', |
manakai_local_name => 'a', |
136 |
namespace_uri => undef, |
namespace_uri => undef, |
145 |
attributes => undef, |
attributes => undef, |
146 |
previous_sibling => undef, |
previous_sibling => undef, |
147 |
}, |
}, |
148 |
|
attr_get_bool => { |
149 |
|
has_attributes => 0, |
150 |
|
has_child_nodes => 0, |
151 |
|
specified => 1, |
152 |
|
}, |
153 |
}, |
}, |
154 |
attr_ns_prefixed => { |
attr_ns_prefixed => { |
155 |
node => sub { return $doc->create_attribute_ns ('http://test/', 'a:b') }, |
node => sub { return $doc->create_attribute_ns ('http://test/', 'a:b') }, |
156 |
attr_get => { |
attr_get => { |
157 |
base_uri => undef, |
base_uri => undef, |
158 |
|
manakai_expanded_uri => 'http://test/b', |
159 |
local_name => 'b', |
local_name => 'b', |
160 |
manakai_local_name => 'b', |
manakai_local_name => 'b', |
161 |
namespace_uri => 'http://test/', |
namespace_uri => 'http://test/', |
170 |
attributes => undef, |
attributes => undef, |
171 |
previous_sibling => undef, |
previous_sibling => undef, |
172 |
}, |
}, |
173 |
|
attr_get_bool => { |
174 |
|
has_attributes => 0, |
175 |
|
has_child_nodes => 0, |
176 |
|
specified => 1, |
177 |
|
}, |
178 |
}, |
}, |
179 |
cdatasection => { |
cdatasection => { |
180 |
node => sub { return $doc->create_cdata_section ('cdatadata') }, |
node => sub { return $doc->create_cdata_section ('cdatadata') }, |
181 |
attr_get => { |
attr_get => { |
182 |
base_uri => undef, |
base_uri => undef, |
183 |
|
manakai_expanded_uri => undef, |
184 |
first_child => undef, |
first_child => undef, |
185 |
last_child => undef, |
last_child => undef, |
186 |
local_name => undef, |
local_name => undef, |
196 |
attributes => undef, |
attributes => undef, |
197 |
previous_sibling => undef, |
previous_sibling => undef, |
198 |
}, |
}, |
199 |
|
attr_get_bool => { |
200 |
|
has_attributes => 0, |
201 |
|
has_child_nodes => 0, |
202 |
|
}, |
203 |
}, |
}, |
204 |
cdatasectionmde => { |
cdatasectionmde => { |
205 |
node => sub { return $doc->create_cdata_section ('cdata]]>data') }, |
node => sub { return $doc->create_cdata_section ('cdata]]>data') }, |
206 |
attr_get => { |
attr_get => { |
207 |
base_uri => undef, |
base_uri => undef, |
208 |
|
manakai_expanded_uri => undef, |
209 |
first_child => undef, |
first_child => undef, |
210 |
last_child => undef, |
last_child => undef, |
211 |
local_name => undef, |
local_name => undef, |
221 |
attributes => undef, |
attributes => undef, |
222 |
previous_sibling => undef, |
previous_sibling => undef, |
223 |
}, |
}, |
224 |
|
attr_get_bool => { |
225 |
|
has_attributes => 0, |
226 |
|
has_child_nodes => 0, |
227 |
|
}, |
228 |
}, |
}, |
229 |
comment => { |
comment => { |
230 |
node => sub { return $doc->create_comment ('commentdata') }, |
node => sub { return $doc->create_comment ('commentdata') }, |
231 |
attr_get => { |
attr_get => { |
232 |
base_uri => undef, |
base_uri => undef, |
233 |
|
manakai_expanded_uri => undef, |
234 |
first_child => undef, |
first_child => undef, |
235 |
last_child => undef, |
last_child => undef, |
236 |
local_name => undef, |
local_name => undef, |
245 |
data => 'commentdata', |
data => 'commentdata', |
246 |
attributes => undef, |
attributes => undef, |
247 |
previous_sibling => undef, |
previous_sibling => undef, |
248 |
|
}, |
249 |
|
attr_get_bool => { |
250 |
|
has_attributes => 0, |
251 |
|
has_child_nodes => 0, |
252 |
}, |
}, |
253 |
}, |
}, |
254 |
commentcom1 => { |
commentcom1 => { |
255 |
node => sub { return $doc->create_comment ('comment--data') }, |
node => sub { return $doc->create_comment ('comment--data') }, |
256 |
attr_get => { |
attr_get => { |
257 |
base_uri => undef, |
base_uri => undef, |
258 |
|
manakai_expanded_uri => undef, |
259 |
first_child => undef, |
first_child => undef, |
260 |
last_child => undef, |
last_child => undef, |
261 |
local_name => undef, |
local_name => undef, |
271 |
attributes => undef, |
attributes => undef, |
272 |
previous_sibling => undef, |
previous_sibling => undef, |
273 |
}, |
}, |
274 |
|
attr_get_bool => { |
275 |
|
has_attributes => 0, |
276 |
|
has_child_nodes => 0, |
277 |
|
}, |
278 |
}, |
}, |
279 |
commentcom2 => { |
commentcom2 => { |
280 |
node => sub { return $doc->create_comment ('commentdata-') }, |
node => sub { return $doc->create_comment ('commentdata-') }, |
281 |
attr_get => { |
attr_get => { |
282 |
base_uri => undef, |
base_uri => undef, |
283 |
|
manakai_expanded_uri => undef, |
284 |
first_child => undef, |
first_child => undef, |
285 |
last_child => undef, |
last_child => undef, |
286 |
local_name => undef, |
local_name => undef, |
296 |
attributes => undef, |
attributes => undef, |
297 |
previous_sibling => undef, |
previous_sibling => undef, |
298 |
}, |
}, |
299 |
|
attr_get_bool => { |
300 |
|
has_attributes => 0, |
301 |
|
has_child_nodes => 0, |
302 |
|
}, |
303 |
}, |
}, |
304 |
document => { |
document => { |
305 |
node => sub { return $doc }, |
node => sub { return $doc }, |
308 |
base_uri => undef, |
base_uri => undef, |
309 |
document_uri => undef, |
document_uri => undef, |
310 |
manakai_entity_base_uri => undef, |
manakai_entity_base_uri => undef, |
311 |
|
manakai_expanded_uri => undef, |
312 |
first_child => undef, |
first_child => undef, |
313 |
implementation => $dom, |
implementation => $dom, |
314 |
last_child => undef, |
last_child => undef, |
327 |
}, |
}, |
328 |
attr_get_bool => { |
attr_get_bool => { |
329 |
all_declarations_processed => 0, |
all_declarations_processed => 0, |
330 |
|
has_attributes => 0, |
331 |
|
has_child_nodes => 0, |
332 |
manakai_is_html => 0, |
manakai_is_html => 0, |
333 |
strict_error_checking => 1, |
strict_error_checking => 1, |
334 |
xml_standalone => 0, |
xml_standalone => 0, |
339 |
attr_get => { |
attr_get => { |
340 |
attributes => undef, |
attributes => undef, |
341 |
base_uri => undef, |
base_uri => undef, |
342 |
|
manakai_expanded_uri => undef, |
343 |
first_child => undef, |
first_child => undef, |
344 |
last_child => undef, |
last_child => undef, |
345 |
local_name => undef, |
local_name => undef, |
353 |
prefix => undef, |
prefix => undef, |
354 |
previous_sibling => undef, |
previous_sibling => undef, |
355 |
}, |
}, |
356 |
|
attr_get_bool => { |
357 |
|
has_attributes => 0, |
358 |
|
has_child_nodes => 0, |
359 |
|
}, |
360 |
}, |
}, |
361 |
document_type => { |
document_type => { |
362 |
node => sub { return $doc->implementation->create_document_type ('n') }, |
node => sub { return $doc->implementation->create_document_type ('n') }, |
365 |
base_uri => undef, |
base_uri => undef, |
366 |
declaration_base_uri => undef, |
declaration_base_uri => undef, |
367 |
manakai_declaration_base_uri => undef, |
manakai_declaration_base_uri => undef, |
368 |
|
manakai_expanded_uri => undef, |
369 |
first_child => undef, |
first_child => undef, |
370 |
implementation => $dom, |
implementation => $dom, |
371 |
last_child => undef, |
last_child => undef, |
382 |
public_id => undef, |
public_id => undef, |
383 |
system_id => undef, |
system_id => undef, |
384 |
}, |
}, |
385 |
|
attr_get_bool => { |
386 |
|
has_attributes => 0, |
387 |
|
has_child_nodes => 0, |
388 |
|
}, |
389 |
}, |
}, |
390 |
document_type_definition => { |
document_type_definition => { |
391 |
node => sub { return $doc->create_document_type_definition ('n') }, |
node => sub { return $doc->create_document_type_definition ('n') }, |
394 |
base_uri => undef, |
base_uri => undef, |
395 |
declaration_base_uri => undef, |
declaration_base_uri => undef, |
396 |
manakai_declaration_base_uri => undef, |
manakai_declaration_base_uri => undef, |
397 |
|
manakai_expanded_uri => undef, |
398 |
first_child => undef, |
first_child => undef, |
399 |
implementation => $dom, |
implementation => $dom, |
400 |
last_child => undef, |
last_child => undef, |
411 |
public_id => undef, |
public_id => undef, |
412 |
system_id => undef, |
system_id => undef, |
413 |
}, |
}, |
414 |
|
attr_get_bool => { |
415 |
|
has_attributes => 0, |
416 |
|
has_child_nodes => 0, |
417 |
|
}, |
418 |
}, |
}, |
419 |
element => { |
element => { |
420 |
node => sub { return $doc->create_element ('e') }, |
node => sub { return $doc->create_element ('e') }, |
422 |
## TODO: attributes => |
## TODO: attributes => |
423 |
base_uri => undef, |
base_uri => undef, |
424 |
manakai_base_uri => undef, |
manakai_base_uri => undef, |
425 |
|
manakai_expanded_uri => 'e', |
426 |
first_child => undef, |
first_child => undef, |
427 |
last_child => undef, |
last_child => undef, |
428 |
local_name => 'e', |
local_name => 'e', |
436 |
prefix => undef, |
prefix => undef, |
437 |
previous_sibling => undef, |
previous_sibling => undef, |
438 |
}, |
}, |
439 |
|
attr_get_bool => { |
440 |
|
has_attributes => 0, |
441 |
|
has_child_nodes => 0, |
442 |
|
}, |
443 |
}, |
}, |
444 |
element_ns_default => { |
element_ns_default => { |
445 |
node => sub { return $doc->create_element_ns ('http://test/', 'f') }, |
node => sub { return $doc->create_element_ns ('http://test/', 'f') }, |
447 |
## TODO: attributes => |
## TODO: attributes => |
448 |
base_uri => undef, |
base_uri => undef, |
449 |
manakai_base_uri => undef, |
manakai_base_uri => undef, |
450 |
|
manakai_expanded_uri => 'http://test/f', |
451 |
first_child => undef, |
first_child => undef, |
452 |
last_child => undef, |
last_child => undef, |
453 |
local_name => 'f', |
local_name => 'f', |
461 |
prefix => undef, |
prefix => undef, |
462 |
previous_sibling => undef, |
previous_sibling => undef, |
463 |
}, |
}, |
464 |
|
attr_get_bool => { |
465 |
|
has_attributes => 0, |
466 |
|
has_child_nodes => 0, |
467 |
|
}, |
468 |
}, |
}, |
469 |
element_ns_prefiexed => { |
element_ns_prefiexed => { |
470 |
node => sub { return $doc->create_element_ns ('http://test/', 'e:f') }, |
node => sub { return $doc->create_element_ns ('http://test/', 'e:f') }, |
472 |
## TODO: attributes => |
## TODO: attributes => |
473 |
base_uri => undef, |
base_uri => undef, |
474 |
manakai_base_uri => undef, |
manakai_base_uri => undef, |
475 |
|
manakai_expanded_uri => 'http://test/f', |
476 |
first_child => undef, |
first_child => undef, |
477 |
last_child => undef, |
last_child => undef, |
478 |
local_name => 'f', |
local_name => 'f', |
486 |
prefix => 'e', |
prefix => 'e', |
487 |
previous_sibling => undef, |
previous_sibling => undef, |
488 |
}, |
}, |
489 |
|
attr_get_bool => { |
490 |
|
has_attributes => 0, |
491 |
|
has_child_nodes => 0, |
492 |
|
}, |
493 |
}, |
}, |
494 |
entity => { |
entity => { |
495 |
node => sub { return $doc->create_general_entity ('e') }, |
node => sub { return $doc->create_general_entity ('e') }, |
499 |
manakai_declaration_base_uri => undef, |
manakai_declaration_base_uri => undef, |
500 |
manakai_entity_base_uri => undef, |
manakai_entity_base_uri => undef, |
501 |
manakai_entity_uri => undef, |
manakai_entity_uri => undef, |
502 |
|
manakai_expanded_uri => undef, |
503 |
first_child => undef, |
first_child => undef, |
504 |
last_child => undef, |
last_child => undef, |
505 |
next_sibling => undef, |
next_sibling => undef, |
512 |
public_id => undef, |
public_id => undef, |
513 |
system_id => undef, |
system_id => undef, |
514 |
}, |
}, |
515 |
|
attr_get_bool => { |
516 |
|
has_attributes => 0, |
517 |
|
has_child_nodes => 0, |
518 |
|
}, |
519 |
}, |
}, |
520 |
entity_reference => { |
entity_reference => { |
521 |
node => sub { return $doc->create_entity_reference ('e') }, |
node => sub { return $doc->create_entity_reference ('e') }, |
523 |
attributes => undef, |
attributes => undef, |
524 |
base_uri => undef, |
base_uri => undef, |
525 |
manakai_entity_base_uri => undef, |
manakai_entity_base_uri => undef, |
526 |
|
manakai_expanded_uri => undef, |
527 |
first_child => undef, |
first_child => undef, |
528 |
last_child => undef, |
last_child => undef, |
529 |
local_name => undef, |
local_name => undef, |
540 |
attr_get_bool => { |
attr_get_bool => { |
541 |
manakai_expanded => 0, |
manakai_expanded => 0, |
542 |
manakai_external => 0, |
manakai_external => 0, |
543 |
|
has_attributes => 0, |
544 |
|
has_child_nodes => 0, |
545 |
}, |
}, |
546 |
}, |
}, |
547 |
notation => { |
notation => { |
550 |
attributes => undef, |
attributes => undef, |
551 |
base_uri => undef, |
base_uri => undef, |
552 |
manakai_declaration_base_uri => undef, |
manakai_declaration_base_uri => undef, |
553 |
|
manakai_expanded_uri => undef, |
554 |
first_child => undef, |
first_child => undef, |
555 |
last_child => undef, |
last_child => undef, |
556 |
local_name => undef, |
local_name => undef, |
566 |
public_id => undef, |
public_id => undef, |
567 |
system_id => undef, |
system_id => undef, |
568 |
}, |
}, |
569 |
|
attr_get_bool => { |
570 |
|
has_attributes => 0, |
571 |
|
has_child_nodes => 0, |
572 |
|
}, |
573 |
}, |
}, |
574 |
processing_instruction => { |
processing_instruction => { |
575 |
node => sub { return $doc->create_processing_instruction ('t', 'd') }, |
node => sub { return $doc->create_processing_instruction ('t', 'd') }, |
577 |
attributes => undef, |
attributes => undef, |
578 |
base_uri => undef, |
base_uri => undef, |
579 |
manakai_base_uri => undef, |
manakai_base_uri => undef, |
580 |
|
manakai_expanded_uri => undef, |
581 |
first_child => undef, |
first_child => undef, |
582 |
last_child => undef, |
last_child => undef, |
583 |
local_name => undef, |
local_name => undef, |
591 |
prefix => undef, |
prefix => undef, |
592 |
previous_sibling => undef, |
previous_sibling => undef, |
593 |
}, |
}, |
594 |
|
attr_get_bool => { |
595 |
|
has_attributes => 0, |
596 |
|
has_child_nodes => 0, |
597 |
|
}, |
598 |
}, |
}, |
599 |
text => { |
text => { |
600 |
node => sub { return $doc->create_text_node ('textdata') }, |
node => sub { return $doc->create_text_node ('textdata') }, |
601 |
attr_get => { |
attr_get => { |
602 |
attributes => undef, |
attributes => undef, |
603 |
base_uri => undef, |
base_uri => undef, |
604 |
|
manakai_expanded_uri => undef, |
605 |
first_child => undef, |
first_child => undef, |
606 |
last_child => undef, |
last_child => undef, |
607 |
local_name => undef, |
local_name => undef, |
615 |
prefix => undef, |
prefix => undef, |
616 |
previous_sibling => undef, |
previous_sibling => undef, |
617 |
}, |
}, |
618 |
|
attr_get_bool => { |
619 |
|
has_attributes => 0, |
620 |
|
has_child_nodes => 0, |
621 |
|
}, |
622 |
}, |
}, |
623 |
element_type_definition => { |
element_type_definition => { |
624 |
node => sub { return $doc->create_element_type_definition ('e') }, |
node => sub { return $doc->create_element_type_definition ('e') }, |
625 |
attr_get => { |
attr_get => { |
626 |
attributes => undef, |
attributes => undef, |
627 |
base_uri => undef, |
base_uri => undef, |
628 |
|
manakai_expanded_uri => undef, |
629 |
first_child => undef, |
first_child => undef, |
630 |
last_child => undef, |
last_child => undef, |
631 |
local_name => undef, |
local_name => undef, |
639 |
prefix => undef, |
prefix => undef, |
640 |
previous_sibling => undef, |
previous_sibling => undef, |
641 |
}, |
}, |
642 |
|
attr_get_bool => { |
643 |
|
has_attributes => 0, |
644 |
|
has_child_nodes => 0, |
645 |
|
}, |
646 |
}, |
}, |
647 |
attribute_definition => { |
attribute_definition => { |
648 |
node => sub { return $doc->create_attribute_definition ('e') }, |
node => sub { return $doc->create_attribute_definition ('e') }, |
651 |
base_uri => undef, |
base_uri => undef, |
652 |
declared_type => 0, |
declared_type => 0, |
653 |
default_type => 0, |
default_type => 0, |
654 |
|
manakai_expanded_uri => undef, |
655 |
first_child => undef, |
first_child => undef, |
656 |
last_child => undef, |
last_child => undef, |
657 |
local_name => undef, |
local_name => undef, |
665 |
prefix => undef, |
prefix => undef, |
666 |
previous_sibling => undef, |
previous_sibling => undef, |
667 |
}, |
}, |
668 |
|
attr_get_bool => { |
669 |
|
has_attributes => 0, |
670 |
|
has_child_nodes => 0, |
671 |
|
}, |
672 |
}, |
}, |
673 |
}; |
}; |
674 |
|
|
1337 |
ok $dt->base_uri, q<http://doc.test/>, "DT->base_uri [1]"; |
ok $dt->base_uri, q<http://doc.test/>, "DT->base_uri [1]"; |
1338 |
} |
} |
1339 |
|
|
1340 |
|
## |hasAttribute| |
1341 |
|
{ |
1342 |
|
my $el = $doc->create_element ('e'); |
1343 |
|
ok $el->has_attributes ? 1 : 0, 0, "Element->has_attributes [0]"; |
1344 |
|
|
1345 |
|
$el->set_attribute (a => 'b'); |
1346 |
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [1]"; |
1347 |
|
|
1348 |
|
$el->set_attribute (c => 'd'); |
1349 |
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [2]"; |
1350 |
|
|
1351 |
|
$el->remove_attribute ('c'); |
1352 |
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [3]"; |
1353 |
|
|
1354 |
|
$el->get_attribute_node ('a')->specified (0); |
1355 |
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [4]"; |
1356 |
|
|
1357 |
|
$el->remove_attribute ('a'); |
1358 |
|
ok $el->has_attributes ? 1 : 0, 0, "Element->has_attributes [5]"; |
1359 |
|
} |
1360 |
|
|
1361 |
|
## |hasChildNodes| |
1362 |
|
{ |
1363 |
|
my $doc2 = $doc->implementation->create_document; |
1364 |
|
|
1365 |
|
ok $doc2->has_child_nodes ? 1 : 0, 0, "Document->has_child_nodes [0]"; |
1366 |
|
|
1367 |
|
$doc2->append_child ($doc2->create_comment ('')); |
1368 |
|
ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [1]"; |
1369 |
|
|
1370 |
|
$doc2->append_child ($doc2->create_comment ('')); |
1371 |
|
ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [2]"; |
1372 |
|
|
1373 |
|
$doc2->remove_child ($doc2->first_child); |
1374 |
|
ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [3]"; |
1375 |
|
|
1376 |
|
$doc2->remove_child ($doc2->first_child); |
1377 |
|
ok $doc2->has_child_nodes ? 1 : 0, 0, "Document->has_child_nodes [4]"; |
1378 |
|
} |
1379 |
|
|
1380 |
|
## |compareDocumentPosition| |
1381 |
|
{ |
1382 |
|
my $e1 = $doc->create_element ('e1'); |
1383 |
|
my $e2 = $doc->create_element ('e2'); |
1384 |
|
|
1385 |
|
my $dp2 = $e1->compare_document_position ($e2); |
1386 |
|
|
1387 |
|
ok $dp2 & $e1->DOCUMENT_POSITION_DISCONNECTED ? 1 : 0, 1, "cdp [1]"; |
1388 |
|
ok $dp2 & $e1->DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ? 1 : 0, 1, "edp [2]"; |
1389 |
|
ok (($dp2 & $e1->DOCUMENT_POSITION_PRECEDING || |
1390 |
|
$dp2 & $e1->DOCUMENT_POSITION_FOLLOWING) ? 1 : 0, 1, "cdp [3]"); |
1391 |
|
|
1392 |
|
my $dp1 = $e2->compare_document_position ($e1); |
1393 |
|
|
1394 |
|
ok $dp1 & $e1->DOCUMENT_POSITION_DISCONNECTED ? 1 : 0, 1, "cdp [4]"; |
1395 |
|
ok $dp1 & $e1->DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ? 1 : 0, 1, "cdp [5]"; |
1396 |
|
ok (($dp1 & $e1->DOCUMENT_POSITION_PRECEDING || |
1397 |
|
$dp1 & $e1->DOCUMENT_POSITION_FOLLOWING) ? 1 : 0, 1, "cdp [6]"); |
1398 |
|
} |
1399 |
|
|
1400 |
|
{ |
1401 |
|
my $e1 = $doc->create_element ('e1'); |
1402 |
|
my $e2 = $doc->create_element ('e2'); |
1403 |
|
|
1404 |
|
my $pe = $doc->create_element ('pe'); |
1405 |
|
$pe->append_child ($e1); |
1406 |
|
$pe->append_child ($e2); |
1407 |
|
|
1408 |
|
my $dp2 = $e1->compare_document_position ($e2); |
1409 |
|
|
1410 |
|
ok $dp2 & $e1->DOCUMENT_POSITION_FOLLOWING ? 1 : 0, 1, "cde [7]"; |
1411 |
|
|
1412 |
|
my $dp1 = $e2->compare_document_position ($e1); |
1413 |
|
|
1414 |
|
ok $dp1 & $e1->DOCUMENT_POSITION_PRECEDING ? 1 : 0, 1, "cde [8]"; |
1415 |
|
} |
1416 |
|
## TODO: Apparently compare_document_position requires more tests. |
1417 |
|
|
1418 |
|
## |lookupNamespaceURI| |
1419 |
|
{ |
1420 |
|
for my $node (create_nodes ()) { |
1421 |
|
ok $node->lookup_namespace_uri ('ns1'), undef, $node->node_name . " lnu [0]"; |
1422 |
|
ok $node->lookup_namespace_uri ('xml'), undef, $node->node_name . " lnu [1]"; |
1423 |
|
ok $node->lookup_namespace_uri ('xmlns'), undef, $node->node_name . " lnu [2]"; |
1424 |
|
ok $node->lookup_namespace_uri (''), undef, $node->node_name . " lnu [3]"; |
1425 |
|
ok $node->lookup_namespace_uri (undef), undef, $node->node_name . " lnu [4]"; |
1426 |
|
} |
1427 |
|
|
1428 |
|
my $el = $doc->create_element_ns ('about:', 'el'); |
1429 |
|
ok $el->lookup_namespace_uri ('ns1'), undef, 'Element->lnu [0]'; |
1430 |
|
|
1431 |
|
$el->prefix ('ns1'); |
1432 |
|
ok $el->lookup_namespace_uri ('ns1'), 'about:', 'Element->lnu [1]'; |
1433 |
|
|
1434 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns:ns1', 'DAV:'); |
1435 |
|
ok $el->lookup_namespace_uri ('ns1'), 'about:', 'Element->lnu [2]'; |
1436 |
|
|
1437 |
|
$el->prefix (undef); |
1438 |
|
ok $el->lookup_namespace_uri ('ns1'), 'DAV:', 'Element->lnu [3]'; |
1439 |
|
} |
1440 |
|
|
1441 |
|
## |lookupPrefix| |
1442 |
|
{ |
1443 |
|
for my $node (create_nodes ()) { |
1444 |
|
ok $node->lookup_prefix ('http://test/'), undef, $node->node_name . "lp [0]"; |
1445 |
|
ok $node->lookup_prefix ('http://www.w3.org/XML/1998/namespace'), undef, $node->node_name . "lp [1]"; |
1446 |
|
ok $node->lookup_prefix ('http://www.w3.org/2000/xmlns/'), undef, $node->node_name . "lp [2]"; |
1447 |
|
ok $node->lookup_prefix ('http://www.w3.org/1999/xhtml'), undef, $node->node_name . "lp [3]"; |
1448 |
|
ok $node->lookup_prefix (''), undef, $node->node_name . "lp [4]"; |
1449 |
|
ok $node->lookup_prefix (undef), undef, $node->node_name . "lp [5]"; |
1450 |
|
} |
1451 |
|
|
1452 |
|
my $el = $doc->create_element_ns ('http://test/', 'e'); |
1453 |
|
ok $el->lookup_prefix ('ns'), undef, "Element->lp [0]";; |
1454 |
|
|
1455 |
|
my $el2 = $doc->create_element_ns ('http://test/', 'f'); |
1456 |
|
$el2->append_child ($el); |
1457 |
|
$el2->prefix ('ns'); |
1458 |
|
ok $el->lookup_prefix ('http://test/'), 'ns', "Element->lp [1]"; |
1459 |
|
|
1460 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns:a', |
1461 |
|
'http://test/'); |
1462 |
|
ok $el->lookup_prefix ('http://test/'), 'a', "Element->lp [2]"; |
1463 |
|
|
1464 |
|
$el->prefix ('b'); |
1465 |
|
ok $el->lookup_prefix ('http://test/'), 'b', "Element->lp [3]"; |
1466 |
|
} |
1467 |
|
|
1468 |
|
## |isDefaultNamespace| |
1469 |
|
{ |
1470 |
|
for my $node (create_nodes ()) { |
1471 |
|
next if $node->node_type == 1; |
1472 |
|
ok $node->is_default_namespace ('about:') ? 1 : 0, 0, $node->node_name."idn[0]"; |
1473 |
|
ok $node->is_default_namespace ('http://www.w3.org/XML/1998/namespace') ? 1 : 0, 0, $node->node_name."idn[2]"; |
1474 |
|
ok $node->is_default_namespace ('http://www.w3.org/2000/xmlns/') ? 1 : 0, 0, $node->node_name."idn[3]"; |
1475 |
|
ok $node->is_default_namespace ('') ? 1 : 0, 0, $node->node_name."idn[4]"; |
1476 |
|
ok $node->is_default_namespace (undef) ? 1 : 0, 0, $node->node_name."idn[5]"; |
1477 |
|
} |
1478 |
|
|
1479 |
|
my $el = $doc->create_element_ns ('about:', 'el'); |
1480 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [0]"; |
1481 |
|
|
1482 |
|
$el->prefix ('ns1'); |
1483 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [1]"; |
1484 |
|
|
1485 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:'); |
1486 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [2]"; |
1487 |
|
|
1488 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'about:'); |
1489 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [3]"; |
1490 |
|
|
1491 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', ''); |
1492 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [4]"; |
1493 |
|
} |
1494 |
|
|
1495 |
|
{ |
1496 |
|
my $el = $doc->create_element_ns ('about:', 'p:el'); |
1497 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [5]"; |
1498 |
|
|
1499 |
|
$el->prefix ('ns1'); |
1500 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [6]"; |
1501 |
|
|
1502 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:'); |
1503 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [7]"; |
1504 |
|
|
1505 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'about:'); |
1506 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [8]"; |
1507 |
|
|
1508 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', ''); |
1509 |
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [9]"; |
1510 |
|
} |
1511 |
|
|
1512 |
|
{ |
1513 |
|
my $el = $doc->create_element ('e'); |
1514 |
|
|
1515 |
|
## NOTE: This might look like strange, but it is how it is defined! |
1516 |
|
ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [10]"; |
1517 |
|
ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [11]"; |
1518 |
|
|
1519 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:'); |
1520 |
|
ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [12]"; |
1521 |
|
ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [13]"; |
1522 |
|
|
1523 |
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', ''); |
1524 |
|
ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [14]"; |
1525 |
|
ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [15]"; |
1526 |
|
} |
1527 |
|
|
1528 |
|
## |manakaiParentElement| |
1529 |
|
{ |
1530 |
|
my $el = $doc->create_element ('el'); |
1531 |
|
ok $el->manakai_parent_element, undef, "mpe [0]"; |
1532 |
|
|
1533 |
|
my $el2 = $doc->create_element ('el2'); |
1534 |
|
$el->append_child ($el2); |
1535 |
|
ok $el2->manakai_parent_element, $el, "mpe [1]"; |
1536 |
|
|
1537 |
|
my $er1 = $doc->create_entity_reference ('er1'); |
1538 |
|
$er1->manakai_set_read_only (0, 1); |
1539 |
|
$el->append_child ($er1); |
1540 |
|
$er1->append_child ($el2); |
1541 |
|
ok $el2->manakai_parent_element, $el, "mpe [1]"; |
1542 |
|
} |
1543 |
|
|
1544 |
|
{ |
1545 |
|
my $el = $doc->create_element ('el'); |
1546 |
|
my $t1 = $doc->create_text_node ('t1'); |
1547 |
|
my $t2 = $doc->create_text_node ('t2'); |
1548 |
|
$el->append_child ($t1); |
1549 |
|
$el->append_child ($t2); |
1550 |
|
$el->normalize; |
1551 |
|
|
1552 |
|
ok $el->text_content, 't1t2', 'normalize [0]'; |
1553 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [1]'; |
1554 |
|
} |
1555 |
|
|
1556 |
|
{ |
1557 |
|
my $el = $doc->create_element ('el'); |
1558 |
|
my $t1 = $doc->create_text_node ('t1'); |
1559 |
|
my $t2 = $doc->create_text_node ('t2'); |
1560 |
|
my $t3 = $doc->create_text_node ('t3'); |
1561 |
|
my $t4 = $doc->create_text_node ('t4'); |
1562 |
|
$el->append_child ($t1); |
1563 |
|
$el->append_child ($t2); |
1564 |
|
$el->append_child ($t3); |
1565 |
|
$el->append_child ($t4); |
1566 |
|
$el->normalize; |
1567 |
|
|
1568 |
|
ok $el->text_content, 't1t2t3t4', 'normalize [2]'; |
1569 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [3]'; |
1570 |
|
} |
1571 |
|
|
1572 |
|
{ |
1573 |
|
my $el = $doc->create_element ('el'); |
1574 |
|
my $t1 = $doc->create_text_node ('t1'); |
1575 |
|
my $t2 = $doc->create_text_node ('t2'); |
1576 |
|
my $c1 = $doc->create_cdata_section ('c1'); |
1577 |
|
my $t3 = $doc->create_text_node ('t3'); |
1578 |
|
my $t4 = $doc->create_text_node ('t4'); |
1579 |
|
$el->append_child ($t1); |
1580 |
|
$el->append_child ($t2); |
1581 |
|
$el->append_child ($c1); |
1582 |
|
$el->append_child ($t3); |
1583 |
|
$el->append_child ($t4); |
1584 |
|
$el->normalize; |
1585 |
|
|
1586 |
|
ok $el->text_content, 't1t2c1t3t4', 'normalize [4]'; |
1587 |
|
ok 0+@{$el->child_nodes}, 3, 'normalize [5]'; |
1588 |
|
ok $el->first_child->text_content, 't1t2', 'normalize [6]'; |
1589 |
|
ok $el->last_child->text_content, 't3t4', 'normalize [7]'; |
1590 |
|
} |
1591 |
|
|
1592 |
|
{ |
1593 |
|
my $el = $doc->create_element ('el'); |
1594 |
|
my $t1 = $doc->create_text_node ('t1'); |
1595 |
|
my $t2 = $doc->create_text_node (''); |
1596 |
|
$el->append_child ($t1); |
1597 |
|
$el->append_child ($t2); |
1598 |
|
$el->normalize; |
1599 |
|
|
1600 |
|
ok $el->text_content, 't1', 'normalize [8]'; |
1601 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [9]'; |
1602 |
|
} |
1603 |
|
|
1604 |
|
{ |
1605 |
|
my $el = $doc->create_element ('el'); |
1606 |
|
my $t1 = $doc->create_text_node (''); |
1607 |
|
my $t2 = $doc->create_text_node ('t2'); |
1608 |
|
$el->append_child ($t1); |
1609 |
|
$el->append_child ($t2); |
1610 |
|
$el->normalize; |
1611 |
|
|
1612 |
|
ok $el->text_content, 't2', 'normalize [10]'; |
1613 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [11]'; |
1614 |
|
} |
1615 |
|
|
1616 |
|
{ |
1617 |
|
my $el = $doc->create_element ('el'); |
1618 |
|
my $t1 = $doc->create_text_node (''); |
1619 |
|
$el->append_child ($t1); |
1620 |
|
$el->normalize; |
1621 |
|
|
1622 |
|
ok $el->text_content, '', 'normalize [12]'; |
1623 |
|
ok 0+@{$el->child_nodes}, 0, 'normalize [13]'; |
1624 |
|
} |
1625 |
|
|
1626 |
|
{ |
1627 |
|
my $pe = $doc->create_element ('pe'); |
1628 |
|
my $el = $doc->create_element ('el'); |
1629 |
|
my $t1 = $doc->create_text_node ('t1'); |
1630 |
|
my $t2 = $doc->create_text_node ('t2'); |
1631 |
|
$el->append_child ($t1); |
1632 |
|
$el->append_child ($t2); |
1633 |
|
$pe->append_child ($el); |
1634 |
|
$pe->normalize; |
1635 |
|
|
1636 |
|
ok $el->text_content, 't1t2', 'normalize [14]'; |
1637 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [15]'; |
1638 |
|
} |
1639 |
|
|
1640 |
|
{ |
1641 |
|
my $pe = $doc->create_element ('pe'); |
1642 |
|
my $el = $doc->create_attribute ('a'); |
1643 |
|
my $t1 = $doc->create_text_node ('t1'); |
1644 |
|
my $t2 = $doc->create_text_node ('t2'); |
1645 |
|
$el->append_child ($t1); |
1646 |
|
$el->append_child ($t2); |
1647 |
|
$pe->set_attribute_node ($el); |
1648 |
|
$pe->normalize; |
1649 |
|
|
1650 |
|
ok $el->text_content, 't1t2', 'normalize [16]'; |
1651 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [17]'; |
1652 |
|
} |
1653 |
|
|
1654 |
|
{ |
1655 |
|
my $pe = $doc->create_element_type_definition ('pe'); |
1656 |
|
my $el = $doc->create_attribute_definition ('a'); |
1657 |
|
my $t1 = $doc->create_text_node ('t1'); |
1658 |
|
my $t2 = $doc->create_text_node ('t2'); |
1659 |
|
$el->append_child ($t1); |
1660 |
|
$el->append_child ($t2); |
1661 |
|
$pe->set_attribute_definition_node ($el); |
1662 |
|
$pe->normalize; |
1663 |
|
|
1664 |
|
ok $el->text_content, 't1t2', 'normalize [16]'; |
1665 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [17]'; |
1666 |
|
} |
1667 |
|
|
1668 |
|
{ |
1669 |
|
my $dt = $doc->create_document_type_definition ('dt'); |
1670 |
|
my $pe = $doc->create_element_type_definition ('pe'); |
1671 |
|
my $el = $doc->create_attribute_definition ('a'); |
1672 |
|
my $t1 = $doc->create_text_node ('t1'); |
1673 |
|
my $t2 = $doc->create_text_node ('t2'); |
1674 |
|
$el->append_child ($t1); |
1675 |
|
$el->append_child ($t2); |
1676 |
|
$pe->set_attribute_definition_node ($el); |
1677 |
|
$dt->set_element_type_definition_node ($pe); |
1678 |
|
$dt->normalize; |
1679 |
|
|
1680 |
|
ok $el->text_content, 't1t2', 'normalize [18]'; |
1681 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [19]'; |
1682 |
|
} |
1683 |
|
|
1684 |
|
{ |
1685 |
|
my $pe = $doc->create_document_type_definition ('pe'); |
1686 |
|
my $el = $doc->create_general_entity ('a'); |
1687 |
|
my $t1 = $doc->create_text_node ('t1'); |
1688 |
|
my $t2 = $doc->create_text_node ('t2'); |
1689 |
|
$el->append_child ($t1); |
1690 |
|
$el->append_child ($t2); |
1691 |
|
$pe->set_general_entity_node ($el); |
1692 |
|
$pe->normalize; |
1693 |
|
|
1694 |
|
ok $el->text_content, 't1t2', 'normalize [20]'; |
1695 |
|
ok 0+@{$el->child_nodes}, 1, 'normalize [21]'; |
1696 |
|
} |
1697 |
|
|
1698 |
## TODO: parent_node tests, as with append_child tests |
## TODO: parent_node tests, as with append_child tests |
1699 |
|
|