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