/[suikacvs]/messaging/manakai/t/DOM-Node.t
Suika

Contents of /messaging/manakai/t/DOM-Node.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download) (as text)
Wed Jun 20 13:41:16 2007 UTC (17 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +474 -1 lines
File MIME type: application/x-troff
++ manakai/t/ChangeLog	20 Jun 2007 13:41:02 -0000
2007-06-20  Wakaba  <wakaba@suika.fam.cx>

	* DOM-Node.t: Tests for DOCUMENT_POSITION_* constants
	and new features are added.

++ manakai/lib/Message/DOM/ChangeLog	20 Jun 2007 13:40:42 -0000
2007-06-20  Wakaba  <wakaba@suika.fam.cx>

	* Node.pm (manakai_expanded_uri, manakai_parent_element,
	clone_node, compare_document_position, has_attributes,
	has_child_nodes, is_default_namespace, lookup_namespace_uri,
	lookup_prefix, normalize): Implemented.

	* DOMElement.pm (remove_attribute, set_attribute): Alpha version.

	* DOMException.pm (CLONE_NODE_TYPE_NOT_SUPPORTED_ERR): New error.

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3     use Test;
4 wakaba 1.4 BEGIN { plan tests => 1921 }
5 wakaba 1.1
6     require Message::DOM::DOMImplementation;
7 wakaba 1.3 use Message::Util::Error;
8 wakaba 1.1
9     my $dom = Message::DOM::DOMImplementation->____new;
10     my $doc = $dom->create_document;
11    
12 wakaba 1.4
13     sub create_nodes () {
14     (
15     $doc->create_attribute ('attr1'),
16     $doc->create_attribute_definition ('at1'),
17     $doc->create_cdata_section ('cdata1'),
18     $doc->create_comment ('comment1'),
19     $doc->create_element ('element1'),
20     $doc->create_element_type_definition ('et1'),
21     $doc->create_general_entity ('entity1'),
22     $doc->create_entity_reference ('entity-reference1'),
23     $doc->implementation->create_document,
24     $doc->create_document_fragment,
25     $doc->create_document_type_definition ('dt1'),
26     $doc->create_notation ('notation1'),
27     $doc->create_processing_instruction ('pi1', 'pi1data'),
28     $doc->create_text_node ('text1'),
29     );
30     } # create_nodes
31    
32     sub create_parent_nodes () {
33     (
34     $doc->create_attribute ('attr1'),
35     $doc->create_attribute_definition ('at1'),
36     $doc->create_element ('element1'),
37     $doc->create_general_entity ('entity1'),
38     $doc->create_entity_reference ('entity-reference1'),
39     $doc->implementation->create_document,
40     $doc->create_document_fragment,
41     $doc->create_document_type_definition ('dt1'),
42     );
43     } # create_parent_nodes
44    
45 wakaba 1.1 ## Constants
46     my $constants = [
47     [ELEMENT_NODE => 1],
48     [ATTRIBUTE_NODE => 2],
49     [TEXT_NODE => 3],
50     [CDATA_SECTION_NODE => 4],
51     [ENTITY_REFERENCE_NODE => 5],
52     [ENTITY_NODE => 6],
53     [PROCESSING_INSTRUCTION_NODE => 7],
54     [COMMENT_NODE => 8],
55     [DOCUMENT_NODE => 9],
56     [DOCUMENT_TYPE_NODE => 10],
57     [DOCUMENT_FRAGMENT_NODE => 11],
58     [NOTATION_NODE => 12],
59     [ELEMENT_TYPE_DEFINITION_NODE => 81001],
60     [ATTRIBUTE_DEFINITION_NODE => 81002],
61 wakaba 1.6
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 wakaba 1.1 ];
69    
70     my $tests = {
71 wakaba 1.4 attr1 => {
72     node => sub { return $doc->create_attribute ('a') },
73     attr_get => {
74     manakai_attribute_type => 0,
75     base_uri => undef,
76 wakaba 1.6 manakai_expanded_uri => 'a',
77 wakaba 1.4 first_child => undef,
78     last_child => undef,
79     local_name => 'a',
80     manakai_local_name => 'a',
81     namespace_uri => undef,
82     next_sibling => undef,
83     node_name => 'a',
84     name => 'a',
85     node_value => '',
86     owner_document => $doc,
87     parent_node => undef,
88     prefix => undef,
89     previous_sibling => undef,
90     value => '',
91     attributes => undef,
92     },
93     attr_get_bool => {
94 wakaba 1.6 has_attributes => 0,
95     has_child_nodes => 0,
96 wakaba 1.4 specified => 1,
97     },
98     },
99     attr2 => {
100 wakaba 1.1 node => sub {
101     my $attr = $doc->create_attribute ('a');
102     $attr->value ('b');
103     return $attr;
104     },
105     attr_get => {
106 wakaba 1.4 manakai_attribute_type => 0,
107     base_uri => undef,
108 wakaba 1.6 manakai_expanded_uri => 'a',
109 wakaba 1.2 local_name => 'a',
110     manakai_local_name => 'a',
111     namespace_uri => undef,
112     next_sibling => undef,
113 wakaba 1.1 node_name => 'a',
114     name => 'a',
115     node_value => 'b',
116 wakaba 1.2 owner_document => $doc,
117     parent_node => undef,
118     prefix => undef,
119     previous_sibling => undef,
120 wakaba 1.1 value => 'b',
121     attributes => undef,
122     },
123 wakaba 1.4 attr_get_bool => {
124 wakaba 1.6 has_attributes => 0,
125     has_child_nodes => 1,
126 wakaba 1.4 specified => 1,
127     },
128 wakaba 1.1 },
129     attr_ns_default => {
130 wakaba 1.4 node => sub { return $doc->create_attribute_ns (undef, 'a') },
131 wakaba 1.1 attr_get => {
132 wakaba 1.4 base_uri => undef,
133 wakaba 1.6 manakai_expanded_uri => 'a',
134 wakaba 1.2 local_name => 'a',
135     manakai_local_name => 'a',
136     namespace_uri => undef,
137     next_sibling => undef,
138 wakaba 1.1 node_name => 'a',
139     name => 'a',
140 wakaba 1.4 node_value => '',
141 wakaba 1.2 owner_document => $doc,
142     parent_node => undef,
143     prefix => undef,
144 wakaba 1.4 value => '',
145 wakaba 1.1 attributes => undef,
146 wakaba 1.2 previous_sibling => undef,
147 wakaba 1.1 },
148 wakaba 1.6 attr_get_bool => {
149     has_attributes => 0,
150     has_child_nodes => 0,
151     specified => 1,
152     },
153 wakaba 1.1 },
154     attr_ns_prefixed => {
155 wakaba 1.4 node => sub { return $doc->create_attribute_ns ('http://test/', 'a:b') },
156 wakaba 1.1 attr_get => {
157 wakaba 1.4 base_uri => undef,
158 wakaba 1.6 manakai_expanded_uri => 'http://test/b',
159 wakaba 1.2 local_name => 'b',
160     manakai_local_name => 'b',
161     namespace_uri => 'http://test/',
162     next_sibling => undef,
163 wakaba 1.1 node_name => 'a:b',
164     name => 'a:b',
165 wakaba 1.4 node_value => '',
166 wakaba 1.2 owner_document => $doc,
167     parent_node => undef,
168     prefix => 'a',
169 wakaba 1.4 value => '',
170 wakaba 1.1 attributes => undef,
171 wakaba 1.2 previous_sibling => undef,
172 wakaba 1.1 },
173 wakaba 1.6 attr_get_bool => {
174     has_attributes => 0,
175     has_child_nodes => 0,
176     specified => 1,
177     },
178 wakaba 1.1 },
179     cdatasection => {
180     node => sub { return $doc->create_cdata_section ('cdatadata') },
181     attr_get => {
182 wakaba 1.4 base_uri => undef,
183 wakaba 1.6 manakai_expanded_uri => undef,
184 wakaba 1.2 first_child => undef,
185     last_child => undef,
186     local_name => undef,
187     manakai_local_name => undef,
188     namespace_uri => undef,
189     next_sibling => undef,
190 wakaba 1.1 node_name => '#cdata-section',
191     node_value => 'cdatadata',
192 wakaba 1.2 owner_document => $doc,
193     parent_node => undef,
194     prefix => undef,
195 wakaba 1.1 data => 'cdatadata',
196     attributes => undef,
197 wakaba 1.2 previous_sibling => undef,
198 wakaba 1.1 },
199 wakaba 1.6 attr_get_bool => {
200     has_attributes => 0,
201     has_child_nodes => 0,
202     },
203 wakaba 1.1 },
204     cdatasectionmde => {
205     node => sub { return $doc->create_cdata_section ('cdata]]>data') },
206     attr_get => {
207 wakaba 1.4 base_uri => undef,
208 wakaba 1.6 manakai_expanded_uri => undef,
209 wakaba 1.2 first_child => undef,
210     last_child => undef,
211     local_name => undef,
212     manakai_local_name => undef,
213     namespace_uri => undef,
214     next_sibling => undef,
215 wakaba 1.1 node_name => '#cdata-section',
216     node_value => 'cdata]]>data',
217 wakaba 1.2 owner_document => $doc,
218     parent_node => undef,
219     prefix => undef,
220 wakaba 1.1 data => 'cdata]]>data',
221     attributes => undef,
222 wakaba 1.2 previous_sibling => undef,
223 wakaba 1.1 },
224 wakaba 1.6 attr_get_bool => {
225     has_attributes => 0,
226     has_child_nodes => 0,
227     },
228 wakaba 1.1 },
229     comment => {
230     node => sub { return $doc->create_comment ('commentdata') },
231     attr_get => {
232 wakaba 1.4 base_uri => undef,
233 wakaba 1.6 manakai_expanded_uri => undef,
234 wakaba 1.2 first_child => undef,
235     last_child => undef,
236     local_name => undef,
237     manakai_local_name => undef,
238     namespace_uri => undef,
239     next_sibling => undef,
240 wakaba 1.1 node_name => '#comment',
241     node_value => 'commentdata',
242 wakaba 1.2 owner_document => $doc,
243     parent_node => undef,
244     prefix => undef,
245 wakaba 1.1 data => 'commentdata',
246     attributes => undef,
247 wakaba 1.2 previous_sibling => undef,
248 wakaba 1.6 },
249     attr_get_bool => {
250     has_attributes => 0,
251     has_child_nodes => 0,
252 wakaba 1.1 },
253     },
254     commentcom1 => {
255     node => sub { return $doc->create_comment ('comment--data') },
256     attr_get => {
257 wakaba 1.4 base_uri => undef,
258 wakaba 1.6 manakai_expanded_uri => undef,
259 wakaba 1.2 first_child => undef,
260     last_child => undef,
261     local_name => undef,
262     manakai_local_name => undef,
263     namespace_uri => undef,
264     next_sibling => undef,
265 wakaba 1.1 node_name => '#comment',
266     node_value => 'comment--data',
267 wakaba 1.2 owner_document => $doc,
268     parent_node => undef,
269     prefix => undef,
270 wakaba 1.1 data => 'comment--data',
271     attributes => undef,
272 wakaba 1.2 previous_sibling => undef,
273 wakaba 1.1 },
274 wakaba 1.6 attr_get_bool => {
275     has_attributes => 0,
276     has_child_nodes => 0,
277     },
278 wakaba 1.1 },
279     commentcom2 => {
280     node => sub { return $doc->create_comment ('commentdata-') },
281     attr_get => {
282 wakaba 1.4 base_uri => undef,
283 wakaba 1.6 manakai_expanded_uri => undef,
284 wakaba 1.2 first_child => undef,
285     last_child => undef,
286     local_name => undef,
287     manakai_local_name => undef,
288     namespace_uri => undef,
289     next_sibling => undef,
290 wakaba 1.1 node_name => '#comment',
291     node_value => 'commentdata-',
292 wakaba 1.2 owner_document => $doc,
293     parent_node => undef,
294     prefix => undef,
295 wakaba 1.1 data => 'commentdata-',
296     attributes => undef,
297 wakaba 1.2 previous_sibling => undef,
298 wakaba 1.1 },
299 wakaba 1.6 attr_get_bool => {
300     has_attributes => 0,
301     has_child_nodes => 0,
302     },
303 wakaba 1.1 },
304     document => {
305     node => sub { return $doc },
306     attr_get => {
307     attributes => undef,
308 wakaba 1.4 base_uri => undef,
309     document_uri => undef,
310     manakai_entity_base_uri => undef,
311 wakaba 1.6 manakai_expanded_uri => undef,
312 wakaba 1.2 first_child => undef,
313     implementation => $dom,
314     last_child => undef,
315 wakaba 1.1 local_name => undef,
316 wakaba 1.2 manakai_local_name => undef,
317 wakaba 1.1 namespace_uri => undef,
318 wakaba 1.2 next_sibling => undef,
319 wakaba 1.1 node_name => '#document',
320     node_value => undef,
321 wakaba 1.2 owner_document => undef,
322 wakaba 1.1 parent_node => undef,
323     prefix => undef,
324 wakaba 1.2 previous_sibling => undef,
325 wakaba 1.4 xml_encoding => undef,
326     xml_version => '1.0',
327     },
328     attr_get_bool => {
329     all_declarations_processed => 0,
330 wakaba 1.6 has_attributes => 0,
331     has_child_nodes => 0,
332 wakaba 1.4 manakai_is_html => 0,
333     strict_error_checking => 1,
334     xml_standalone => 0,
335 wakaba 1.1 },
336     },
337     document_fragment => {
338     node => sub { return $doc->create_document_fragment },
339     attr_get => {
340     attributes => undef,
341 wakaba 1.4 base_uri => undef,
342 wakaba 1.6 manakai_expanded_uri => undef,
343 wakaba 1.2 first_child => undef,
344     last_child => undef,
345     local_name => undef,
346     manakai_local_name => undef,
347     namespace_uri => undef,
348     next_sibling => undef,
349 wakaba 1.1 node_name => '#document-fragment',
350     node_value => undef,
351 wakaba 1.2 owner_document => $doc,
352     parent_node => undef,
353     prefix => undef,
354     previous_sibling => undef,
355 wakaba 1.1 },
356 wakaba 1.6 attr_get_bool => {
357     has_attributes => 0,
358     has_child_nodes => 0,
359     },
360 wakaba 1.1 },
361     document_type => {
362     node => sub { return $doc->implementation->create_document_type ('n') },
363     attr_get => {
364     attributes => undef,
365 wakaba 1.4 base_uri => undef,
366     declaration_base_uri => undef,
367     manakai_declaration_base_uri => undef,
368 wakaba 1.6 manakai_expanded_uri => undef,
369 wakaba 1.2 first_child => undef,
370     implementation => $dom,
371     last_child => undef,
372     local_name => undef,
373     manakai_local_name => undef,
374     namespace_uri => undef,
375     next_sibling => undef,
376 wakaba 1.1 node_name => 'n',
377     node_value => undef,
378 wakaba 1.2 owner_document => undef,
379     parent_node => undef,
380     prefix => undef,
381     previous_sibling => undef,
382 wakaba 1.4 public_id => undef,
383     system_id => undef,
384 wakaba 1.1 },
385 wakaba 1.6 attr_get_bool => {
386     has_attributes => 0,
387     has_child_nodes => 0,
388     },
389 wakaba 1.1 },
390     document_type_definition => {
391     node => sub { return $doc->create_document_type_definition ('n') },
392     attr_get => {
393     attributes => undef,
394 wakaba 1.4 base_uri => undef,
395     declaration_base_uri => undef,
396     manakai_declaration_base_uri => undef,
397 wakaba 1.6 manakai_expanded_uri => undef,
398 wakaba 1.2 first_child => undef,
399     implementation => $dom,
400     last_child => undef,
401     local_name => undef,
402     manakai_local_name => undef,
403     namespace_uri => undef,
404     next_sibling => undef,
405 wakaba 1.1 node_name => 'n',
406     node_value => undef,
407 wakaba 1.2 owner_document => $doc,
408     parent_node => undef,
409     prefix => undef,
410     previous_sibling => undef,
411 wakaba 1.4 public_id => undef,
412     system_id => undef,
413 wakaba 1.1 },
414 wakaba 1.6 attr_get_bool => {
415     has_attributes => 0,
416     has_child_nodes => 0,
417     },
418 wakaba 1.1 },
419     element => {
420     node => sub { return $doc->create_element ('e') },
421     attr_get => {
422     ## TODO: attributes =>
423 wakaba 1.4 base_uri => undef,
424     manakai_base_uri => undef,
425 wakaba 1.6 manakai_expanded_uri => 'e',
426 wakaba 1.2 first_child => undef,
427     last_child => undef,
428     local_name => 'e',
429     manakai_local_name => 'e',
430     namespace_uri => undef,
431     next_sibling => undef,
432 wakaba 1.1 node_name => 'e',
433     node_value => undef,
434 wakaba 1.2 owner_document => $doc,
435     parent_node => undef,
436     prefix => undef,
437     previous_sibling => undef,
438 wakaba 1.1 },
439 wakaba 1.6 attr_get_bool => {
440     has_attributes => 0,
441     has_child_nodes => 0,
442     },
443 wakaba 1.1 },
444     element_ns_default => {
445     node => sub { return $doc->create_element_ns ('http://test/', 'f') },
446     attr_get => {
447     ## TODO: attributes =>
448 wakaba 1.4 base_uri => undef,
449     manakai_base_uri => undef,
450 wakaba 1.6 manakai_expanded_uri => 'http://test/f',
451 wakaba 1.2 first_child => undef,
452     last_child => undef,
453     local_name => 'f',
454     manakai_local_name => 'f',
455     namespace_uri => 'http://test/',
456     next_sibling => undef,
457 wakaba 1.1 node_name => 'f',
458     node_value => undef,
459 wakaba 1.2 owner_document => $doc,
460     parent_node => undef,
461     prefix => undef,
462     previous_sibling => undef,
463 wakaba 1.1 },
464 wakaba 1.6 attr_get_bool => {
465     has_attributes => 0,
466     has_child_nodes => 0,
467     },
468 wakaba 1.1 },
469     element_ns_prefiexed => {
470     node => sub { return $doc->create_element_ns ('http://test/', 'e:f') },
471     attr_get => {
472     ## TODO: attributes =>
473 wakaba 1.4 base_uri => undef,
474     manakai_base_uri => undef,
475 wakaba 1.6 manakai_expanded_uri => 'http://test/f',
476 wakaba 1.2 first_child => undef,
477     last_child => undef,
478     local_name => 'f',
479     manakai_local_name => 'f',
480     namespace_uri => 'http://test/',
481     next_sibling => undef,
482 wakaba 1.1 node_name => 'e:f',
483     node_value => undef,
484 wakaba 1.2 owner_document => $doc,
485     parent_node => undef,
486     prefix => 'e',
487     previous_sibling => undef,
488 wakaba 1.1 },
489 wakaba 1.6 attr_get_bool => {
490     has_attributes => 0,
491     has_child_nodes => 0,
492     },
493 wakaba 1.1 },
494     entity => {
495     node => sub { return $doc->create_general_entity ('e') },
496     attr_get => {
497     attributes => undef,
498 wakaba 1.4 base_uri => undef,
499     manakai_declaration_base_uri => undef,
500     manakai_entity_base_uri => undef,
501     manakai_entity_uri => undef,
502 wakaba 1.6 manakai_expanded_uri => undef,
503 wakaba 1.2 first_child => undef,
504     last_child => undef,
505     next_sibling => undef,
506 wakaba 1.1 node_name => 'e',
507     node_value => undef,
508 wakaba 1.5 notation_name => undef,
509 wakaba 1.2 owner_document => $doc,
510     parent_node => undef,
511     previous_sibling => undef,
512 wakaba 1.4 public_id => undef,
513     system_id => undef,
514 wakaba 1.1 },
515 wakaba 1.6 attr_get_bool => {
516     has_attributes => 0,
517     has_child_nodes => 0,
518     },
519 wakaba 1.1 },
520     entity_reference => {
521     node => sub { return $doc->create_entity_reference ('e') },
522     attr_get => {
523     attributes => undef,
524 wakaba 1.4 base_uri => undef,
525     manakai_entity_base_uri => undef,
526 wakaba 1.6 manakai_expanded_uri => undef,
527 wakaba 1.2 first_child => undef,
528     last_child => undef,
529     local_name => undef,
530     manakai_local_name => undef,
531     namespace_uri => undef,
532     next_sibling => undef,
533 wakaba 1.1 node_name => 'e',
534     node_value => undef,
535 wakaba 1.2 owner_document => $doc,
536     parent_node => undef,
537     prefix => undef,
538     previous_sibling => undef,
539 wakaba 1.1 },
540 wakaba 1.4 attr_get_bool => {
541     manakai_expanded => 0,
542     manakai_external => 0,
543 wakaba 1.6 has_attributes => 0,
544     has_child_nodes => 0,
545 wakaba 1.4 },
546 wakaba 1.1 },
547     notation => {
548     node => sub { return $doc->create_notation ('e') },
549     attr_get => {
550     attributes => undef,
551 wakaba 1.4 base_uri => undef,
552     manakai_declaration_base_uri => undef,
553 wakaba 1.6 manakai_expanded_uri => undef,
554 wakaba 1.2 first_child => undef,
555     last_child => undef,
556     local_name => undef,
557     manakai_local_name => undef,
558     namespace_uri => undef,
559     next_sibling => undef,
560 wakaba 1.1 node_name => 'e',
561     node_value => undef,
562 wakaba 1.2 owner_document => $doc,
563     parent_node => undef,
564     prefix => undef,
565     previous_sibling => undef,
566 wakaba 1.4 public_id => undef,
567     system_id => undef,
568 wakaba 1.1 },
569 wakaba 1.6 attr_get_bool => {
570     has_attributes => 0,
571     has_child_nodes => 0,
572     },
573 wakaba 1.1 },
574     processing_instruction => {
575     node => sub { return $doc->create_processing_instruction ('t', 'd') },
576     attr_get => {
577     attributes => undef,
578 wakaba 1.4 base_uri => undef,
579     manakai_base_uri => undef,
580 wakaba 1.6 manakai_expanded_uri => undef,
581 wakaba 1.2 first_child => undef,
582     last_child => undef,
583     local_name => undef,
584     manakai_local_name => undef,
585     namespace_uri => undef,
586     next_sibling => undef,
587 wakaba 1.1 node_name => 't',
588     node_value => 'd',
589 wakaba 1.2 owner_document => $doc,
590     parent_node => undef,
591     prefix => undef,
592     previous_sibling => undef,
593 wakaba 1.1 },
594 wakaba 1.6 attr_get_bool => {
595     has_attributes => 0,
596     has_child_nodes => 0,
597     },
598 wakaba 1.1 },
599     text => {
600     node => sub { return $doc->create_text_node ('textdata') },
601     attr_get => {
602     attributes => undef,
603 wakaba 1.4 base_uri => undef,
604 wakaba 1.6 manakai_expanded_uri => undef,
605 wakaba 1.2 first_child => undef,
606     last_child => undef,
607     local_name => undef,
608     manakai_local_name => undef,
609     namespace_uri => undef,
610     next_sibling => undef,
611 wakaba 1.1 node_name => '#text',
612     node_value => 'textdata',
613 wakaba 1.2 owner_document => $doc,
614     parent_node => undef,
615     prefix => undef,
616     previous_sibling => undef,
617 wakaba 1.1 },
618 wakaba 1.6 attr_get_bool => {
619     has_attributes => 0,
620     has_child_nodes => 0,
621     },
622 wakaba 1.1 },
623     element_type_definition => {
624     node => sub { return $doc->create_element_type_definition ('e') },
625     attr_get => {
626     attributes => undef,
627 wakaba 1.4 base_uri => undef,
628 wakaba 1.6 manakai_expanded_uri => undef,
629 wakaba 1.2 first_child => undef,
630     last_child => undef,
631     local_name => undef,
632     manakai_local_name => undef,
633     namespace_uri => undef,
634     next_sibling => undef,
635 wakaba 1.1 node_name => 'e',
636     node_value => undef,
637 wakaba 1.2 owner_document => $doc,
638     parent_node => undef,
639     prefix => undef,
640     previous_sibling => undef,
641 wakaba 1.1 },
642 wakaba 1.6 attr_get_bool => {
643     has_attributes => 0,
644     has_child_nodes => 0,
645     },
646 wakaba 1.1 },
647     attribute_definition => {
648     node => sub { return $doc->create_attribute_definition ('e') },
649     attr_get => {
650     attributes => undef,
651 wakaba 1.4 base_uri => undef,
652     declared_type => 0,
653     default_type => 0,
654 wakaba 1.6 manakai_expanded_uri => undef,
655 wakaba 1.2 first_child => undef,
656     last_child => undef,
657     local_name => undef,
658     manakai_local_name => undef,
659     namespace_uri => undef,
660     next_sibling => undef,
661 wakaba 1.1 node_name => 'e',
662     node_value => undef,
663 wakaba 1.2 owner_document => $doc,
664     parent_node => undef,
665     prefix => undef,
666     previous_sibling => undef,
667 wakaba 1.1 },
668 wakaba 1.6 attr_get_bool => {
669     has_attributes => 0,
670     has_child_nodes => 0,
671     },
672 wakaba 1.1 },
673     };
674    
675     for my $test_id (sort {$a cmp $b} keys %$tests) {
676     my $test_def = $tests->{$test_id};
677     my $node = $test_def->{node}->();
678    
679     for (@$constants) {
680     my $const_name = $_->[0];
681     ok $node->can ($const_name) ? 1 : 0, 1, "$test_id->can ($const_name)";
682     ok $node->$const_name, $_->[1], "$test_id.$const_name";
683     }
684    
685     for my $attr_name (sort {$a cmp $b} keys %{$test_def->{attr_get}}) {
686     my $expected = $test_def->{attr_get}->{$attr_name};
687     ok $node->can ($attr_name) ? 1 : 0, 1, "$test_id->can ($attr_name)";
688     my $actual = $node->$attr_name;
689     ok $actual, $expected, "$test_id.$attr_name.get";
690     }
691 wakaba 1.4
692     for my $attr_name (sort {$a cmp $b} keys %{$test_def->{attr_get_bool} or {}}) {
693     my $expected = $test_def->{attr_get_bool}->{$attr_name} ? 1 : 0;
694     ok $node->can ($attr_name) ? 1 : 0, 1, "$test_id->can ($attr_name)";
695     my $actual = $node->$attr_name ? 1 : 0;
696     ok $actual, $expected, "$test_id.$attr_name.get";
697     }
698 wakaba 1.1 }
699    
700 wakaba 1.2 ## Child node accessors' tests
701     for my $parent (create_parent_nodes ()) {
702     my $node1;
703     my $node2;
704     my $node3;
705     if ($parent->node_type == $parent->DOCUMENT_TYPE_NODE) {
706     $node1 = $doc->create_processing_instruction ('pi1', 'data1');
707     $node2 = $doc->create_processing_instruction ('pi2', 'data2');
708     $node3 = $doc->create_processing_instruction ('pi3', 'data3');
709     } elsif ($parent->node_type == $parent->DOCUMENT_NODE) {
710     $node1 = $doc->create_comment ('comment1');
711     $node2 = $doc->create_comment ('comment2');
712     $node3 = $doc->create_comment ('comment3');
713     } else {
714     $node1 = $doc->create_text_node ('text1');
715     $node2 = $doc->create_text_node ('text2');
716     $node3 = $doc->create_text_node ('text3');
717     }
718    
719     $parent->append_child ($node1);
720     ok $parent->first_child, $node1, $parent->node_name."->first_child [1]";
721     ok $parent->last_child, $node1, $parent->node_name."->last_child [1]";
722     ok $node1->next_sibling, undef, $parent->node_name."->next_sibling [1]";
723     ok $node1->previous_sibling, undef, $parent->node_name."->previous_sibling [1]";
724    
725     $parent->append_child ($node2);
726     ok $parent->first_child, $node1, $parent->node_name."->first_child [2]";
727     ok $parent->last_child, $node2, $parent->node_name."->last_child [2]";
728     ok $node1->next_sibling, $node2, $parent->node_name."1->next_sibling [2]";
729     ok $node1->previous_sibling, undef, $parent->node_name."1->previous_sibling [2]";
730     ok $node2->next_sibling, undef, $parent->node_name."2->next_sibling [2]";
731     ok $node2->previous_sibling, $node1, $parent->node_name."2->previous_sibling [2]";
732    
733     $parent->append_child ($node3);
734     ok $parent->first_child, $node1, $parent->node_name."->first_child [3]";
735     ok $parent->last_child, $node3, $parent->node_name."->last_child [3]";
736     ok $node1->next_sibling, $node2, $parent->node_name."1->next_sibling [3]";
737     ok $node1->previous_sibling, undef, $parent->node_name."1->previous_sibling [3]";
738     ok $node2->next_sibling, $node3, $parent->node_name."2->next_sibling [3]";
739     ok $node2->previous_sibling, $node1, $parent->node_name."2->previous_sibling [3]";
740     ok $node3->next_sibling, undef, $parent->node_name."3->next_sibling [3]";
741     ok $node3->previous_sibling, $node2, $parent->node_name."3->previous_sibling [3]";
742     }
743    
744 wakaba 1.3 ## |prefix| setter
745     for my $node (create_nodes ()) {
746     $node->manakai_set_read_only (0);
747    
748     $node->prefix ('non-null');
749     if ($node->node_type == $node->ELEMENT_NODE or
750     $node->node_type == $node->ATTRIBUTE_NODE) {
751     ok $node->prefix, 'non-null', $node->node_name . '->prefix (non-null)';
752     } else {
753     ok $node->prefix, undef, $node->node_name . '->prefix (non-null)';
754     }
755    
756     $node->prefix (undef);
757     if ($node->node_type == $node->ELEMENT_NODE or
758     $node->node_type == $node->ATTRIBUTE_NODE) {
759     ok $node->prefix, undef, $node->node_name . '->prefix (null)';
760     } else {
761     ok $node->prefix, undef, $node->node_name . '->prefix (null)';
762     }
763    
764     $node->manakai_set_read_only (1);
765     my $err_type;
766     try {
767     $node->prefix ('non-null');
768     } catch Message::IF::DOMException with {
769     my $err = shift;
770     $err_type = $err->type;
771     };
772     if ($node->node_type == $node->ELEMENT_NODE or
773     $node->node_type == $node->ATTRIBUTE_NODE) {
774     ok $err_type, 'NO_MODIFICATION_ALLOWED_ERR',
775     $node->node_name . '->prefix exception (read-only)';
776     ok $node->prefix, undef, $node->node_name . '->prefix (read-only)';
777     } else {
778     ok $err_type, undef, $node->node_name . '->prefix exception (read-only)';
779     ok $node->prefix, undef, $node->node_name . '->prefix (read-only)';
780     }
781     }
782    
783     ## |text_content|
784     {
785     my $doc2 = $doc->implementation->create_document;
786     $doc2->dom_config->set_parameter
787     ('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 1);
788     for my $node (
789     $doc2,
790     $doc->create_document_type_definition ('dt1'),
791     $doc->implementation->create_document_type ('doctype1'),
792     $doc->create_notation ('notation1'),
793     $doc->create_element_type_definition ('et1'),
794     ) {
795     ok $node->can ('text_content') ? 1 : 0, 1,
796     $node->node_name . '->can text_content';
797    
798     ok $node->text_content, undef, $node->node_name . '->text_content';
799    
800     $node->manakai_set_read_only (0);
801     $node->text_content ('new-text-content');
802     ok $node->text_content, undef, $node->node_name . '->text_content set';
803    
804     $node->manakai_set_read_only (1);
805     $node->text_content ('new-text-content');
806     ok $node->text_content, undef,
807     $node->node_name . '->text_content set (read-only)';
808     }
809    
810     $doc2->dom_config->set_parameter
811     ('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 0);
812     for my $node (
813     $doc2,
814     $doc->create_attribute ('attr1'),
815     $doc->create_attribute_definition ('at1'),
816     $doc->create_element ('element1'),
817     $doc->create_general_entity ('entity1'),
818     $doc->create_entity_reference ('entity-reference1'),
819     $doc->create_document_fragment,
820     ) {
821     ok $node->can ('text_content') ? 1 : 0, 1,
822     $node->node_name . '->can text_content';
823    
824     ok $node->text_content, '', $node->node_name . '->text_content';
825    
826     $node->manakai_set_read_only (0);
827     $node->text_content ('text1');
828     ok $node->text_content, 'text1', $node->node_name . '->text_content set';
829     ok 0+@{$node->child_nodes}, 1,
830     $node->node_name . '->text_content set child_nodes length';
831    
832     $node->text_content ('');
833     ok $node->text_content, '', $node->node_name . '->text_content set empty';
834     ok 0+@{$node->child_nodes}, 0,
835     $node->node_name . '->text_content set empty child_nodes length';
836    
837     $node->text_content ('text2');
838     $node->text_content ('');
839     ok $node->text_content, '', $node->node_name . '->text_content set empty';
840     ok 0+@{$node->child_nodes}, 0,
841     $node->node_name . '->text_content set empty child_nodes length';
842    
843     $node->text_content ('text3');
844     $node->manakai_set_read_only (1);
845     try {
846     $node->text_content ('new-text-content');
847     ok undef, 'NO_MODIFICATION_ALLOWED_ERR',
848     $node->node_name . '->text_content set (read-only)';
849     } catch Message::IF::DOMException with {
850     my $err = shift;
851     ok $err->type, 'NO_MODIFICATION_ALLOWED_ERR',
852     $node->node_name . '->text_content set (read-only)';
853     };
854     ok $node->text_content, 'text3',
855     $node->node_name . '->text_content set (read-only) text_content';
856     }
857    
858    
859     for (0..2) {
860     my $el;
861     my $ce;
862    
863     [
864     sub {
865     $el = $doc->create_element ('nestingElement');
866     $ce = $doc->create_element ('el2');
867     },
868     sub {
869     $el = $doc->create_element ('elementWithEntityReference');
870     $ce = $doc->create_entity_reference ('ent');
871     $ce->manakai_set_read_only (0, 1);
872     },
873     sub {
874     $el = $doc->create_general_entity ('generalEntityWithChild');
875     $ce = $doc->create_element ('el');
876     $el->manakai_set_read_only (0, 1);
877     },
878     ]->[$_]->();
879     $el->append_child ($ce);
880    
881     ok $el->text_content, '', $el->node_name . '->text_content [1]';
882    
883     $ce->text_content ('gc');
884     ok $el->text_content, 'gc', $el->node_name . '->text_content [2]';
885    
886     $el->manakai_append_text ('cc');
887     ok $el->text_content, 'gccc', $el->node_name . '->text_content [3]';
888    
889     $el->text_content ('nc');
890     ok $el->text_content, 'nc', $el->node_name . '->text_content [4]';
891     ok 0+@{$el->child_nodes}, 1,
892     $el->node_name . '->text_content child_nodes length [4]';
893     ok $ce->parent_node, undef,
894     $el->node_name . '->text_content old_child parent_node [4]';
895     }
896     }
897    
898 wakaba 1.4 ## |manakaiReadOnly| and |manakaiSetReadOnly|
899     {
900     for my $node (create_nodes ()) {
901     $node->manakai_set_read_only (1, 0);
902     ok $node->manakai_read_only ? 1 : 0, 1,
903     $node->node_name . '->manakai_set_read_only (1, 0) [1]';
904    
905     $node->manakai_set_read_only (0, 0);
906     ok $node->manakai_read_only ? 1 : 0, 0,
907     $node->node_name . '->manakai_set_read_only (0, 0)';
908    
909     $node->manakai_set_read_only (1, 0);
910     ok $node->manakai_read_only ? 1 : 0, 1,
911     $node->node_name . '->manakai_set_read_only (1, 0) [2]';
912     }
913    
914     {
915     my $el = $doc->create_element ('readOnlyElement1');
916     my $c1 = $doc->create_element ('c1');
917     $el->append_child ($c1);
918     my $c2 = $doc->create_text_node ('c2');
919     $el->append_child ($c2);
920     my $c3 = $doc->create_element ('c3');
921     $el->append_child ($c3);
922     my $c4 = $doc->create_attribute ('c4');
923     $el->set_attribute_node ($c4);
924     my $c5 = $doc->create_entity_reference ('c5');
925     $el->append_child ($c5);
926    
927     $el->manakai_set_read_only (1, 1);
928     for ($c1, $c2, $c3, $c4, $c5) {
929     ok $_->manakai_read_only ? 1 : 0, 1,
930     $el->node_name . '->read_only (1, 1) ' . $_->node_name . ' [1]';
931     }
932    
933     $el->manakai_set_read_only (0, 1);
934     for ($c1, $c2, $c3, $c4, $c5) {
935     ok $_->manakai_read_only ? 1 : 0, 0,
936     $el->node_name . '->read_only (1, 0) ' . $_->node_name;
937     }
938    
939     $el->manakai_set_read_only (1, 1);
940     for ($c1, $c2, $c3, $c4, $c5) {
941     ok $_->manakai_read_only ? 1 : 0, 1,
942     $el->node_name . '->read_only (1, 1) ' . $_->node_name . ' [2]';
943     }
944     }
945    
946     {
947     my $dtd = $doc->create_document_type_definition ('readOnlyDTDef1');
948     my $c1 = $doc->create_processing_instruction ('c1', '');
949     $dtd->append_child ($c1);
950     my $c2 = $doc->create_element_type_definition ('c2');
951     $dtd->set_element_type_definition_node ($c2);
952     my $c3 = $doc->create_general_entity ('c3');
953     $dtd->set_general_entity_node ($c3);
954     my $c4 = $doc->create_notation ('c4');
955     $dtd->set_notation_node ($c4);
956     my $c5 = $doc->create_text_node ('c5');
957     $c3->append_child ($c5);
958    
959     $dtd->manakai_set_read_only (1, 1);
960     for ($c1, $c2, $c3, $c4, $c5) {
961     ok $_->manakai_read_only ? 1 : 0, 1,
962     $dtd->node_name . '->read_only (1, 1) ' . $_->node_name . ' [1]';
963     }
964    
965     $dtd->manakai_set_read_only (0, 1);
966     for ($c1, $c2, $c3, $c4, $c5) {
967     ok $_->manakai_read_only ? 1 : 0, 0,
968     $dtd->node_name . '->read_only (1, 0) ' . $_->node_name;
969     }
970    
971     $dtd->manakai_set_read_only (1, 1);
972     for ($c1, $c2, $c3, $c4, $c5) {
973     ok $_->manakai_read_only ? 1 : 0, 1,
974     $dtd->node_name . '->read_only (1, 1) ' . $_->node_name . ' [2]';
975     }
976     }
977    
978     {
979     my $et = $doc->create_element_type_definition ('readOnlyETDef1');
980     my $c1 = $doc->create_element ('c1');
981     $et->set_attribute_definition_node ($c1);
982     my $c2 = $doc->create_text_node ('c2');
983     $c1->append_child ($c2);
984    
985     $et->manakai_set_read_only (1, 1);
986     for ($c1, $c2) {
987     ok $_->manakai_read_only ? 1 : 0, 1,
988     $et->node_name . '->read_only (1, 1) ' . $_->node_name . ' [1]';
989     }
990    
991     $et->manakai_set_read_only (0, 1);
992     for ($c1, $c2) {
993     ok $_->manakai_read_only ? 1 : 0, 0,
994     $et->node_name . '->read_only (1, 0) ' . $_->node_name;
995     }
996    
997     $et->manakai_set_read_only (1, 1);
998     for ($c1, $c2) {
999     ok $_->manakai_read_only ? 1 : 0, 1,
1000     $et->node_name . '->read_only (1, 1) ' . $_->node_name . ' [2]';
1001     }
1002     }
1003     }
1004    
1005     ## |manakaiAppendText|
1006     {
1007     my $doc2 = $doc->implementation->create_document;
1008    
1009     $doc2->dom_config->set_parameter
1010     ('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 1);
1011     for my $node (
1012     $doc2,
1013     $doc->create_notation ('Notation_manakaiAppendText'),
1014     $doc->create_document_type_definition ('DT_manakaiAppendText'),
1015     $doc->create_element_type_definition ('ET_manakaiAppendText'),
1016     ) {
1017     ok $node->can ('manakai_append_text') ? 1 : 0, 1, $node->node_name . 'can';
1018    
1019     $node->manakai_append_text ('aaaa');
1020     ok $node->text_content, undef, $node->node_name . ' [1]';
1021     ok 0+@{$node->child_nodes}, 0, $node->node_name . ' childNodes @{} 0+ [1]';
1022     }
1023    
1024     $doc2->dom_config->set_parameter
1025     ('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 0);
1026     for my $node (
1027     $doc->create_attribute ('Attr_manakaiAppendText'),
1028     $doc->create_element ('Element_manakaiAppendText'),
1029     $doc2,
1030     $doc->create_document_fragment,
1031     $doc->create_general_entity ('Entity_manakaiAppendText'),
1032     $doc->create_entity_reference ('ER_manakaiAppendText'),
1033     $doc->create_attribute_definition ('AT_manakaiAppendText'),
1034     ) {
1035     $node->manakai_set_read_only (0, 1);
1036     ok $node->can ('manakai_append_text') ? 1 : 0, 1, $node->node_name . 'can';
1037    
1038     $node->manakai_append_text ('string');
1039     ok $node->text_content, 'string', $node->node_name . ' [1]';
1040     ok 0+@{$node->child_nodes}, 1, $node->node_name . ' childNodes @{} 0+ [1]';
1041    
1042     $node->manakai_append_text ('STRING');
1043     ok $node->text_content, 'stringSTRING', $node->node_name . ' [2]';
1044     ok 0+@{$node->child_nodes}, 1, $node->node_name . ' childNodes @{} 0+ [2]';
1045    
1046     my $er = $doc->create_entity_reference ('er');
1047     $node->append_child ($er);
1048    
1049     $node->manakai_append_text ('text');
1050     ok $node->text_content, 'stringSTRINGtext', $node->node_name . ' [3]';
1051     ok 0+@{$node->child_nodes}, 3, $node->node_name . ' childNodes @{} 0+ [3]';
1052     }
1053    
1054     for my $node (
1055     $doc->create_text_node (''),
1056     $doc->create_cdata_section (''),
1057     $doc->create_comment (''),
1058     $doc->create_processing_instruction ('PI_manakaiAppendText'),
1059     ) {
1060     ok $node->can ('manakai_append_text') ? 1 : 0, 1, $node->node_name . 'can';
1061    
1062     $node->manakai_append_text ('aaaa');
1063     ok $node->text_content, 'aaaa', $node->node_name . ' [1]';
1064     ok 0+@{$node->child_nodes}, 0, $node->node_name . ' childNodes @{} 0+ [1]';
1065    
1066     $node->manakai_append_text ('bbbb');
1067     ok $node->text_content, 'aaaabbbb', $node->node_name . ' [1]';
1068     ok 0+@{$node->child_nodes}, 0, $node->node_name . ' childNodes @{} 0+ [1]';
1069     }
1070     }
1071    
1072     ## |baseURI|
1073     {
1074     my $doc2 = $doc->implementation->create_document;
1075    
1076     $doc2->document_uri (q<ftp://suika.fam.cx/>);
1077     ok $doc2->base_uri, q<ftp://suika.fam.cx/>, 'Document->base_uri [1]';
1078    
1079     $doc2->document_uri (undef);
1080     ok $doc2->base_uri, undef, 'Document->base_uri [2]';
1081     ok $doc2->manakai_entity_base_uri, undef, 'Document->base_uri ebu [2]';
1082    
1083     $doc2->manakai_entity_base_uri (q<https://suika.fam.cx/>);
1084     ok $doc2->base_uri, q<https://suika.fam.cx/>, 'Document->base_uri [3]';
1085     ok $doc2->manakai_entity_base_uri, q<https://suika.fam.cx/>,
1086     'Document->base_uri ebu [3]';
1087    
1088     $doc2->manakai_entity_base_uri (undef);
1089     ok $doc2->base_uri, undef, 'Document->base_uri [4]';
1090     ok $doc2->manakai_entity_base_uri, undef, 'Document->base_uri ebu [4]';
1091    
1092     $doc2->document_uri (q<ftp://suika.fam.cx/>);
1093     $doc2->manakai_entity_base_uri (q<https://suika.fam.cx/>);
1094     ok $doc2->base_uri, q<https://suika.fam.cx/>, 'Document->base_uri [5]';
1095     ok $doc2->manakai_entity_base_uri, q<https://suika.fam.cx/>,
1096     'Document->base_uri ebu [5]';
1097     }
1098    
1099     for my $method (qw/
1100     create_document_fragment
1101     create_element_type_definition
1102     create_attribute_definition
1103     /) {
1104     my $doc2 = $doc->implementation->create_document;
1105    
1106     my $node = $doc2->$method ('a');
1107    
1108     $doc2->document_uri (q<ftp://doc.test/>);
1109     ok $node->base_uri, q<ftp://doc.test/>, $node->node_name . '->base_uri [1]';
1110    
1111     $doc2->manakai_entity_base_uri (q<ftp://suika.fam.cx/>);
1112     ok $node->base_uri, q<ftp://suika.fam.cx/>,
1113     $node->node_name . '->base_uri [2]';
1114     }
1115    
1116     {
1117     my $doc2 = $doc->implementation->create_document;
1118    
1119     my $attr = $doc2->create_attribute_ns (undef, 'attr');
1120    
1121     $doc2->document_uri (q<http://www.example.com/>);
1122     ok $attr->base_uri, q<http://www.example.com/>, 'Attr->base_uri [1]';
1123    
1124     my $el = $doc2->create_element_ns (undef, 'element');
1125     $el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace',
1126     'xml:base' => q<http://www.example.org/>);
1127     $el->set_attribute_node_ns ($attr);
1128     ok $attr->base_uri, q<http://www.example.org/>, 'Attr->base_uri [2]';
1129     }
1130    
1131     for my $i (0..1) {
1132     my $xb = [
1133     ['http://www.w3.org/XML/1998/namespace', 'xml:base'],
1134     [undef, [undef, 'xml:base']],
1135     ]->[$i];
1136    
1137     my $doc2 = $doc->implementation->create_document;
1138    
1139     my $attr = $doc2->create_attribute_ns (@$xb);
1140     $attr->value (q<http://attr.test/>);
1141    
1142     ok $attr->base_uri, undef, 'xml:base->base_uri [0]' . $i;
1143    
1144     $doc2->document_uri (q<http://doc.test/>);
1145     ok $attr->base_uri, q<http://doc.test/>, 'xml:base->base_uri [1]' . $i;
1146    
1147     my $el = $doc2->create_element_ns (undef, 'e');
1148     $el->set_attribute_node_ns ($attr);
1149     ok $attr->base_uri, q<http://doc.test/>, 'xml:base->base_uri [2]' . $i;
1150    
1151     my $pel = $doc2->create_element_ns (undef, 'e');
1152     $pel->set_attribute_ns (@$xb, q<http://pel.test/>);
1153     $pel->append_child ($el);
1154     ok $attr->base_uri, q<http://pel.test/>, 'xml:base->base_uri [3]' . $i;
1155     }
1156    
1157     for my $i (0..1) {
1158     my $xb = [
1159     ['http://www.w3.org/XML/1998/namespace', 'xml:base'],
1160     [undef, [undef, 'xml:base']],
1161     ]->[$i];
1162    
1163     my $doc2 = $doc->implementation->create_document;
1164    
1165     my $el = $doc2->create_element_ns (undef, 'el');
1166    
1167     ok $el->base_uri, undef, "Element->base_uri [0]";
1168     ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [0]";
1169    
1170     $doc2->document_uri (q<http://foo.example/>);
1171     ok $el->base_uri, q<http://foo.example/>, "Element->base_uri [1]";
1172     ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [1]";
1173    
1174     $el->set_attribute_ns (@$xb => q<http://www.example.com/>);
1175     ok $el->base_uri, q<http://www.example.com/>, "Element->base_uri [2]";
1176     ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [2]";
1177    
1178     $el->set_attribute_ns (@$xb => q<bar>);
1179     ok $el->base_uri, q<http://foo.example/bar>, "Element->base_uri [3]";
1180     ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [3]";
1181    
1182     $el->manakai_base_uri (q<http://baz.example/>);
1183     ok $el->base_uri, q<http://baz.example/>, "Element->base_uri [4]";
1184     ok $el->manakai_base_uri, q<http://baz.example/>,
1185     "Element->manakai_base_uri [4]";
1186    
1187     $el->manakai_base_uri (undef);
1188     ok $el->base_uri, q<http://foo.example/bar>, "Element->base_uri [5]";
1189     ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [5]";
1190     }
1191    
1192     {
1193     my $doc2 = $doc->implementation->create_document;
1194    
1195     my $el = $doc2->create_element_ns (undef, 'el');
1196    
1197     ok $el->base_uri, undef, "Element->base_uri [6]";
1198    
1199     $doc2->document_uri (q<http://doc.test/>);
1200     ok $el->base_uri, q<http://doc.test/>, "Element->base_uri [7]";
1201    
1202     my $el0 = $doc2->create_element_ns (undef, 'e');
1203     $el0->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base',
1204     q<http://el.test/>);
1205     $el0->append_child ($el);
1206     ok $el->base_uri, q<http://el.test/>, "Element->base_uri [8]";
1207    
1208     my $ent = $doc2->create_entity_reference ('ent');
1209     $ent->manakai_set_read_only (0, 1);
1210     $ent->manakai_external (1);
1211     $ent->manakai_entity_base_uri (q<http://ent.test/>);
1212     $el0->append_child ($ent);
1213     $ent->append_child ($el);
1214     ok $el->base_uri, q<http://ent.test/>, "Element->base_uri [9]";
1215     }
1216    
1217     for (qw/create_text_node create_cdata_section create_comment/) {
1218     my $doc2 = $doc->implementation->create_document;
1219     my $node = $doc2->$_ ('');
1220    
1221     $doc2->document_uri (q<http://doc.test/>);
1222     ok $node->base_uri, q<http://doc.test/>, $node->node_name . "->base_uri [0]";
1223    
1224     my $el = $doc2->create_element_ns (undef, 'e');
1225     $el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base',
1226     q<http://el.test/>);
1227     $el->append_child ($node);
1228     ok $node->base_uri, q<http://el.test/>, $node->node_name . "->base_uri [1]";
1229    
1230     my $ent = $doc2->create_entity_reference ('ent');
1231     $ent->manakai_set_read_only (0, 1);
1232     $ent->manakai_external (1);
1233     $ent->manakai_entity_base_uri (q<http://ent.test/>);
1234     $el->append_child ($ent);
1235     $ent->append_child ($node);
1236     ok $node->base_uri, q<http://ent.test/>, $node->node_name . "->base_uri [2]";
1237     }
1238    
1239     {
1240     my $doc2 = $doc->implementation->create_document;
1241     my $ent = $doc2->create_general_entity ('ent');
1242    
1243     $doc2->document_uri (q<http://base.example/>);
1244     ok $ent->base_uri, q<http://base.example/>, "Entity->base_uri [1]";
1245    
1246     $ent->manakai_entity_base_uri (q<http://www.example.com/>);
1247     ok $ent->base_uri, q<http://base.example/>, "Entity->base_uri [2]";
1248    
1249     $ent->manakai_declaration_base_uri (q<http://www.example/>);
1250     ok $ent->base_uri, q<http://base.example/>, "Entity->base_uri [3]";
1251     }
1252    
1253     {
1254     my $doc2 = $doc->implementation->create_document;
1255    
1256     my $ent = $doc2->create_entity_reference ('ent');
1257     $ent->manakai_set_read_only (0, 1);
1258    
1259     $doc2->document_uri (q<http://base.example/>);
1260     ok $ent->base_uri, q<http://base.example/>, "ER->base_uri [1]";
1261    
1262     $ent->manakai_entity_base_uri (q<http://www.example.com/>);
1263     ok $ent->base_uri, q<http://base.example/>;
1264    
1265     my $el = $doc2->create_element_ns (undef, 'el');
1266     $el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base',
1267     q<http://el.test/>);
1268     $el->append_child ($ent);
1269     ok $ent->base_uri, q<http://el.test/>, "ER->base_uri [2]";
1270    
1271     my $xent = $doc2->create_entity_reference ('ext');
1272     $xent->manakai_set_read_only (0, 1);
1273     $xent->manakai_entity_base_uri (q<http://ent.test/>);
1274     $xent->manakai_external (1);
1275     $el->append_child ($xent);
1276     $xent->append_child ($ent);
1277     ok $ent->base_uri, q<http://ent.test/>, "ER->base_uri [3]";
1278     }
1279    
1280     {
1281     my $doc2 = $doc->implementation->create_document;
1282    
1283     my $pi = $doc2->create_processing_instruction ('i');
1284    
1285     ok $pi->base_uri, undef, "PI->base_uri [0]";
1286     ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [0]";
1287    
1288     $doc2->document_uri (q<http://doc.test/>);
1289     ok $pi->base_uri, q<http://doc.test/>, "PI->base_uri [1]";
1290     ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [1]";
1291    
1292     my $el = $doc2->create_element_ns (undef, 'e');
1293     $el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base',
1294     q<http://el.test/>);
1295     $el->append_child ($pi);
1296     ok $pi->base_uri, q<http://el.test/>, "PI->base_uri [2]";
1297     ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [2]";
1298    
1299     my $ent = $doc2->create_entity_reference ('ent');
1300     $ent->manakai_set_read_only (0, 1);
1301     $ent->manakai_external (1);
1302     $ent->manakai_entity_base_uri (q<http://ent.test/>);
1303     $el->append_child ($ent);
1304     $ent->append_child ($pi);
1305     ok $pi->base_uri, q<http://ent.test/>, "PI->base_uri [3]";
1306     ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [3]";
1307    
1308     $pi->manakai_base_uri (q<http://pi.ent/>);
1309     ok $pi->base_uri, q<http://pi.ent/>, "PI->base_uri [4]";
1310     ok $pi->manakai_base_uri, q<http://pi.ent/>, "PI->manakai_base_uri [4]";
1311    
1312     $pi->manakai_base_uri (undef);
1313     ok $pi->base_uri, q<http://ent.test/>, "PI->base_uri [5]";
1314     ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [5]";
1315     }
1316    
1317     {
1318     my $doc2 = $doc->implementation->create_document;
1319    
1320     my $pi = $doc2->create_notation ('i');
1321    
1322     $doc2->document_uri (q<http://doc.test/>);
1323     ok $pi->base_uri, q<http://doc.test/>, "Notation->base_uri [1]";
1324    
1325     $pi->manakai_declaration_base_uri (q<http://www.example/>);
1326     ok $pi->base_uri, q<http://doc.test/>, "Notation->base_uri [2]";
1327     }
1328    
1329     {
1330     my $dt = $doc->implementation->create_document_type ('name');
1331     ok $dt->base_uri, undef, "DT->base_uri [0]";
1332    
1333     my $doc2 = $doc->implementation->create_document;
1334     $doc2->append_child ($dt);
1335     $doc2->document_uri (q<http://doc.test/>);
1336     ok $dt->owner_document, $doc2;
1337     ok $dt->base_uri, q<http://doc.test/>, "DT->base_uri [1]";
1338     }
1339    
1340 wakaba 1.6 ## |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 wakaba 1.4
1698 wakaba 1.2 ## TODO: parent_node tests, as with append_child tests
1699    
1700 wakaba 1.3 ## TODO: text_content tests for CharacterData and PI
1701    
1702 wakaba 1.4 =head1 LICENSE
1703    
1704     Copyright 2007 Wakaba <w@suika.fam.cx>
1705 wakaba 1.3
1706 wakaba 1.4 This program is free software; you can redistribute it and/or
1707     modify it under the same terms as Perl itself.
1708 wakaba 1.2
1709 wakaba 1.4 =cut
1710 wakaba 1.2
1711 wakaba 1.6 ## $Date: 2007/06/17 14:15:39 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24