1 |
wakaba |
1.1 |
package Message::DOM::Notation; |
2 |
|
|
use strict; |
3 |
wakaba |
1.5 |
our $VERSION=do{my @r=(q$Revision: 1.4 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
4 |
wakaba |
1.1 |
push our @ISA, 'Message::DOM::Node', 'Message::IF::Notation'; |
5 |
|
|
require Message::DOM::Node; |
6 |
|
|
|
7 |
|
|
sub ____new ($$$) { |
8 |
|
|
my $self = shift->SUPER::____new (shift); |
9 |
|
|
$$self->{node_name} = $_[0]; |
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 |
wakaba |
1.2 |
node_name => 1, |
21 |
wakaba |
1.1 |
}->{$method_name}) { |
22 |
|
|
no strict 'refs'; |
23 |
|
|
eval qq{ |
24 |
|
|
sub $method_name (\$) { |
25 |
|
|
if (\@_ > 1) { |
26 |
|
|
require Carp; |
27 |
|
|
Carp::croak (qq<Can't modify read-only attribute>); |
28 |
|
|
} |
29 |
|
|
return \${\$_[0]}->{$method_name}; |
30 |
|
|
} |
31 |
|
|
}; |
32 |
|
|
goto &{ $AUTOLOAD }; |
33 |
|
|
} elsif ({ |
34 |
|
|
## Read-write attributes (DOMString, trivial accessors) |
35 |
|
|
public_id => 1, |
36 |
|
|
system_id => 1, |
37 |
|
|
}->{$method_name}) { |
38 |
|
|
no strict 'refs'; |
39 |
|
|
eval qq{ |
40 |
wakaba |
1.5 |
sub $method_name (\$;\$) { |
41 |
wakaba |
1.1 |
if (\@_ > 1) { |
42 |
wakaba |
1.5 |
if (\${\$_[0]}->{strict_error_checking} and |
43 |
|
|
\${\$_[0]}->{manakai_read_only}) { |
44 |
|
|
report Message::DOM::DOMException |
45 |
|
|
-object => \$_[0], |
46 |
|
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
47 |
|
|
-subtype => 'READ_ONLY_NODE_ERR'; |
48 |
|
|
} |
49 |
|
|
if (defined \$_[1]) { |
50 |
|
|
\${\$_[0]}->{$method_name} = ''.\$_[1]; |
51 |
|
|
} else { |
52 |
|
|
delete \${\$_[0]}->{$method_name}; |
53 |
|
|
} |
54 |
wakaba |
1.1 |
} |
55 |
wakaba |
1.5 |
return \${\$_[0]}->{$method_name}; |
56 |
wakaba |
1.1 |
} |
57 |
|
|
}; |
58 |
|
|
goto &{ $AUTOLOAD }; |
59 |
|
|
} else { |
60 |
|
|
require Carp; |
61 |
|
|
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
62 |
|
|
} |
63 |
|
|
} # AUTOLOAD |
64 |
|
|
|
65 |
wakaba |
1.5 |
## |Node| attributes |
66 |
wakaba |
1.1 |
|
67 |
wakaba |
1.3 |
sub child_nodes ($) { |
68 |
|
|
require Message::DOM::NodeList; |
69 |
|
|
return bless \\($_[0]), 'Message::DOM::NodeList::EmptyNodeList'; |
70 |
|
|
} # child_nodes |
71 |
wakaba |
1.2 |
|
72 |
|
|
sub node_name ($); # read-only trivial accessor |
73 |
|
|
|
74 |
wakaba |
1.3 |
sub node_type () { 12 } # NOTATION_NODE |
75 |
wakaba |
1.1 |
|
76 |
wakaba |
1.5 |
sub text_content () { undef } |
77 |
|
|
|
78 |
|
|
## |Node| methods |
79 |
|
|
|
80 |
|
|
sub manakai_append_text () { } |
81 |
|
|
|
82 |
|
|
## |Notation| attributes |
83 |
|
|
|
84 |
|
|
sub manakai_declaration_base_uri ($;$) { |
85 |
|
|
## NOTE: Same as |Notation|'s. |
86 |
|
|
|
87 |
|
|
if (@_ > 1) { |
88 |
|
|
if (${${$_[0]}->{owner_document}}->{strict_error_checking} and |
89 |
|
|
${$_[0]}->{manakai_read_only}) { |
90 |
|
|
report Message::DOM::DOMException |
91 |
|
|
-object => $_[0], |
92 |
|
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
93 |
|
|
-subtype => 'READ_ONLY_NODE_ERR'; |
94 |
|
|
} |
95 |
|
|
if (defined $_[1]) { |
96 |
|
|
${$_[0]}->{manakai_declaration_base_uri} = ''.$_[1]; |
97 |
|
|
} else { |
98 |
|
|
delete ${$_[0]}->{manakai_declaration_base_uri}; |
99 |
|
|
} |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
if (defined wantarray) { |
103 |
|
|
if (defined ${$_[0]}->{manakai_declaration_base_uri}) { |
104 |
|
|
return ${$_[0]}->{manakai_declaration_base_uri}; |
105 |
|
|
} else { |
106 |
|
|
local $Error::Depth = $Error::Depth + 1; |
107 |
|
|
return $_[0]->base_uri; |
108 |
|
|
} |
109 |
|
|
} |
110 |
|
|
} # manakai_declaration_base_uri |
111 |
|
|
|
112 |
|
|
## NOTE: Setter is a manakai extension. |
113 |
|
|
sub public_id ($;$); |
114 |
|
|
|
115 |
|
|
## NOTE: Setter is a manakai extension. |
116 |
|
|
sub system_id ($;$); |
117 |
wakaba |
1.4 |
|
118 |
wakaba |
1.1 |
package Message::IF::Notation; |
119 |
|
|
|
120 |
|
|
package Message::DOM::Document; |
121 |
|
|
|
122 |
wakaba |
1.2 |
sub create_notation ($$) { |
123 |
wakaba |
1.1 |
return Message::DOM::Notation->____new (@_[0, 1]); |
124 |
|
|
} # create_notation |
125 |
|
|
|
126 |
wakaba |
1.3 |
=head1 LICENSE |
127 |
|
|
|
128 |
|
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
129 |
|
|
|
130 |
|
|
This program is free software; you can redistribute it and/or |
131 |
|
|
modify it under the same terms as Perl itself. |
132 |
|
|
|
133 |
|
|
=cut |
134 |
|
|
|
135 |
wakaba |
1.1 |
1; |
136 |
wakaba |
1.5 |
## $Date: 2007/06/16 15:27:45 $ |