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