/[suikacvs]/messaging/manakai/lib/Message/DOM/Document.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/Document.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (show annotations) (download)
Sat Dec 30 15:43:00 2006 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.15: +13 -45 lines
*** empty log message ***

1 #!/usr/bin/perl
2 ## This file is automatically generated
3 ## at 2006-12-30T14:33:19+00:00,
4 ## from file "../DOM/Document.dis",
5 ## module <http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.Document>,
6 ## for <http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#all>.
7 ## Don't edit by hand!
8 use strict;
9 require Message::DOM::DOMCore;
10 require Message::DOM::TreeCore;
11 require Message::Util::Error::DOMException;
12 package Message::DOM::Document;
13 our $VERSION = 20061230.1433;
14 package Message::DOM::Document::ManakaiDOMImplementationDocument;
15 our $VERSION = 20061230.1433;
16 push @Message::DOM::DOMCore::ManakaiDOMImplementation::ISA, q<Message::DOM::Document::ManakaiDOMImplementationDocument> unless Message::DOM::DOMCore::ManakaiDOMImplementation->isa (q<Message::DOM::Document::ManakaiDOMImplementationDocument>);
17 sub create_document ($;$$$) {
18 my ($self, $namespaceURI, $qualifiedName, $doctype) = @_;
19
20 {
21
22 if
23 (CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) {
24 require Message::DOM::DOMMain;
25
26 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:1167487489:32060:02l5m38360';
27
28 ;
29
30 $namespaceURI = undef;
31 }
32
33
34 }
35 my $r;
36
37 {
38
39 require
40 Scalar::Util;
41 $r = bless \{
42
43 'child'
44 => [],
45
46 'impl'
47 => $self,
48
49 'http://www.w3.org/2001/04/infoset#version'
50 => '1.0',
51
52 'chk'
53 => 1,
54 },
55 'Message::DOM::Document::ManakaiDOMDocument'
56 ;
57
58 if (defined $doctype) {
59
60
61 {
62
63 local $Error::Depth = $Error::Depth + 1;
64
65 {
66
67
68
69 $r->
70 append_child
71 ($doctype);
72
73
74
75 }
76
77
78 ;}
79
80 ;
81 }
82
83 if (defined $qualifiedName) {
84
85
86 {
87
88 local $Error::Depth = $Error::Depth + 1;
89
90 {
91
92
93 my
94 $el = $r->
95 create_element_ns
96
97 ($namespaceURI, $qualifiedName);
98 $r->
99 append_child
100 ($el);
101 $r = $el->
102 owner_document
103 ;
104 ## Choose the class based on document element type
105
106
107
108 }
109
110
111 ;}
112
113 ;
114 } elsif (defined $namespaceURI) {
115
116 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'create_document', 'http://www.w3.org/2001/04/infoset#namespaceURI' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_NULL_QNAME_WITH_NON_NULL_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMImplementationDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'namespaceURI';
117
118 ;
119 }
120
121
122 }
123 $r}
124 $Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMImplementationDocument>}->{has_feature} = {};
125 $Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMImplementationDocument>} = 0;
126 package Message::DOM::IF::Document;
127 our $VERSION = 20061230.1433;
128 package Message::DOM::Document::ManakaiDOMDocument;
129 our $VERSION = 20061230.1433;
130 push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode',
131 'Message::DOM::IF::Document',
132 'Message::DOM::IF::Node';
133 sub node_type ($;$) {
134 if (@_ == 1) {my ($self) = @_;
135 my $r;
136 $r = 9;
137 $r;
138 } else {my ($self) = @_;
139 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_type';
140 }
141 }
142 sub append_child ($$) {
143 my ($self, $newChild) = @_;
144 my $r;
145
146 {
147
148 my
149 $strictc = $self->
150 dom_config
151
152 ->
153 get_parameter
154
155 (
156 'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
157 );
158 my $child_od = $newChild->
159 owner_document
160 || $self;
161 my $child_nt = $newChild->
162 node_type
163 ;
164 if ($strictc and $self->
165 strict_error_checking
166 ) {
167
168
169 {
170
171 local $Error::Depth = $Error::Depth + 1;
172
173 {
174
175
176 my
177 $has_el;
178 my $has_dt;
179 if ($child_nt ==
180 1
181 ) {
182 $has_el =
183 1
184 ;
185 } elsif ($child_nt ==
186 10
187 ) {
188 $has_dt =
189 1
190 ;
191 } elsif ($child_nt ==
192 11
193 ) {
194 for my $cn (@{$newChild->
195 child_nodes
196 }) {
197 my $cnt = $cn->
198 node_type
199 ;
200 if ($cnt ==
201 1
202 ) {
203 if ($has_el) {
204
205
206 {
207
208 local $Error::Depth = $Error::Depth - 1;
209
210 {
211
212 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
213
214
215 }
216
217
218 ;}
219
220 ;
221 }
222 $has_el =
223 1
224 ;
225 }
226 # DocumentType node cannot be contained in DocumentFragments
227 }
228 }
229
230 if ($has_el) {
231 my $anode = $self->
232 last_child
233 ;
234 while (defined $anode) {
235 if ($anode->
236 node_type
237 ==
238 1
239 ) {
240
241
242 {
243
244 local $Error::Depth = $Error::Depth - 1;
245
246 {
247
248 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
249
250
251 }
252
253
254 ;}
255
256 ;
257 }
258 $anode = $anode->
259 previous_sibling
260 ;
261 }
262 } # has_el
263 if ($has_dt) {
264 my $anode = $self->
265 last_child
266 ;
267 while (defined $anode) {
268 my $ant = $anode->
269 node_type
270 ;
271 if ($ant ==
272 1
273 ) {
274
275
276 {
277
278 local $Error::Depth = $Error::Depth - 1;
279
280 {
281
282 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
283
284
285 }
286
287
288 ;}
289
290 ;
291 } elsif ($ant ==
292 10
293 ) {
294
295
296 {
297
298 local $Error::Depth = $Error::Depth - 1;
299
300 {
301
302 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
303
304
305 }
306
307
308 ;}
309
310 ;
311 }
312 $anode = $anode->
313 previous_sibling
314 ;
315 }
316 } # has_dt
317
318
319
320 }
321
322
323 ;}
324
325 ;
326 }
327
328
329 {
330
331
332 {
333
334 local $Error::Depth = $Error::Depth + 1;
335
336 {
337
338
339 my
340 $strict = $self->
341 strict_error_checking
342 ;
343
344 ## -- Node Type check
345 my @new_child;
346 if ({
347 3 => (not $strictc),
348 5 => (not $strictc),
349 1 => 1,
350 4 => (not $strictc),
351 7 => 1,
352 8 => 1,
353 10 => 1,
354 }->{$child_nt}) {
355 push @new_child, $newChild;
356 } elsif ($child_nt ==
357 11
358 ) {
359 for my $cn (@{$newChild->
360 child_nodes
361 }) {
362 unless ({
363 3 => (not $strictc),
364 5 => (not $strictc),
365 1 => 1,
366 4 => (not $strictc),
367 7 => 1,
368 8 => 1,
369 10 => 1,
370 }->{$cn->
371 node_type
372 }) {
373
374
375 {
376
377 local $Error::Depth = $Error::Depth - 1;
378
379 {
380
381 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
382
383
384 }
385
386
387 ;}
388
389 ;
390 }
391 push @new_child, $cn;
392 }
393 } else {
394
395
396 {
397
398 local $Error::Depth = $Error::Depth - 1;
399
400 {
401
402 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
403
404
405 }
406
407
408 ;}
409
410 ;
411 }
412
413 my $nc_parent = @new_child ? $new_child[0]->
414 parent_node
415 :
416
417 undef
418 ;
419 if ($strict) {
420 ## -- Wrong-document check
421 unless ($self eq $child_od) {
422
423
424 {
425
426 local $Error::Depth = $Error::Depth - 1;
427
428 {
429
430 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
431
432
433 }
434
435
436 ;}
437
438 ;
439 }
440
441 ## -- Read-onlyness check
442 if ($self->
443 manakai_read_only
444 ) {
445
446
447 {
448
449 local $Error::Depth = $Error::Depth - 1;
450
451 {
452
453 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1';
454
455
456 }
457
458
459 ;}
460
461 ;
462 }
463 if (@new_child) {
464 if ($nc_parent and
465 $nc_parent->
466 manakai_read_only
467 ) {
468
469
470 {
471
472 local $Error::Depth = $Error::Depth - 1;
473
474 {
475
476 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1';
477
478
479 }
480
481
482 ;}
483
484 ;
485 }
486 }
487 }
488
489 ## -- Insert at...
490 my $index = -1; # last
491
492
493 ; # FOR !tc:ForAppendChild
494
495 ## -- Removes from parent
496 if ($nc_parent) {
497 if ($child_nt ==
498 11
499 ) {
500 $$newChild->{
501 'child'
502 } = [];
503 } else {
504 my $v = $$nc_parent->{
505 'child'
506 };
507 RP: for my $i (0..$#$v) {
508 if ($v->[$i] eq $new_child[0]) {
509 splice @$v, $i, 1, ();
510 last RP;
511 }
512 } # RP
513 }
514 }
515
516 ## -- Rewrite the |parentNode| properties
517 for my $nc (@new_child) {
518 $$nc->{
519 'parent'
520 } = $self;
521 Scalar::Util::weaken ($$nc->{
522 'parent'
523 });
524 }
525
526 my $children = $$self->{
527 'child'
528 };
529
530
531
532 {
533
534
535 ## -- Adds to children list
536 push @$children, @new_child;
537 $r = $newChild;
538
539
540
541 }
542
543 ;
544
545
546
547 ;
548
549
550
551 ;
552
553
554
555 }
556
557
558 ;}
559
560 ;
561
562
563 }
564
565 ;
566 if ($child_nt ==
567 10 and
568
569 not defined $newChild->
570 owner_document
571 ) {
572 CORE::delete $$newChild->{
573 'impl'
574 };
575 $$newChild->{
576 'od'
577 } = $self;
578 Scalar::Util::weaken ($$newChild->{
579 'od'
580 });
581 }
582
583
584 }
585 $r}
586 sub insert_before ($$;$) {
587 my ($self, $newChild, $refChild) = @_;
588 my $r;
589
590 {
591
592 my
593 $strictc = $self->
594 dom_config
595
596 ->
597 get_parameter
598
599 (
600 'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
601 );
602 my $child_od = $newChild->
603 owner_document
604 || $self;
605 my $child_nt = $newChild->
606 node_type
607 ;
608 if ($strictc and $self->
609 strict_error_checking
610 ) {
611
612
613 {
614
615 local $Error::Depth = $Error::Depth + 1;
616
617 {
618
619
620 my
621 $has_el;
622 my $has_dt;
623 if ($child_nt ==
624 1
625 ) {
626 $has_el =
627 1
628 ;
629 } elsif ($child_nt ==
630 10
631 ) {
632 $has_dt =
633 1
634 ;
635 } elsif ($child_nt ==
636 11
637 ) {
638 for my $cn (@{$newChild->
639 child_nodes
640 }) {
641 my $cnt = $cn->
642 node_type
643 ;
644 if ($cnt ==
645 1
646 ) {
647 if ($has_el) {
648
649
650 {
651
652 local $Error::Depth = $Error::Depth - 1;
653
654 {
655
656 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
657
658
659 }
660
661
662 ;}
663
664 ;
665 }
666 $has_el =
667 1
668 ;
669 }
670 # DocumentType node cannot be contained in DocumentFragments
671 }
672 }
673
674 if ($has_el) {
675 my $anode = $refChild ? $refChild->
676 previous_sibling
677 :
678 $self->
679 last_child
680 ;
681 while (defined $anode) {
682 if ($anode->
683 node_type
684 ==
685 1
686 ) {
687
688
689 {
690
691 local $Error::Depth = $Error::Depth - 1;
692
693 {
694
695 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
696
697
698 }
699
700
701 ;}
702
703 ;
704 }
705 $anode = $anode->
706 previous_sibling
707 ;
708 }
709 $anode = $refChild;
710 while (defined $anode) {
711 my $ant = $anode->
712 node_type
713 ;
714 if ($ant ==
715 1
716 ) {
717
718
719 {
720
721 local $Error::Depth = $Error::Depth - 1;
722
723 {
724
725 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
726
727
728 }
729
730
731 ;}
732
733 ;
734 } elsif ($ant ==
735 10
736 ) {
737
738
739 {
740
741 local $Error::Depth = $Error::Depth - 1;
742
743 {
744
745 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
746
747
748 }
749
750
751 ;}
752
753 ;
754 }
755 $anode = $anode->
756 next_sibling
757 ;
758 }
759 } # has_el
760 if ($has_dt) {
761 my $anode = $refChild ? $refChild->
762 previous_sibling
763 :
764 $self->
765 last_child
766 ;
767 while (defined $anode) {
768 my $ant = $anode->
769 node_type
770 ;
771 if ($ant ==
772 1
773 ) {
774
775
776 {
777
778 local $Error::Depth = $Error::Depth - 1;
779
780 {
781
782 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
783
784
785 }
786
787
788 ;}
789
790 ;
791 } elsif ($ant ==
792 10
793 ) {
794
795
796 {
797
798 local $Error::Depth = $Error::Depth - 1;
799
800 {
801
802 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
803
804
805 }
806
807
808 ;}
809
810 ;
811 }
812 $anode = $anode->
813 previous_sibling
814 ;
815 }
816 $anode = $refChild;
817 while (defined $anode) {
818 if ($anode->
819 node_type
820
821 ==
822 10
823 ) {
824
825
826 {
827
828 local $Error::Depth = $Error::Depth - 1;
829
830 {
831
832 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
833
834
835 }
836
837
838 ;}
839
840 ;
841 }
842 $anode = $anode->
843 next_sibling
844 ;
845 }
846 } # has_dt
847
848
849
850 }
851
852
853 ;}
854
855 ;
856 }
857
858
859 {
860
861
862 {
863
864 local $Error::Depth = $Error::Depth + 1;
865
866 {
867
868
869 my
870 $strict = $self->
871 strict_error_checking
872 ;
873
874 ## -- Node Type check
875 my @new_child;
876 if ({
877 3 => (not $strictc),
878 5 => (not $strictc),
879 1 => 1,
880 4 => (not $strictc),
881 7 => 1,
882 8 => 1,
883 10 => 1,
884 }->{$child_nt}) {
885 push @new_child, $newChild;
886 } elsif ($child_nt ==
887 11
888 ) {
889 for my $cn (@{$newChild->
890 child_nodes
891 }) {
892 unless ({
893 3 => (not $strictc),
894 5 => (not $strictc),
895 1 => 1,
896 4 => (not $strictc),
897 7 => 1,
898 8 => 1,
899 10 => 1,
900 }->{$cn->
901 node_type
902 }) {
903
904
905 {
906
907 local $Error::Depth = $Error::Depth - 1;
908
909 {
910
911 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
912
913
914 }
915
916
917 ;}
918
919 ;
920 }
921 push @new_child, $cn;
922 }
923 } else {
924
925
926 {
927
928 local $Error::Depth = $Error::Depth - 1;
929
930 {
931
932 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
933
934
935 }
936
937
938 ;}
939
940 ;
941 }
942
943 my $nc_parent = @new_child ? $new_child[0]->
944 parent_node
945 :
946
947 undef
948 ;
949 if ($strict) {
950 ## -- Wrong-document check
951 unless ($self eq $child_od) {
952
953
954 {
955
956 local $Error::Depth = $Error::Depth - 1;
957
958 {
959
960 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
961
962
963 }
964
965
966 ;}
967
968 ;
969 }
970
971 ## -- Read-onlyness check
972 if ($self->
973 manakai_read_only
974 ) {
975
976
977 {
978
979 local $Error::Depth = $Error::Depth - 1;
980
981 {
982
983 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1';
984
985
986 }
987
988
989 ;}
990
991 ;
992 }
993 if (@new_child) {
994 if ($nc_parent and
995 $nc_parent->
996 manakai_read_only
997 ) {
998
999
1000 {
1001
1002 local $Error::Depth = $Error::Depth - 1;
1003
1004 {
1005
1006 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1';
1007
1008
1009 }
1010
1011
1012 ;}
1013
1014 ;
1015 }
1016 }
1017 }
1018
1019 ## -- Insert at...
1020 my $index = -1; # last
1021
1022
1023 {
1024
1025
1026 # tc:ForAppendChild & tc:ForReplaceChild
1027 if (defined $refChild) {
1028 if ($refChild eq $newChild) {
1029
1030
1031 {
1032
1033
1034 {
1035
1036 local $Error::Depth = $Error::Depth - 1;
1037
1038 {
1039
1040 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1';
1041
1042
1043 }
1044
1045
1046 ;}
1047
1048 ;
1049
1050
1051
1052 }
1053
1054 ;
1055
1056
1057 ;
1058 }
1059
1060 my $cns = $self->
1061 child_nodes
1062 ;
1063 my $cnsl = @$cns;
1064 C: {
1065 $index = 0;
1066 for my $i (0..($cnsl-1)) {
1067 my $cn = $cns->[$i];
1068 if ($cn eq $refChild) {
1069 $index += $i;
1070 last C;
1071 } elsif ($cn eq $newChild) {
1072 $index = -1; # offset
1073 }
1074 }
1075
1076
1077 {
1078
1079
1080 {
1081
1082 local $Error::Depth = $Error::Depth - 1;
1083
1084 {
1085
1086 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild;
1087
1088
1089 }
1090
1091
1092 ;}
1093
1094 ;
1095
1096
1097
1098 }
1099
1100 ;
1101
1102
1103 ;
1104 } # C
1105 } else { # |oldChild| is not defined
1106
1107
1108 ;
1109 }
1110
1111
1112
1113 }
1114
1115 ; # FOR !tc:ForAppendChild
1116
1117 ## -- Removes from parent
1118 if ($nc_parent) {
1119 if ($child_nt ==
1120 11
1121 ) {
1122 $$newChild->{
1123 'child'
1124 } = [];
1125 } else {
1126 my $v = $$nc_parent->{
1127 'child'
1128 };
1129 RP: for my $i (0..$#$v) {
1130 if ($v->[$i] eq $new_child[0]) {
1131 splice @$v, $i, 1, ();
1132 last RP;
1133 }
1134 } # RP
1135 }
1136 }
1137
1138 ## -- Rewrite the |parentNode| properties
1139 for my $nc (@new_child) {
1140 $$nc->{
1141 'parent'
1142 } = $self;
1143 Scalar::Util::weaken ($$nc->{
1144 'parent'
1145 });
1146 }
1147
1148 my $children = $$self->{
1149 'child'
1150 };
1151
1152
1153
1154 ;
1155
1156
1157
1158 {
1159
1160
1161 ## -- Adds to children list
1162 if ($index == -1) {
1163 push @$children, @new_child;
1164 } else {
1165 splice @$children, $index, 0, @new_child;
1166 }
1167 $r = $newChild;
1168
1169
1170
1171 }
1172
1173 ;
1174
1175
1176
1177 ;
1178
1179
1180
1181 }
1182
1183
1184 ;}
1185
1186 ;
1187
1188
1189 }
1190
1191 ;
1192 if ($child_nt ==
1193 10 and
1194
1195 not defined $newChild->
1196 owner_document
1197 ) {
1198 CORE::delete $$newChild->{
1199 'impl'
1200 };
1201 $$newChild->{
1202 'od'
1203 } = $self;
1204 Scalar::Util::weaken ($$newChild->{
1205 'od'
1206 });
1207 }
1208
1209
1210 }
1211 $r}
1212 sub replace_child ($$$) {
1213 my ($self, $newChild, $oldChild) = @_;
1214 my $r;
1215
1216 {
1217
1218 my
1219 $strictc = $self->
1220 dom_config
1221
1222 ->
1223 get_parameter
1224
1225 (
1226 'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
1227 );
1228 my $child_od = $newChild->
1229 owner_document
1230 || $self;
1231 my $child_nt = $newChild->
1232 node_type
1233 ;
1234 if ($strictc and $self->
1235 strict_error_checking
1236 ) {
1237
1238
1239 {
1240
1241 local $Error::Depth = $Error::Depth + 1;
1242
1243 {
1244
1245
1246 my
1247 $has_el;
1248 my $has_dt;
1249 if ($child_nt ==
1250 1
1251 ) {
1252 $has_el =
1253 1
1254 ;
1255 } elsif ($child_nt ==
1256 10
1257 ) {
1258 $has_dt =
1259 1
1260 ;
1261 } elsif ($child_nt ==
1262 11
1263 ) {
1264 for my $cn (@{$newChild->
1265 child_nodes
1266 }) {
1267 my $cnt = $cn->
1268 node_type
1269 ;
1270 if ($cnt ==
1271 1
1272 ) {
1273 if ($has_el) {
1274
1275
1276 {
1277
1278 local $Error::Depth = $Error::Depth - 1;
1279
1280 {
1281
1282 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1283
1284
1285 }
1286
1287
1288 ;}
1289
1290 ;
1291 }
1292 $has_el =
1293 1
1294 ;
1295 }
1296 # DocumentType node cannot be contained in DocumentFragments
1297 }
1298 }
1299
1300 if ($has_el) {
1301 my $anode = $oldChild->
1302 previous_sibling
1303 ;
1304 while (defined $anode) {
1305 if ($anode->
1306 node_type
1307 ==
1308 1
1309 ) {
1310
1311
1312 {
1313
1314 local $Error::Depth = $Error::Depth - 1;
1315
1316 {
1317
1318 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1319
1320
1321 }
1322
1323
1324 ;}
1325
1326 ;
1327 }
1328 $anode = $anode->
1329 previous_sibling
1330 ;
1331 }
1332 $anode = $oldChild->
1333 next_sibling
1334 ;
1335 while (defined $anode) {
1336 my $ant = $anode->
1337 node_type
1338 ;
1339 if ($ant ==
1340 1
1341 ) {
1342
1343
1344 {
1345
1346 local $Error::Depth = $Error::Depth - 1;
1347
1348 {
1349
1350 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1351
1352
1353 }
1354
1355
1356 ;}
1357
1358 ;
1359 } elsif ($ant ==
1360 10
1361 ) {
1362
1363
1364 {
1365
1366 local $Error::Depth = $Error::Depth - 1;
1367
1368 {
1369
1370 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1371
1372
1373 }
1374
1375
1376 ;}
1377
1378 ;
1379 }
1380 $anode = $anode->
1381 next_sibling
1382 ;
1383 }
1384 } # has_el
1385 if ($has_dt) {
1386 my $anode = $oldChild->
1387 previous_sibling
1388 ;
1389 while (defined $anode) {
1390 my $ant = $anode->
1391 node_type
1392 ;
1393 if ($ant ==
1394 1
1395 ) {
1396
1397
1398 {
1399
1400 local $Error::Depth = $Error::Depth - 1;
1401
1402 {
1403
1404 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1405
1406
1407 }
1408
1409
1410 ;}
1411
1412 ;
1413 } elsif ($ant ==
1414 10
1415 ) {
1416
1417
1418 {
1419
1420 local $Error::Depth = $Error::Depth - 1;
1421
1422 {
1423
1424 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1425
1426
1427 }
1428
1429
1430 ;}
1431
1432 ;
1433 }
1434 $anode = $anode->
1435 previous_sibling
1436 ;
1437 }
1438 $anode = $oldChild->
1439 next_sibling
1440 ;
1441 while (defined $anode) {
1442 if ($anode->
1443 node_type
1444
1445 ==
1446 10
1447 ) {
1448
1449
1450 {
1451
1452 local $Error::Depth = $Error::Depth - 1;
1453
1454 {
1455
1456 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1457
1458
1459 }
1460
1461
1462 ;}
1463
1464 ;
1465 }
1466 $anode = $anode->
1467 next_sibling
1468 ;
1469 }
1470 } # has_dt
1471
1472
1473
1474 }
1475
1476
1477 ;}
1478
1479 ;
1480 }
1481
1482
1483 {
1484
1485
1486 {
1487
1488 local $Error::Depth = $Error::Depth + 1;
1489
1490 {
1491
1492
1493 my
1494 $strict = $self->
1495 strict_error_checking
1496 ;
1497
1498 ## -- Node Type check
1499 my @new_child;
1500 if ({
1501 3 => (not $strictc),
1502 5 => (not $strictc),
1503 1 => 1,
1504 4 => (not $strictc),
1505 7 => 1,
1506 8 => 1,
1507 10 => 1,
1508 }->{$child_nt}) {
1509 push @new_child, $newChild;
1510 } elsif ($child_nt ==
1511 11
1512 ) {
1513 for my $cn (@{$newChild->
1514 child_nodes
1515 }) {
1516 unless ({
1517 3 => (not $strictc),
1518 5 => (not $strictc),
1519 1 => 1,
1520 4 => (not $strictc),
1521 7 => 1,
1522 8 => 1,
1523 10 => 1,
1524 }->{$cn->
1525 node_type
1526 }) {
1527
1528
1529 {
1530
1531 local $Error::Depth = $Error::Depth - 1;
1532
1533 {
1534
1535 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1536
1537
1538 }
1539
1540
1541 ;}
1542
1543 ;
1544 }
1545 push @new_child, $cn;
1546 }
1547 } else {
1548
1549
1550 {
1551
1552 local $Error::Depth = $Error::Depth - 1;
1553
1554 {
1555
1556 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1557
1558
1559 }
1560
1561
1562 ;}
1563
1564 ;
1565 }
1566
1567 my $nc_parent = @new_child ? $new_child[0]->
1568 parent_node
1569 :
1570
1571 undef
1572 ;
1573 if ($strict) {
1574 ## -- Wrong-document check
1575 unless ($self eq $child_od) {
1576
1577
1578 {
1579
1580 local $Error::Depth = $Error::Depth - 1;
1581
1582 {
1583
1584 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1585
1586
1587 }
1588
1589
1590 ;}
1591
1592 ;
1593 }
1594
1595 ## -- Read-onlyness check
1596 if ($self->
1597 manakai_read_only
1598 ) {
1599
1600
1601 {
1602
1603 local $Error::Depth = $Error::Depth - 1;
1604
1605 {
1606
1607 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1';
1608
1609
1610 }
1611
1612
1613 ;}
1614
1615 ;
1616 }
1617 if (@new_child) {
1618 if ($nc_parent and
1619 $nc_parent->
1620 manakai_read_only
1621 ) {
1622
1623
1624 {
1625
1626 local $Error::Depth = $Error::Depth - 1;
1627
1628 {
1629
1630 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1';
1631
1632
1633 }
1634
1635
1636 ;}
1637
1638 ;
1639 }
1640 }
1641 }
1642
1643 ## -- Insert at...
1644 my $index = -1; # last
1645
1646
1647 {
1648
1649
1650 # tc:ForAppendChild & tc:ForReplaceChild
1651 if (defined $oldChild) {
1652 if ($oldChild eq $newChild) {
1653
1654
1655 ;
1656
1657
1658 {
1659
1660
1661 {
1662
1663 local $Error::Depth = $Error::Depth - 1;
1664
1665 {
1666
1667 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1';
1668
1669
1670 }
1671
1672
1673 ;}
1674
1675 ;
1676
1677
1678
1679 }
1680
1681 ;
1682 }
1683
1684 my $cns = $self->
1685 child_nodes
1686 ;
1687 my $cnsl = @$cns;
1688 C: {
1689 $index = 0;
1690 for my $i (0..($cnsl-1)) {
1691 my $cn = $cns->[$i];
1692 if ($cn eq $oldChild) {
1693 $index += $i;
1694 last C;
1695 } elsif ($cn eq $newChild) {
1696 $index = -1; # offset
1697 }
1698 }
1699
1700
1701 ;
1702
1703
1704 {
1705
1706
1707 {
1708
1709 local $Error::Depth = $Error::Depth - 1;
1710
1711 {
1712
1713 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
1714
1715
1716 }
1717
1718
1719 ;}
1720
1721 ;
1722
1723
1724
1725 }
1726
1727 ;
1728 } # C
1729 } else { # |oldChild| is not defined
1730
1731
1732 {
1733
1734
1735 {
1736
1737 local $Error::Depth = $Error::Depth - 1;
1738
1739 {
1740
1741 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
1742
1743
1744 }
1745
1746
1747 ;}
1748
1749 ;
1750
1751
1752
1753 }
1754
1755 ;
1756 }
1757
1758
1759
1760 }
1761
1762 ; # FOR !tc:ForAppendChild
1763
1764 ## -- Removes from parent
1765 if ($nc_parent) {
1766 if ($child_nt ==
1767 11
1768 ) {
1769 $$newChild->{
1770 'child'
1771 } = [];
1772 } else {
1773 my $v = $$nc_parent->{
1774 'child'
1775 };
1776 RP: for my $i (0..$#$v) {
1777 if ($v->[$i] eq $new_child[0]) {
1778 splice @$v, $i, 1, ();
1779 last RP;
1780 }
1781 } # RP
1782 }
1783 }
1784
1785 ## -- Rewrite the |parentNode| properties
1786 for my $nc (@new_child) {
1787 $$nc->{
1788 'parent'
1789 } = $self;
1790 Scalar::Util::weaken ($$nc->{
1791 'parent'
1792 });
1793 }
1794
1795 my $children = $$self->{
1796 'child'
1797 };
1798
1799
1800
1801 ;
1802
1803
1804
1805 ;
1806
1807
1808
1809 {
1810
1811
1812 ## -- Replaces the node
1813 splice @$children, $index, 1, @new_child;
1814 CORE::delete $$oldChild->{
1815 'parent'
1816 };
1817 $r = $oldChild;
1818
1819
1820
1821 }
1822
1823 ;
1824
1825
1826
1827 }
1828
1829
1830 ;}
1831
1832 ;
1833
1834
1835 }
1836
1837 ;
1838 if ($child_nt ==
1839 10 and
1840
1841 not defined $newChild->
1842 owner_document
1843 ) {
1844 CORE::delete $$newChild->{
1845 'impl'
1846 };
1847 $$newChild->{
1848 'od'
1849 } = $self;
1850 Scalar::Util::weaken ($$newChild->{
1851 'od'
1852 });
1853 }
1854
1855
1856 }
1857 $r}
1858 sub manakai_append_text ($$) {
1859 my ($self, $string) = @_;
1860 my $r;
1861
1862 {
1863
1864
1865 {
1866
1867 local $Error::Depth = $Error::Depth + 1;
1868
1869 {
1870
1871
1872 unless
1873 ($self->
1874 dom_config
1875
1876 ->
1877 get_parameter
1878
1879 (
1880 'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
1881 )) {
1882 my $lc = $self->
1883 last_child
1884 ;
1885 if (defined $lc and
1886 $lc->
1887 node_type
1888 ==
1889 3
1890 ) {
1891 $lc->
1892 manakai_append_text
1893
1894 (ref $string eq 'SCALAR' ? $string : \$string);
1895 } else {
1896 my $text = $self->
1897 create_text_node
1898
1899 (ref $string eq 'SCALAR' ? $$string : $string);
1900 $self->
1901 append_child
1902 ($text);
1903 }
1904 }
1905 $r = $self;
1906
1907
1908
1909 }
1910
1911
1912 ;}
1913
1914 ;
1915
1916
1917 }
1918 $r}
1919 sub remove_child ($$) {
1920 my ($self, $oldChild) = @_;
1921 my $r;
1922
1923 {
1924
1925 if
1926 ($self->
1927 strict_error_checking and
1928
1929 $self->
1930 manakai_read_only
1931 ) {
1932
1933 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'remove_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument';
1934
1935 ;
1936 }
1937
1938
1939 {
1940
1941 F:
1942 {
1943 my $i = -1;
1944 my $v = $$self->{
1945 'child'
1946 };
1947 for my $cld (@$v) {
1948 $i++;
1949 if ($cld eq $oldChild) {
1950 splice @$v, $i, 1, ();
1951 CORE::delete $$oldChild->{
1952 'parent'
1953 };
1954 $r = $oldChild;
1955 last F;
1956 }
1957 }
1958
1959 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/removeChildImpl', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
1960
1961 ;
1962 } # F
1963
1964
1965 }
1966
1967 ;
1968
1969
1970 }
1971 $r}
1972 sub node_name ($;$) {
1973 if (@_ == 1) {my ($self) = @_;
1974 my $r = '';
1975 $r = '#document';
1976 $r;
1977 } else {my ($self) = @_;
1978 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_name';
1979 }
1980 }
1981 sub text_content ($;$) {
1982 if (@_ == 1) {my ($self) = @_;
1983 my $r = '';
1984
1985 {
1986
1987
1988 {
1989
1990 local $Error::Depth = $Error::Depth + 1;
1991
1992 {
1993
1994
1995 if
1996 ($self->
1997 dom_config
1998
1999 ->
2000 get_parameter
2001
2002 (
2003 'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
2004 )) {
2005 $r =
2006 undef
2007 ;
2008 } else {
2009 $r = '';
2010 my @target = @{$self->
2011 child_nodes
2012 };
2013 C: for my $node (@target) {
2014 my $nt = $node->
2015 node_type
2016 ;
2017 if ($nt ==
2018 3 or
2019
2020 $nt ==
2021 4
2022 ) {
2023 $r .= $node->
2024 data
2025 unless
2026 $node->
2027 is_element_content_whitespace
2028 ;
2029 } elsif ($nt ==
2030 1 or
2031
2032 $nt ==
2033 5
2034 ) {
2035 unshift @target, @{$node->
2036 child_nodes
2037 };
2038 }
2039 }
2040 }
2041
2042
2043
2044 }
2045
2046
2047 ;}
2048
2049 ;
2050
2051
2052 }
2053 $r;
2054 } else {my ($self, $given) = @_;
2055
2056 {
2057
2058 if
2059 ($self->
2060 dom_config
2061
2062 ->
2063 get_parameter
2064
2065 (
2066 'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
2067 )) {
2068
2069 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#setting-node-value-no-effect', 'rdata' => $self, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'text_content';
2070
2071 ;
2072 } else {
2073
2074
2075 {
2076
2077
2078 {
2079
2080 if
2081 ($self->
2082 manakai_read_only
2083 ) {
2084
2085 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
2086
2087 ;
2088 }
2089
2090
2091 }
2092
2093 ;
2094
2095 for my $__old_child (@{${$self}->{
2096 'child'
2097 }}) {
2098 CORE::delete $$__old_child->{
2099 'parent'
2100 };
2101 }
2102
2103 my @__new_children;
2104 if (defined $given and length $given) {
2105 my $__text = $self->
2106 create_text_node
2107 ($given);
2108 push @__new_children, $__text;
2109 $$__text->{
2110 'parent'
2111 } = $self;
2112 Scalar::Util::weaken ($$__text->{
2113 'parent'
2114 });
2115 }
2116
2117 ${$self}->{
2118 'child'
2119 } = \@__new_children;
2120
2121
2122 }
2123
2124 ;
2125 }
2126
2127
2128 }
2129 }
2130 }
2131 sub get_feature ($$$) {
2132 my ($self, $feature, $version) = @_;
2133
2134 {
2135
2136
2137 $feature = lc $feature;
2138
2139
2140 }
2141
2142 {
2143
2144
2145 $version = '' unless defined $version;
2146
2147
2148 }
2149 my $r;
2150
2151 {
2152
2153
2154 $feature =~ s/^\+//;
2155
2156
2157 {
2158
2159 if
2160 ($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) {
2161 $r = $self;
2162 }
2163
2164
2165 }
2166
2167 ;
2168 unless (defined $r) {
2169
2170
2171 {
2172
2173 local $Error::Depth = $Error::Depth + 1;
2174
2175 {
2176
2177
2178
2179 $r = $self->SUPER::get_feature ($feature, $version);
2180
2181
2182
2183 }
2184
2185
2186 ;}
2187
2188 ;
2189 }
2190
2191
2192 }
2193 $r}
2194 sub base_uri ($;$) {
2195 if (@_ == 1) {my ($self) = @_;
2196 my $r = '';
2197
2198 {
2199
2200
2201 $r = $$self->{
2202 'buri'
2203 };
2204 unless (defined $r) {
2205 $r = $$self->{
2206 'duri'
2207 };
2208 }
2209
2210
2211 }
2212 $r;
2213 } else {my ($self) = @_;
2214 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'base_uri';
2215 }
2216 }
2217 sub create_document_fragment ($) {
2218 my ($self) = @_;
2219 my $r;
2220
2221 {
2222
2223
2224 $r = bless \{
2225
2226 'od'
2227 => $self,
2228
2229 'child'
2230 => [],
2231 },
2232 'Message::DOM::Document::ManakaiDOMDocumentFragment'
2233 ;
2234 Scalar::Util::weaken ($$r->{
2235 'od'
2236 });
2237
2238
2239 }
2240 $r}
2241 sub strict_error_checking ($;$) {
2242 if (@_ == 1) {my ($self) = @_;
2243 my $r = 0;
2244
2245 {
2246
2247
2248 $r = $$self->{
2249 'chk'
2250 };
2251
2252
2253 }
2254 $r;
2255 } else {my ($self, $given) = @_;
2256
2257 {
2258
2259
2260 $$self->{
2261 'chk'
2262 } = $given;
2263
2264
2265 }
2266 }
2267 }
2268 sub dom_config ($;$) {
2269 if (@_ == 1) {my ($self) = @_;
2270 my $r;
2271
2272 {
2273
2274
2275 {
2276
2277
2278 $r = bless [$self, $$self, 'Message::DOM::IF::Document'],
2279
2280 'Message::DOM::DOMCore::ManakaiDOMConfiguration'
2281 ;
2282
2283
2284 }
2285
2286 ;
2287
2288
2289 }
2290 $r;
2291 } else {my ($self) = @_;
2292 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'dom_config';
2293 }
2294 }
2295 sub document_element ($;$) {
2296 if (@_ == 1) {my ($self) = @_;
2297 my $r;
2298
2299 {
2300
2301
2302 {
2303
2304 local $Error::Depth = $Error::Depth + 1;
2305
2306 {
2307
2308
2309 F:
2310 for my $child (@{$self->
2311 child_nodes
2312 }) {
2313 if ($child->
2314 node_type
2315 ==
2316 1
2317 ) {
2318 $r = $child;
2319 last F;
2320 }
2321 } # F
2322
2323
2324
2325 }
2326
2327
2328 ;}
2329
2330 ;
2331
2332
2333 }
2334 $r;
2335 } else {my ($self) = @_;
2336 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'document_element';
2337 }
2338 }
2339 sub implementation ($;$) {
2340 if (@_ == 1) {my ($self) = @_;
2341 my $r;
2342
2343 {
2344
2345
2346 $r = $$self->{
2347 'impl'
2348 };
2349
2350
2351 }
2352 $r;
2353 } else {my ($self) = @_;
2354 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'implementation';
2355 }
2356 }
2357 sub xml_version ($;$) {
2358 if (@_ == 1) {my ($self) = @_;
2359 my $r = '';
2360
2361 {
2362
2363
2364 $r = $$self->{
2365 'http://www.w3.org/2001/04/infoset#version'
2366 };
2367
2368
2369 }
2370 $r;
2371 } else {my ($self, $given) = @_;
2372
2373 {
2374
2375
2376 {
2377
2378 if
2379 ($self->
2380 manakai_read_only
2381 ) {
2382
2383 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
2384
2385 ;
2386 }
2387
2388
2389 }
2390
2391 ;
2392 if (defined $given and
2393 ($given eq '1.0' or $given eq '1.1' or
2394 not $self->
2395 strict_error_checking
2396 )) {
2397 $$self->{
2398 'http://www.w3.org/2001/04/infoset#version'
2399 } = $given;
2400 } else {
2401
2402 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_NOSUPPORT_XMLVER', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'xml_version', 'http://www.w3.org/2001/04/infoset#version' => $given;
2403
2404 ;
2405 }
2406
2407
2408 }
2409 }
2410 }
2411 sub doctype ($;$) {
2412 if (@_ == 1) {my ($self) = @_;
2413 my $r;
2414
2415 {
2416
2417
2418 {
2419
2420 local $Error::Depth = $Error::Depth + 1;
2421
2422 {
2423
2424
2425 F:
2426 for my $child (@{$self->
2427 child_nodes
2428 }) {
2429 my $nt = $child->
2430 node_type
2431 ;
2432 if ($nt ==
2433 10
2434 ) {
2435 $r = $child;
2436 last F;
2437 } elsif ($nt ==
2438 1
2439 ) { # document element
2440 last F;
2441 }
2442 } # F
2443
2444
2445
2446 }
2447
2448
2449 ;}
2450
2451 ;
2452
2453
2454 }
2455 $r;
2456 } else {my ($self) = @_;
2457 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'doctype';
2458 }
2459 }
2460 sub document_uri ($;$) {
2461 if (@_ == 1) {my ($self) = @_;
2462 my $r = '';
2463
2464 {
2465
2466
2467 $r = $$self->{
2468 'duri'
2469 };
2470
2471
2472 }
2473 $r;
2474 } else {my ($self, $given) = @_;
2475
2476 {
2477
2478
2479 {
2480
2481 if
2482 ($self->
2483 manakai_read_only
2484 ) {
2485
2486 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
2487
2488 ;
2489 }
2490
2491
2492 }
2493
2494 ;
2495 $$self->{
2496 'duri'
2497 } = $given;
2498
2499
2500 }
2501 }
2502 }
2503 sub input_encoding ($;$) {
2504 if (@_ == 1) {my ($self) = @_;
2505 my $r = '';
2506
2507 {
2508
2509
2510 $r = $$self->{
2511 'ces'
2512 };
2513
2514
2515 }
2516 $r;
2517 } else {my ($self, $given) = @_;
2518
2519 {
2520
2521
2522 {
2523
2524 if
2525 ($self->
2526 manakai_read_only
2527 ) {
2528
2529 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
2530
2531 ;
2532 }
2533
2534
2535 }
2536
2537 ;
2538 $$self->{
2539 'ces'
2540 } = $given;
2541
2542
2543 }
2544 }
2545 }
2546 sub xml_encoding ($;$) {
2547 if (@_ == 1) {my ($self) = @_;
2548 my $r = '';
2549
2550 {
2551
2552
2553 $r = $$self->{
2554 'xcs'
2555 };
2556
2557
2558 }
2559 $r;
2560 } else {my ($self, $given) = @_;
2561
2562 {
2563
2564
2565 {
2566
2567 if
2568 ($self->
2569 manakai_read_only
2570 ) {
2571
2572 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
2573
2574 ;
2575 }
2576
2577
2578 }
2579
2580 ;
2581 $$self->{
2582 'xcs'
2583 } = $given;
2584
2585
2586 }
2587 }
2588 }
2589 sub xml_standalone ($;$) {
2590 if (@_ == 1) {my ($self) = @_;
2591 my $r = 0;
2592
2593 {
2594
2595
2596 $r = $$self->{
2597 'http://www.w3.org/2001/04/infoset#standalone'
2598 };
2599
2600
2601 }
2602 $r;
2603 } else {my ($self, $given) = @_;
2604
2605 {
2606
2607
2608 {
2609
2610 if
2611 ($self->
2612 manakai_read_only
2613 ) {
2614
2615 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
2616
2617 ;
2618 }
2619
2620
2621 }
2622
2623 ;
2624 $$self->{
2625 'http://www.w3.org/2001/04/infoset#standalone'
2626 } = $given;
2627
2628
2629 }
2630 }
2631 }
2632 sub adopt_node ($$) {
2633 my ($self, $source) = @_;
2634 my $r;
2635
2636 {
2637
2638 ADOPT:
2639 {
2640 last ADOPT
2641 unless $source->isa (
2642 'Message::DOM::TreeCore::ManakaiDOMNode'
2643 );
2644
2645 my $strict = $self->
2646 strict_error_checking
2647 ;
2648 if ($strict and $self->
2649 manakai_read_only
2650 ) {
2651
2652 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'source';
2653
2654 ;
2655 }
2656 my $parent = $source->
2657 parent_node
2658 ;
2659 if ($strict and defined $parent and
2660 $parent->
2661 manakai_read_only
2662 ) {
2663
2664 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'parent';
2665
2666 ;
2667 }
2668 my $nt = $source->
2669 node_type
2670 ;
2671 my $oe;
2672 if ($nt ==
2673 2
2674 ) {
2675 $oe = $source->
2676 owner_element
2677 ;
2678 if ($strict and defined $oe and $oe->
2679 manakai_read_only
2680 ) {
2681
2682 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'oe';
2683
2684 ;
2685 }
2686 } elsif ($nt ==
2687 9 or
2688
2689 $nt ==
2690 10 or
2691
2692 $nt ==
2693 6 or
2694
2695 $nt ==
2696 12
2697 ) {
2698
2699 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#ADOPT_NODE_TYPE_NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'source';
2700
2701 ;
2702 }
2703
2704 my @change_od;
2705 my @nodes = ($source);
2706 while (@nodes) {
2707 my $node = shift @nodes;
2708 my $nt = $node->
2709 node_type
2710 ;
2711 if ($strict and $node->
2712 manakai_read_only
2713 ) {
2714
2715 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOMOD_DESCENDANT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $node;
2716
2717 ;
2718 }
2719 if ($nt ==
2720 1
2721 ) {
2722 push @change_od, $node;
2723 push @nodes, @{$node->
2724 child_nodes
2725 };
2726 my $attrs = $node->
2727 attributes
2728 ;
2729 my $attrsLength = $attrs->
2730 length
2731 ;
2732 for my $i (0..($attrsLength - 1)) {
2733 push @nodes, $attrs->
2734 item
2735 ($i);
2736 }
2737 } elsif ($nt ==
2738 2 or
2739
2740 $nt ==
2741 5 or
2742
2743 $nt ==
2744 11
2745 ) {
2746 push @change_od, $node;
2747 push @nodes, @{$node->
2748 child_nodes
2749 };
2750 } elsif ($nt ==
2751 3 or
2752
2753 $nt ==
2754 8 or
2755
2756 $nt ==
2757 7 or
2758
2759 $nt ==
2760 4
2761 ) {
2762 push @change_od, $node;
2763 } else {
2764 ## TODO: assertion
2765 }
2766 } # nodes
2767
2768
2769
2770 {
2771
2772 local $Error::Depth = $Error::Depth + 1;
2773
2774 {
2775
2776
2777 if
2778 (defined $parent) {
2779 $parent->
2780 remove_child
2781 ($source);
2782 } elsif (defined $oe) {
2783 $oe->
2784 remove_attribute_node
2785 ($source);
2786 }
2787
2788
2789
2790 }
2791
2792
2793 ;}
2794
2795 ;
2796
2797 $r = $source;
2798 my $old_od = $change_od[0]->
2799 owner_document
2800 ;
2801 ## NOTE: The array must have more than zero
2802 ## nodes by definition. In addition,
2803 ## it cannot contain document or document
2804 ## type nodes in current implementation.
2805
2806 if ($old_od eq $self) {
2807 last ADOPT;
2808 }
2809
2810 for my $n (@change_od) {
2811 $$n->{
2812 'od'
2813 } = $self;
2814 Scalar::Util::weaken ($$n->{
2815 'od'
2816 });
2817 }
2818
2819 for my $src (@change_od) {
2820 my $src_ud = $$src->{
2821 'ud'
2822 };
2823 for my $key (keys %{$src_ud or {}}) {
2824 my $dh = $src_ud->{$key}->[1];
2825 if ($dh) {
2826 $dh->
2827 handle
2828
2829 (
2830 5
2831 ,
2832 $key, $src_ud->{$key}->[0], $src,
2833 undef
2834 );
2835 }
2836 }
2837 }
2838 } # ADOPT
2839
2840
2841 }
2842 $r}
2843 sub get_element_by_id ($$) {
2844 my ($self, $elementId) = @_;
2845 my $r;
2846
2847 {
2848
2849
2850 {
2851
2852 local $Error::Depth = $Error::Depth + 1;
2853
2854 {
2855
2856
2857 my
2858 @nodes = @{$self->
2859 child_nodes
2860 };
2861 N: while (@nodes) {
2862 my $node = shift @nodes;
2863 next N unless $node->
2864 node_type
2865 ==
2866 1
2867 ;
2868 for my $attr (@{$node->
2869 attributes
2870 }) {
2871 if ($attr->
2872 is_id and
2873
2874 $attr->
2875 value eq
2876 $elementId) {
2877 $r = $attr;
2878 last N;
2879 }
2880 }
2881 unshift @nodes, @{$node->
2882 child_nodes
2883 };
2884 } # N
2885
2886
2887
2888 }
2889
2890
2891 ;}
2892
2893 ;
2894
2895
2896 }
2897 $r}
2898 sub get_elements_by_tag_name ($$) {
2899 my ($self, $name) = @_;
2900 my $r;
2901
2902 {
2903
2904
2905 $name = "$name";
2906 my $chk;
2907 if ($name eq '*') {
2908 $chk = sub {
2909 1
2910 };
2911 } else {
2912 $chk = sub {
2913 my $node = shift;
2914 my $nodeName = $node->
2915 node_name
2916 ;
2917 ($nodeName eq $name);
2918 };
2919 }
2920
2921
2922 {
2923
2924
2925 $r = bless \[$self, $chk],
2926 'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList'
2927 ;
2928
2929
2930 }
2931
2932 ;
2933
2934
2935 }
2936 $r}
2937 sub get_elements_by_tag_name_ns ($$$) {
2938 my ($self, $namespaceURI, $localName) = @_;
2939
2940 {
2941
2942 if
2943 (CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) {
2944 require Message::DOM::DOMMain;
2945
2946 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:1167487489:32060:02l5m38360';
2947
2948 ;
2949
2950 $namespaceURI = undef;
2951 }
2952
2953
2954 }
2955 my $r;
2956
2957 {
2958
2959
2960 $namespaceURI = "$namespaceURI" if defined $namespaceURI;
2961 $localName = "$localName";
2962 my $chk;
2963 if (not defined $namespaceURI) {
2964 if ($localName eq '*') {
2965 $chk = sub {
2966 my $node = shift;
2967 (not defined $node->
2968 namespace_uri
2969 );
2970 };
2971 } else {
2972 $chk = sub {
2973 my $node = shift;
2974 (not defined $node->
2975 namespace_uri and
2976
2977 $node->
2978 local_name eq
2979 $localName);
2980 };
2981 }
2982 } elsif ($namespaceURI eq '*') {
2983 if ($localName eq '*') {
2984 $chk = sub {
2985 1
2986 };
2987 } else {
2988 $chk = sub {
2989 my $node = shift;
2990 ($node->
2991 local_name eq
2992 $localName);
2993 };
2994 }
2995 } else {
2996 if ($localName eq '*') {
2997 $chk = sub {
2998 my $node = shift;
2999 my $nsuri = $node->
3000 namespace_uri
3001 ;
3002 (defined $nsuri and $nsuri eq $namespaceURI);
3003 };
3004 } else {
3005 $chk = sub {
3006 my $node = shift;
3007 my $nsuri = $node->
3008 namespace_uri
3009 ;
3010 (defined $nsuri and $nsuri eq $namespaceURI and
3011 $node->
3012 local_name eq
3013 $localName);
3014 };
3015 }
3016 }
3017
3018
3019 {
3020
3021
3022 $r = bless \[$self, $chk],
3023 'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList'
3024 ;
3025
3026
3027 }
3028
3029 ;
3030
3031
3032 }
3033 $r}
3034 sub import_node ($$;$) {
3035 my ($self, $importedNode, $deep) = @_;
3036 my $r;
3037 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'import_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_METHOD_NOT_IMPLEMENTED', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument';
3038 $r}
3039 sub normalize_document ($) {
3040 my ($self) = @_;
3041 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'normalize_document', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_METHOD_NOT_IMPLEMENTED', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument';
3042 }
3043 sub rename_node ($$$$) {
3044 my ($self, $n, $namespaceURI, $qualifiedName) = @_;
3045
3046 {
3047
3048 if
3049 (CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) {
3050 require Message::DOM::DOMMain;
3051
3052 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:1167487489:32060:02l5m38360';
3053
3054 ;
3055
3056 $namespaceURI = undef;
3057 }
3058
3059
3060 }
3061 my $r;
3062 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'rename_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_METHOD_NOT_IMPLEMENTED', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument';
3063 $r}
3064 sub manakai_entity_base_uri ($;$) {
3065 if (@_ == 1) {my ($self) = @_;
3066 my $r = '';
3067
3068 {
3069
3070
3071 $r = $$self->{
3072 'buri'
3073 };
3074 unless (defined $r) {
3075 $r = $$self->{
3076 'duri'
3077 };
3078 }
3079
3080
3081 }
3082 $r;
3083 } else {my ($self, $given) = @_;
3084
3085 {
3086
3087
3088 {
3089
3090 if
3091 ($self->
3092 manakai_read_only
3093 ) {
3094
3095 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
3096
3097 ;
3098 }
3099
3100
3101 }
3102
3103 ;
3104 $$self->{
3105 'buri'
3106 } = $given;
3107
3108
3109 }
3110 }
3111 }
3112 sub all_declarations_processed ($;$) {
3113 if (@_ == 1) {my ($self) = @_;
3114 my $r = 0;
3115
3116 {
3117
3118
3119 $r = $$self->{
3120 'http://www.w3.org/2001/04/infoset#allDeclarationsProcessed'
3121 };
3122
3123
3124 }
3125 $r;
3126 } else {my ($self, $given) = @_;
3127
3128 {
3129
3130
3131 {
3132
3133 if
3134 ($self->
3135 manakai_read_only
3136 ) {
3137
3138 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError';
3139
3140 ;
3141 }
3142
3143
3144 }
3145
3146 ;
3147 $$self->{
3148 'http://www.w3.org/2001/04/infoset#allDeclarationsProcessed'
3149 } = $given;
3150
3151
3152 }
3153 }
3154 }
3155 $Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMDocument>}->{has_feature} = {'core',
3156 {'',
3157 '1'},
3158 'xml',
3159 {'',
3160 '1'},
3161 'xmlversion',
3162 {'',
3163 '1'}};
3164 $Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMDocument>} = 0;
3165 package Message::DOM::IF::DocumentFragment;
3166 our $VERSION = 20061230.1433;
3167 package Message::DOM::Document::ManakaiDOMDocumentFragment;
3168 our $VERSION = 20061230.1433;
3169 push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode',
3170 'Message::DOM::IF::DocumentFragment',
3171 'Message::DOM::IF::Node';
3172 sub node_type ($;$) {
3173 if (@_ == 1) {my ($self) = @_;
3174 my $r;
3175 $r = 11;
3176 $r;
3177 } else {my ($self) = @_;
3178 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_type';
3179 }
3180 }
3181 sub append_child ($$) {
3182 my ($self, $newChild) = @_;
3183 my $r;
3184
3185 {
3186
3187 if
3188 ($self eq $newChild) {
3189
3190 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#HIERARCHY_DOCUMENT_FRAGMENT_ITSELF_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild';
3191
3192 ;
3193 }
3194 my $self_od = $self->
3195 owner_document
3196 ;
3197 my $child_od = $newChild->
3198 owner_document
3199 ;
3200 my $child_nt = $newChild->
3201 node_type
3202 ;
3203
3204
3205 {
3206
3207
3208 {
3209
3210 local $Error::Depth = $Error::Depth + 1;
3211
3212 {
3213
3214
3215 my
3216 $strict = $self_od->
3217 strict_error_checking
3218 ;
3219
3220 ## -- Node Type check
3221 my @new_child;
3222 if ({
3223 3 => 1,
3224 5 => 1,
3225 1 => 1,
3226 7 => 1,
3227 4 => 1,
3228 8 => 1,
3229 }->{$child_nt}) {
3230 push @new_child, $newChild;
3231 } elsif ($child_nt ==
3232 11
3233 ) {
3234 for my $cn (@{$newChild->
3235 child_nodes
3236 }) {
3237 unless ({
3238 3 => 1,
3239 5 => 1,
3240 1 => 1,
3241 7 => 1,
3242 4 => 1,
3243 8 => 1,
3244 }->{$cn->
3245 node_type
3246 }) {
3247
3248
3249 {
3250
3251 local $Error::Depth = $Error::Depth - 1;
3252
3253 {
3254
3255 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3256
3257
3258 }
3259
3260
3261 ;}
3262
3263 ;
3264 }
3265 push @new_child, $cn;
3266 }
3267 } else {
3268
3269
3270 {
3271
3272 local $Error::Depth = $Error::Depth - 1;
3273
3274 {
3275
3276 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3277
3278
3279 }
3280
3281
3282 ;}
3283
3284 ;
3285 }
3286
3287 my $nc_parent = @new_child ? $new_child[0]->
3288 parent_node
3289 :
3290
3291 undef
3292 ;
3293 if ($strict) {
3294 ## -- Wrong-document check
3295 unless ($self_od eq $child_od) {
3296
3297
3298 {
3299
3300 local $Error::Depth = $Error::Depth - 1;
3301
3302 {
3303
3304 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3305
3306
3307 }
3308
3309
3310 ;}
3311
3312 ;
3313 }
3314
3315 ## -- Read-onlyness check
3316 if ($self->
3317 manakai_read_only
3318 ) {
3319
3320
3321 {
3322
3323 local $Error::Depth = $Error::Depth - 1;
3324
3325 {
3326
3327 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1';
3328
3329
3330 }
3331
3332
3333 ;}
3334
3335 ;
3336 }
3337 if (@new_child) {
3338 if ($nc_parent and
3339 $nc_parent->
3340 manakai_read_only
3341 ) {
3342
3343
3344 {
3345
3346 local $Error::Depth = $Error::Depth - 1;
3347
3348 {
3349
3350 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1';
3351
3352
3353 }
3354
3355
3356 ;}
3357
3358 ;
3359 }
3360 }
3361 }
3362
3363 ## -- Insert at...
3364 my $index = -1; # last
3365
3366
3367 ; # FOR !tc:ForAppendChild
3368
3369 ## -- Removes from parent
3370 if ($nc_parent) {
3371 if ($child_nt ==
3372 11
3373 ) {
3374 $$newChild->{
3375 'child'
3376 } = [];
3377 } else {
3378 my $v = $$nc_parent->{
3379 'child'
3380 };
3381 RP: for my $i (0..$#$v) {
3382 if ($v->[$i] eq $new_child[0]) {
3383 splice @$v, $i, 1, ();
3384 last RP;
3385 }
3386 } # RP
3387 }
3388 }
3389
3390 ## -- Rewrite the |parentNode| properties
3391 for my $nc (@new_child) {
3392 $$nc->{
3393 'parent'
3394 } = $self;
3395 Scalar::Util::weaken ($$nc->{
3396 'parent'
3397 });
3398 }
3399
3400 my $children = $$self->{
3401 'child'
3402 };
3403
3404
3405
3406 {
3407
3408
3409 ## -- Adds to children list
3410 push @$children, @new_child;
3411 $r = $newChild;
3412
3413
3414
3415 }
3416
3417 ;
3418
3419
3420
3421 ;
3422
3423
3424
3425 ;
3426
3427
3428
3429 }
3430
3431
3432 ;}
3433
3434 ;
3435
3436
3437 }
3438
3439 ;
3440
3441
3442 }
3443 $r}
3444 sub insert_before ($$;$) {
3445 my ($self, $newChild, $refChild) = @_;
3446 my $r;
3447
3448 {
3449
3450 if
3451 ($self eq $newChild) {
3452
3453 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#HIERARCHY_DOCUMENT_FRAGMENT_ITSELF_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild';
3454
3455 ;
3456 }
3457 my $self_od = $self->
3458 owner_document
3459 ;
3460 my $child_od = $newChild->
3461 owner_document
3462 ;
3463 my $child_nt = $newChild->
3464 node_type
3465 ;
3466
3467
3468 {
3469
3470
3471 {
3472
3473 local $Error::Depth = $Error::Depth + 1;
3474
3475 {
3476
3477
3478 my
3479 $strict = $self_od->
3480 strict_error_checking
3481 ;
3482
3483 ## -- Node Type check
3484 my @new_child;
3485 if ({
3486 3 => 1,
3487 5 => 1,
3488 1 => 1,
3489 7 => 1,
3490 4 => 1,
3491 8 => 1,
3492 }->{$child_nt}) {
3493 push @new_child, $newChild;
3494 } elsif ($child_nt ==
3495 11
3496 ) {
3497 for my $cn (@{$newChild->
3498 child_nodes
3499 }) {
3500 unless ({
3501 3 => 1,
3502 5 => 1,
3503 1 => 1,
3504 7 => 1,
3505 4 => 1,
3506 8 => 1,
3507 }->{$cn->
3508 node_type
3509 }) {
3510
3511
3512 {
3513
3514 local $Error::Depth = $Error::Depth - 1;
3515
3516 {
3517
3518 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3519
3520
3521 }
3522
3523
3524 ;}
3525
3526 ;
3527 }
3528 push @new_child, $cn;
3529 }
3530 } else {
3531
3532
3533 {
3534
3535 local $Error::Depth = $Error::Depth - 1;
3536
3537 {
3538
3539 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3540
3541
3542 }
3543
3544
3545 ;}
3546
3547 ;
3548 }
3549
3550 my $nc_parent = @new_child ? $new_child[0]->
3551 parent_node
3552 :
3553
3554 undef
3555 ;
3556 if ($strict) {
3557 ## -- Wrong-document check
3558 unless ($self_od eq $child_od) {
3559
3560
3561 {
3562
3563 local $Error::Depth = $Error::Depth - 1;
3564
3565 {
3566
3567 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3568
3569
3570 }
3571
3572
3573 ;}
3574
3575 ;
3576 }
3577
3578 ## -- Read-onlyness check
3579 if ($self->
3580 manakai_read_only
3581 ) {
3582
3583
3584 {
3585
3586 local $Error::Depth = $Error::Depth - 1;
3587
3588 {
3589
3590 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1';
3591
3592
3593 }
3594
3595
3596 ;}
3597
3598 ;
3599 }
3600 if (@new_child) {
3601 if ($nc_parent and
3602 $nc_parent->
3603 manakai_read_only
3604 ) {
3605
3606
3607 {
3608
3609 local $Error::Depth = $Error::Depth - 1;
3610
3611 {
3612
3613 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1';
3614
3615
3616 }
3617
3618
3619 ;}
3620
3621 ;
3622 }
3623 }
3624 }
3625
3626 ## -- Insert at...
3627 my $index = -1; # last
3628
3629
3630 {
3631
3632
3633 # tc:ForAppendChild & tc:ForReplaceChild
3634 if (defined $refChild) {
3635 if ($refChild eq $newChild) {
3636
3637
3638 {
3639
3640
3641 {
3642
3643 local $Error::Depth = $Error::Depth - 1;
3644
3645 {
3646
3647 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1';
3648
3649
3650 }
3651
3652
3653 ;}
3654
3655 ;
3656
3657
3658
3659 }
3660
3661 ;
3662
3663
3664 ;
3665 }
3666
3667 my $cns = $self->
3668 child_nodes
3669 ;
3670 my $cnsl = @$cns;
3671 C: {
3672 $index = 0;
3673 for my $i (0..($cnsl-1)) {
3674 my $cn = $cns->[$i];
3675 if ($cn eq $refChild) {
3676 $index += $i;
3677 last C;
3678 } elsif ($cn eq $newChild) {
3679 $index = -1; # offset
3680 }
3681 }
3682
3683
3684 {
3685
3686
3687 {
3688
3689 local $Error::Depth = $Error::Depth - 1;
3690
3691 {
3692
3693 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild;
3694
3695
3696 }
3697
3698
3699 ;}
3700
3701 ;
3702
3703
3704
3705 }
3706
3707 ;
3708
3709
3710 ;
3711 } # C
3712 } else { # |oldChild| is not defined
3713
3714
3715 ;
3716 }
3717
3718
3719
3720 }
3721
3722 ; # FOR !tc:ForAppendChild
3723
3724 ## -- Removes from parent
3725 if ($nc_parent) {
3726 if ($child_nt ==
3727 11
3728 ) {
3729 $$newChild->{
3730 'child'
3731 } = [];
3732 } else {
3733 my $v = $$nc_parent->{
3734 'child'
3735 };
3736 RP: for my $i (0..$#$v) {
3737 if ($v->[$i] eq $new_child[0]) {
3738 splice @$v, $i, 1, ();
3739 last RP;
3740 }
3741 } # RP
3742 }
3743 }
3744
3745 ## -- Rewrite the |parentNode| properties
3746 for my $nc (@new_child) {
3747 $$nc->{
3748 'parent'
3749 } = $self;
3750 Scalar::Util::weaken ($$nc->{
3751 'parent'
3752 });
3753 }
3754
3755 my $children = $$self->{
3756 'child'
3757 };
3758
3759
3760
3761 ;
3762
3763
3764
3765 {
3766
3767
3768 ## -- Adds to children list
3769 if ($index == -1) {
3770 push @$children, @new_child;
3771 } else {
3772 splice @$children, $index, 0, @new_child;
3773 }
3774 $r = $newChild;
3775
3776
3777
3778 }
3779
3780 ;
3781
3782
3783
3784 ;
3785
3786
3787
3788 }
3789
3790
3791 ;}
3792
3793 ;
3794
3795
3796 }
3797
3798 ;
3799
3800
3801 }
3802 $r}
3803 sub replace_child ($$$) {
3804 my ($self, $newChild, $oldChild) = @_;
3805 my $r;
3806
3807 {
3808
3809 if
3810 ($self eq $newChild) {
3811
3812 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#HIERARCHY_DOCUMENT_FRAGMENT_ITSELF_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild';
3813
3814 ;
3815 }
3816 my $self_od = $self->
3817 owner_document
3818 ;
3819 my $child_od = $newChild->
3820 owner_document
3821 ;
3822 my $child_nt = $newChild->
3823 node_type
3824 ;
3825
3826
3827 {
3828
3829
3830 {
3831
3832 local $Error::Depth = $Error::Depth + 1;
3833
3834 {
3835
3836
3837 my
3838 $strict = $self_od->
3839 strict_error_checking
3840 ;
3841
3842 ## -- Node Type check
3843 my @new_child;
3844 if ({
3845 3 => 1,
3846 5 => 1,
3847 1 => 1,
3848 7 => 1,
3849 4 => 1,
3850 8 => 1,
3851 }->{$child_nt}) {
3852 push @new_child, $newChild;
3853 } elsif ($child_nt ==
3854 11
3855 ) {
3856 for my $cn (@{$newChild->
3857 child_nodes
3858 }) {
3859 unless ({
3860 3 => 1,
3861 5 => 1,
3862 1 => 1,
3863 7 => 1,
3864 4 => 1,
3865 8 => 1,
3866 }->{$cn->
3867 node_type
3868 }) {
3869
3870
3871 {
3872
3873 local $Error::Depth = $Error::Depth - 1;
3874
3875 {
3876
3877 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3878
3879
3880 }
3881
3882
3883 ;}
3884
3885 ;
3886 }
3887 push @new_child, $cn;
3888 }
3889 } else {
3890
3891
3892 {
3893
3894 local $Error::Depth = $Error::Depth - 1;
3895
3896 {
3897
3898 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3899
3900
3901 }
3902
3903
3904 ;}
3905
3906 ;
3907 }
3908
3909 my $nc_parent = @new_child ? $new_child[0]->
3910 parent_node
3911 :
3912
3913 undef
3914 ;
3915 if ($strict) {
3916 ## -- Wrong-document check
3917 unless ($self_od eq $child_od) {
3918
3919
3920 {
3921
3922 local $Error::Depth = $Error::Depth - 1;
3923
3924 {
3925
3926 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3927
3928
3929 }
3930
3931
3932 ;}
3933
3934 ;
3935 }
3936
3937 ## -- Read-onlyness check
3938 if ($self->
3939 manakai_read_only
3940 ) {
3941
3942
3943 {
3944
3945 local $Error::Depth = $Error::Depth - 1;
3946
3947 {
3948
3949 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1';
3950
3951
3952 }
3953
3954
3955 ;}
3956
3957 ;
3958 }
3959 if (@new_child) {
3960 if ($nc_parent and
3961 $nc_parent->
3962 manakai_read_only
3963 ) {
3964
3965
3966 {
3967
3968 local $Error::Depth = $Error::Depth - 1;
3969
3970 {
3971
3972 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1';
3973
3974
3975 }
3976
3977
3978 ;}
3979
3980 ;
3981 }
3982 }
3983 }
3984
3985 ## -- Insert at...
3986 my $index = -1; # last
3987
3988
3989 {
3990
3991
3992 # tc:ForAppendChild & tc:ForReplaceChild
3993 if (defined $oldChild) {
3994 if ($oldChild eq $newChild) {
3995
3996
3997 ;
3998
3999
4000 {
4001
4002
4003 {
4004
4005 local $Error::Depth = $Error::Depth - 1;
4006
4007 {
4008
4009 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1';
4010
4011
4012 }
4013
4014
4015 ;}
4016
4017 ;
4018
4019
4020
4021 }
4022
4023 ;
4024 }
4025
4026 my $cns = $self->
4027 child_nodes
4028 ;
4029 my $cnsl = @$cns;
4030 C: {
4031 $index = 0;
4032 for my $i (0..($cnsl-1)) {
4033 my $cn = $cns->[$i];
4034 if ($cn eq $oldChild) {
4035 $index += $i;
4036 last C;
4037 } elsif ($cn eq $newChild) {
4038 $index = -1; # offset
4039 }
4040 }
4041
4042
4043 ;
4044
4045
4046 {
4047
4048
4049 {
4050
4051 local $Error::Depth = $Error::Depth - 1;
4052
4053 {
4054
4055 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
4056
4057
4058 }
4059
4060
4061 ;}
4062
4063 ;
4064
4065
4066
4067 }
4068
4069 ;
4070 } # C
4071 } else { # |oldChild| is not defined
4072
4073
4074 {
4075
4076
4077 {
4078
4079 local $Error::Depth = $Error::Depth - 1;
4080
4081 {
4082
4083 report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
4084
4085
4086 }
4087
4088
4089 ;}
4090
4091 ;
4092
4093
4094
4095 }
4096
4097 ;
4098 }
4099
4100
4101
4102 }
4103
4104 ; # FOR !tc:ForAppendChild
4105
4106 ## -- Removes from parent
4107 if ($nc_parent) {
4108 if ($child_nt ==
4109 11
4110 ) {
4111 $$newChild->{
4112 'child'
4113 } = [];
4114 } else {
4115 my $v = $$nc_parent->{
4116 'child'
4117 };
4118 RP: for my $i (0..$#$v) {
4119 if ($v->[$i] eq $new_child[0]) {
4120 splice @$v, $i, 1, ();
4121 last RP;
4122 }
4123 } # RP
4124 }
4125 }
4126
4127 ## -- Rewrite the |parentNode| properties
4128 for my $nc (@new_child) {
4129 $$nc->{
4130 'parent'
4131 } = $self;
4132 Scalar::Util::weaken ($$nc->{
4133 'parent'
4134 });
4135 }
4136
4137 my $children = $$self->{
4138 'child'
4139 };
4140
4141
4142
4143 ;
4144
4145
4146
4147 ;
4148
4149
4150
4151 {
4152
4153
4154 ## -- Replaces the node
4155 splice @$children, $index, 1, @new_child;
4156 CORE::delete $$oldChild->{
4157 'parent'
4158 };
4159 $r = $oldChild;
4160
4161
4162
4163 }
4164
4165 ;
4166
4167
4168
4169 }
4170
4171
4172 ;}
4173
4174 ;
4175
4176
4177 }
4178
4179 ;
4180
4181
4182 }
4183 $r}
4184 sub node_name ($;$) {
4185 if (@_ == 1) {my ($self) = @_;
4186 my $r = '';
4187 $r = '#document-fragment';
4188 $r;
4189 } else {my ($self) = @_;
4190 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_name';
4191 }
4192 }
4193 sub manakai_append_text ($$) {
4194 my ($self, $string) = @_;
4195 my $r;
4196
4197 {
4198
4199
4200 {
4201
4202 local $Error::Depth = $Error::Depth + 1;
4203
4204 {
4205
4206
4207 my
4208 $lc = $self->
4209 last_child
4210 ;
4211 if (defined $lc and
4212 $lc->
4213 node_type
4214 ==
4215 3
4216 ) {
4217 $lc->
4218 manakai_append_text
4219
4220 (ref $string eq 'SCALAR' ? $string : \$string);
4221 } else {
4222 my $text = $self->
4223 owner_document
4224
4225 ->
4226 create_text_node
4227
4228 (ref $string eq 'SCALAR' ? $$string : $string);
4229 $self->
4230 append_child
4231 ($text);
4232 }
4233 $r = $self;
4234
4235
4236
4237 }
4238
4239
4240 ;}
4241
4242 ;
4243
4244
4245 }
4246 $r}
4247 sub get_feature ($$$) {
4248 my ($self, $feature, $version) = @_;
4249
4250 {
4251
4252
4253 $feature = lc $feature;
4254
4255
4256 }
4257
4258 {
4259
4260
4261 $version = '' unless defined $version;
4262
4263
4264 }
4265 my $r;
4266
4267 {
4268
4269
4270 $feature =~ s/^\+//;
4271
4272
4273 {
4274
4275 if
4276 ($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) {
4277 $r = $self;
4278 }
4279
4280
4281 }
4282
4283 ;
4284 unless (defined $r) {
4285
4286
4287 {
4288
4289 local $Error::Depth = $Error::Depth + 1;
4290
4291 {
4292
4293
4294
4295 $r = $self->SUPER::get_feature ($feature, $version);
4296
4297
4298
4299 }
4300
4301
4302 ;}
4303
4304 ;
4305 }
4306
4307
4308 }
4309 $r}
4310 sub base_uri ($;$) {
4311 if (@_ == 1) {my ($self) = @_;
4312 my $r = '';
4313
4314 {
4315
4316
4317 {
4318
4319 local $Error::Depth = $Error::Depth + 1;
4320
4321 {
4322
4323
4324
4325 $r = $self->
4326 owner_document
4327 ->
4328 base_uri
4329 ;
4330
4331
4332
4333 }
4334
4335
4336 ;}
4337
4338 ;
4339
4340
4341 }
4342 $r;
4343 } else {my ($self) = @_;
4344 report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'base_uri';
4345 }
4346 }
4347 $Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMDocumentFragment>}->{has_feature} = {'core',
4348 {'',
4349 '1'},
4350 'xml',
4351 {'',
4352 '1'},
4353 'xmlversion',
4354 {'',
4355 '1'}};
4356 $Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMDocumentFragment>} = 0;
4357 for ($Message::DOM::IF::Node::){}
4358 ## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL>
4359 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24