1 |
wakaba |
1.1 |
package Message::DOM::ProcessingInstruction; |
2 |
|
|
use strict; |
3 |
|
|
our $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
4 |
|
|
push our @ISA, 'Message::DOM::Node', 'Message::IF::ProcessingInstruction'; |
5 |
|
|
require Message::DOM::Node; |
6 |
|
|
|
7 |
|
|
## Spec: |
8 |
|
|
## |
9 |
|
|
|
10 |
|
|
sub ____new ($$$$) { |
11 |
|
|
my $self = shift->SUPER::____new (shift); |
12 |
|
|
($$self->{target}, $$self->{data}) = @_; |
13 |
|
|
return $self; |
14 |
|
|
} # ____new |
15 |
|
|
|
16 |
|
|
sub AUTOLOAD { |
17 |
|
|
my $method_name = our $AUTOLOAD; |
18 |
|
|
$method_name =~ s/.*:://; |
19 |
|
|
return if $method_name eq 'DESTROY'; |
20 |
|
|
|
21 |
|
|
if ({ |
22 |
|
|
## Read-only attributes (trivial accessors) |
23 |
|
|
target => 1, |
24 |
|
|
data => 1, |
25 |
|
|
}->{$method_name}) { |
26 |
|
|
no strict 'refs'; |
27 |
|
|
eval qq{ |
28 |
|
|
sub $method_name (\$) { |
29 |
|
|
if (\@_ > 1) { |
30 |
|
|
require Carp; |
31 |
|
|
Carp::croak (qq<Can't modify read-only attribute>); |
32 |
|
|
} |
33 |
|
|
return \${\$_[0]}->{$method_name}; |
34 |
|
|
} |
35 |
|
|
}; |
36 |
|
|
goto &{ $AUTOLOAD }; |
37 |
|
|
} elsif ({ |
38 |
|
|
## Read-write attributes (DOMString, trivial accessors) |
39 |
|
|
}->{$method_name}) { |
40 |
|
|
no strict 'refs'; |
41 |
|
|
eval qq{ |
42 |
|
|
sub $method_name (\$) { |
43 |
|
|
if (\@_ > 1) { |
44 |
|
|
\${\$_[0]}->{$method_name} = ''.$_[1]; |
45 |
|
|
} |
46 |
|
|
return \${\$_[0]}->{$method_name}; |
47 |
|
|
} |
48 |
|
|
}; |
49 |
|
|
goto &{ $AUTOLOAD }; |
50 |
|
|
} else { |
51 |
|
|
require Carp; |
52 |
|
|
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
53 |
|
|
} |
54 |
|
|
} # AUTOLOAD |
55 |
|
|
sub target ($); |
56 |
|
|
sub data ($); |
57 |
|
|
|
58 |
|
|
## The |Node| interface - attribute |
59 |
|
|
|
60 |
wakaba |
1.2 |
## Spec: |
61 |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D095> |
62 |
|
|
## Modified: <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1841493061> |
63 |
|
|
|
64 |
|
|
## The target of the processing instruction [DOM1, DOM2]. |
65 |
|
|
## Same as |ProcessingInstruction.target| [DOM3]. |
66 |
|
|
|
67 |
|
|
*node_name = \⌖ |
68 |
|
|
|
69 |
|
|
## Spec: |
70 |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-111237558> |
71 |
|
|
|
72 |
|
|
sub node_type ($) { 7 } # PROCESSING_INSTRUCTION_NODE |
73 |
|
|
|
74 |
|
|
## Spec: |
75 |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D080> |
76 |
|
|
## Modified: <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1841493061> |
77 |
|
|
|
78 |
|
|
## The entire content exclude the target [DOM1, DOM2]. |
79 |
|
|
## Same as |ProcessingInstruction.data| [DOM3]. |
80 |
|
|
|
81 |
|
|
*node_value = \&data; |
82 |
wakaba |
1.1 |
|
83 |
|
|
package Message::IF::ProcessingInstruction; |
84 |
|
|
|
85 |
|
|
package Message::DOM::Document; |
86 |
|
|
|
87 |
|
|
## Spec: |
88 |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-135944439> |
89 |
|
|
## Compatibility note: |
90 |
|
|
## <http://suika.fam.cx/gate/2005/sw/createProcessingInstruction> |
91 |
|
|
|
92 |
|
|
sub create_processing_instruction ($$$) { |
93 |
|
|
return Message::DOM::ProcessingInstruction->____new (@_[0, 1, 2]); |
94 |
|
|
} # create_processing_instruction |
95 |
|
|
|
96 |
|
|
1; |
97 |
|
|
## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL> |
98 |
wakaba |
1.2 |
## $Date: 2007/06/14 13:10:07 $ |