/[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.20 - (show annotations) (download)
Sun Jul 29 08:19:58 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.19: +0 -0 lines
FILE REMOVED
++ ChangeLog	29 Jul 2007 08:07:03 -0000
	* .htaccess: New file.

2007-07-29  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/DOM/ChangeLog	29 Jul 2007 08:18:17 -0000
	* DOMString.dis, DOMString.pm, Document.dis, Document.pm,
	Element.dis, Element.pm, CharacterData.dis, CharacterData.pm,
	TreeCore.dis, TreeCore.pm, DOMCore.dis, DOMCore.pm,
	DOMFeature.dis, DOMFeature.pm, XML.dis, XML.pm,
	DOMMain.dis, DOMMain.pm, DOMLS.dis,
	GenericLS.dis, GenericLS.pm, SimpleLS.dis: Removed.

	* Makefile: Rules for DIS are removed.

2007-07-29  Wakaba  <wakaba@suika.fam.cx>

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24