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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24