1 |
wakaba |
1.1 |
package Message::DOM::Notation; |
2 |
|
|
use strict; |
3 |
wakaba |
1.8 |
our $VERSION=do{my @r=(q$Revision: 1.7 $=~/\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.7 |
owner_document_type_definition => 1, |
22 |
wakaba |
1.1 |
}->{$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 |
|
|
public_id => 1, |
37 |
|
|
system_id => 1, |
38 |
|
|
}->{$method_name}) { |
39 |
|
|
no strict 'refs'; |
40 |
|
|
eval qq{ |
41 |
wakaba |
1.5 |
sub $method_name (\$;\$) { |
42 |
wakaba |
1.1 |
if (\@_ > 1) { |
43 |
wakaba |
1.5 |
if (\${\$_[0]}->{strict_error_checking} and |
44 |
|
|
\${\$_[0]}->{manakai_read_only}) { |
45 |
|
|
report Message::DOM::DOMException |
46 |
|
|
-object => \$_[0], |
47 |
|
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
48 |
|
|
-subtype => 'READ_ONLY_NODE_ERR'; |
49 |
|
|
} |
50 |
|
|
if (defined \$_[1]) { |
51 |
|
|
\${\$_[0]}->{$method_name} = ''.\$_[1]; |
52 |
|
|
} else { |
53 |
|
|
delete \${\$_[0]}->{$method_name}; |
54 |
|
|
} |
55 |
wakaba |
1.1 |
} |
56 |
wakaba |
1.5 |
return \${\$_[0]}->{$method_name}; |
57 |
wakaba |
1.1 |
} |
58 |
|
|
}; |
59 |
|
|
goto &{ $AUTOLOAD }; |
60 |
|
|
} else { |
61 |
|
|
require Carp; |
62 |
|
|
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
63 |
|
|
} |
64 |
|
|
} # AUTOLOAD |
65 |
|
|
|
66 |
wakaba |
1.5 |
## |Node| attributes |
67 |
wakaba |
1.1 |
|
68 |
wakaba |
1.3 |
sub child_nodes ($) { |
69 |
|
|
require Message::DOM::NodeList; |
70 |
|
|
return bless \\($_[0]), 'Message::DOM::NodeList::EmptyNodeList'; |
71 |
|
|
} # child_nodes |
72 |
wakaba |
1.2 |
|
73 |
|
|
sub node_name ($); # read-only trivial accessor |
74 |
|
|
|
75 |
wakaba |
1.3 |
sub node_type () { 12 } # NOTATION_NODE |
76 |
wakaba |
1.1 |
|
77 |
wakaba |
1.5 |
sub text_content () { undef } |
78 |
|
|
|
79 |
|
|
## |Node| methods |
80 |
|
|
|
81 |
wakaba |
1.6 |
sub append_child ($$) { |
82 |
|
|
report Message::DOM::DOMException |
83 |
|
|
-object => $_[0], |
84 |
|
|
-type => 'HIERARCHY_REQUEST_ERR', |
85 |
|
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
86 |
|
|
} # append_child |
87 |
|
|
|
88 |
wakaba |
1.5 |
sub manakai_append_text () { } |
89 |
|
|
|
90 |
wakaba |
1.6 |
sub insert_before ($;$) { |
91 |
|
|
report Message::DOM::DOMException |
92 |
|
|
-object => $_[0], |
93 |
|
|
-type => 'HIERARCHY_REQUEST_ERR', |
94 |
|
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
95 |
|
|
} # insert_before |
96 |
|
|
|
97 |
|
|
sub replace_child ($$) { |
98 |
|
|
report Message::DOM::DOMException |
99 |
|
|
-object => $_[0], |
100 |
|
|
-type => 'HIERARCHY_REQUEST_ERR', |
101 |
|
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
102 |
|
|
} # replace_child |
103 |
|
|
|
104 |
wakaba |
1.5 |
## |Notation| attributes |
105 |
|
|
|
106 |
|
|
sub manakai_declaration_base_uri ($;$) { |
107 |
|
|
## NOTE: Same as |Notation|'s. |
108 |
|
|
|
109 |
|
|
if (@_ > 1) { |
110 |
|
|
if (${${$_[0]}->{owner_document}}->{strict_error_checking} and |
111 |
|
|
${$_[0]}->{manakai_read_only}) { |
112 |
|
|
report Message::DOM::DOMException |
113 |
|
|
-object => $_[0], |
114 |
|
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
115 |
|
|
-subtype => 'READ_ONLY_NODE_ERR'; |
116 |
|
|
} |
117 |
|
|
if (defined $_[1]) { |
118 |
|
|
${$_[0]}->{manakai_declaration_base_uri} = ''.$_[1]; |
119 |
|
|
} else { |
120 |
|
|
delete ${$_[0]}->{manakai_declaration_base_uri}; |
121 |
|
|
} |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
if (defined wantarray) { |
125 |
|
|
if (defined ${$_[0]}->{manakai_declaration_base_uri}) { |
126 |
|
|
return ${$_[0]}->{manakai_declaration_base_uri}; |
127 |
|
|
} else { |
128 |
|
|
local $Error::Depth = $Error::Depth + 1; |
129 |
|
|
return $_[0]->base_uri; |
130 |
|
|
} |
131 |
|
|
} |
132 |
|
|
} # manakai_declaration_base_uri |
133 |
|
|
|
134 |
wakaba |
1.7 |
## NOTE: A manakai extension. |
135 |
|
|
sub owner_document_type_definition ($); |
136 |
|
|
|
137 |
wakaba |
1.5 |
## NOTE: Setter is a manakai extension. |
138 |
|
|
sub public_id ($;$); |
139 |
|
|
|
140 |
|
|
## NOTE: Setter is a manakai extension. |
141 |
|
|
sub system_id ($;$); |
142 |
wakaba |
1.4 |
|
143 |
wakaba |
1.1 |
package Message::IF::Notation; |
144 |
|
|
|
145 |
|
|
package Message::DOM::Document; |
146 |
|
|
|
147 |
wakaba |
1.2 |
sub create_notation ($$) { |
148 |
wakaba |
1.8 |
if (${$_[0]}->{strict_error_checking}) { |
149 |
|
|
my $xv = $_[0]->xml_version; |
150 |
|
|
if (defined $xv) { |
151 |
|
|
if ($xv eq '1.0' and |
152 |
|
|
$_[1] =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) { |
153 |
|
|
# |
154 |
|
|
} elsif ($xv eq '1.1' and |
155 |
|
|
$_[1] =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) { |
156 |
|
|
# |
157 |
|
|
} else { |
158 |
|
|
report Message::DOM::DOMException |
159 |
|
|
-object => $_[0], |
160 |
|
|
-type => 'INVALID_CHARACTER_ERR', |
161 |
|
|
-subtype => 'MALFORMED_NAME_ERR'; |
162 |
|
|
} |
163 |
|
|
} |
164 |
|
|
} |
165 |
|
|
|
166 |
wakaba |
1.1 |
return Message::DOM::Notation->____new (@_[0, 1]); |
167 |
|
|
} # create_notation |
168 |
|
|
|
169 |
wakaba |
1.3 |
=head1 LICENSE |
170 |
|
|
|
171 |
|
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
172 |
|
|
|
173 |
|
|
This program is free software; you can redistribute it and/or |
174 |
|
|
modify it under the same terms as Perl itself. |
175 |
|
|
|
176 |
|
|
=cut |
177 |
|
|
|
178 |
wakaba |
1.1 |
1; |
179 |
wakaba |
1.8 |
## $Date: 2007/07/12 13:54:46 $ |