/[suikacvs]/messaging/manakai/lib/Message/DOM/Entity.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/Entity.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Sat Jul 14 16:32:28 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
CVS Tags: manakai-release-0-4-0
Changes since 1.8: +2 -6 lines
++ manakai/t/ChangeLog	14 Jul 2007 16:32:13 -0000
2007-07-15  Wakaba  <wakaba@suika.fam.cx>

	* DOM-TreeWalker.t, DOM-SerialWalker.t: New test scripts.

	* DOM-DOMImplementation.t: Tests for |Traversal| feature
	are added.

	* DOM-Node.t: Tests for |Traversal| feature are added.

++ manakai/lib/Message/DOM/ChangeLog	14 Jul 2007 16:31:23 -0000
2007-07-15  Wakaba  <wakaba@suika.fam.cx>

	* TreeWalker.pm, SerialWalker.pm: New Perl modules.

	* Text.pm (whole_text): Parameter index number has
	been changed to support new |NodeFilter| Perl binding
	definition.

2007-07-14  Wakaba  <wakaba@suika.fam.cx>

	* AttributeDefinition.pm, DOMElement.pm, DocumentType.pm,
	ElementTypeDefinition.pm, Entity.pm, EntityReference.pm,
	Notation.pm, ProcessingInstruction.pm (AUTOLOAD): Don't croak even if an attempt is made to modify a read-only attribute.

	* DOMConfiguration.pm (can_set_parameter,
	set_parameter): Don't allow to set the value
	to a string other than <http://www.w3.org/TR/REC-xml> (XML 1.0 DTD).

	* DOMDocument.pm (Message::IF::DocumentTraversal): New interface.
	(create_tree_walker, manakai_create_serial_walker): References
	and prototypes are added.

	* DOMException.pm (NULLPO_ERR): New error type:-).

	* DOMImplementation.pm ($HasFeature): Feature |Traversal|,
	version |2.0|, is added.

1 wakaba 1.2 package Message::DOM::Entity;
2 wakaba 1.1 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.2 push our @ISA, 'Message::DOM::Node', 'Message::IF::Entity';
5 wakaba 1.1 require Message::DOM::Node;
6    
7     sub ____new ($$$) {
8     my $self = shift->SUPER::____new (shift);
9     $$self->{node_name} = $_[0];
10 wakaba 1.3 $$self->{child_nodes} = [];
11 wakaba 1.1 return $self;
12     } # ____new
13    
14     sub AUTOLOAD {
15     my $method_name = our $AUTOLOAD;
16     $method_name =~ s/.*:://;
17     return if $method_name eq 'DESTROY';
18    
19     if ({
20     ## Read-only attributes (trivial accessors)
21 wakaba 1.2 node_name => 1,
22 wakaba 1.7 owner_document_type_definition => 1,
23 wakaba 1.1 }->{$method_name}) {
24     no strict 'refs';
25     eval qq{
26     sub $method_name (\$) {
27     return \${\$_[0]}->{$method_name};
28     }
29     };
30     goto &{ $AUTOLOAD };
31     } elsif ({
32 wakaba 1.4 ## Read-write attributes (boolean, trivial accessors)
33     has_replacement_tree => 1,
34 wakaba 1.6 is_externally_declared => 1,
35 wakaba 1.4 }->{$method_name}) {
36     no strict 'refs';
37     eval qq{
38     sub $method_name (\$;\$) {
39     if (\@_ > 1) {
40     if (\${\${\$_[0]}->{owner_document}}->{manakai_strict_error_checking} and
41     \${\$_[0]}->{manakai_read_only}) {
42     report Message::DOM::DOMException
43     -object => \$_[0],
44     -type => 'NO_MODIFICATION_ALLOWED_ERR',
45     -subtype => 'READ_ONLY_NODE_ERR';
46     }
47     if (\$_[1]) {
48     \${\$_[0]}->{$method_name} = 1;
49     } else {
50     delete \${\$_[0]}->{$method_name};
51     }
52     }
53     return \${\$_[0]}->{$method_name};
54     }
55     };
56     goto &{ $AUTOLOAD };
57     } elsif ({
58 wakaba 1.1 ## Read-write attributes (DOMString, trivial accessors)
59 wakaba 1.6 input_encoding => 1,
60 wakaba 1.5 notation_name => 1,
61 wakaba 1.1 public_id => 1,
62     system_id => 1,
63 wakaba 1.5 xml_encoding => 1,
64 wakaba 1.6 xml_version => 1,
65 wakaba 1.1 }->{$method_name}) {
66     no strict 'refs';
67     eval qq{
68 wakaba 1.4 sub $method_name (\$;\$) {
69 wakaba 1.1 if (\@_ > 1) {
70 wakaba 1.4 if (\${\$_[0]}->{strict_error_checking} and
71     \${\$_[0]}->{manakai_read_only}) {
72     report Message::DOM::DOMException
73     -object => \$_[0],
74     -type => 'NO_MODIFICATION_ALLOWED_ERR',
75     -subtype => 'READ_ONLY_NODE_ERR';
76     }
77     if (defined \$_[1]) {
78     \${\$_[0]}->{$method_name} = ''.\$_[1];
79     } else {
80     delete \${\$_[0]}->{$method_name};
81     }
82 wakaba 1.1 }
83 wakaba 1.4 return \${\$_[0]}->{$method_name};
84 wakaba 1.1 }
85     };
86     goto &{ $AUTOLOAD };
87     } else {
88     require Carp;
89     Carp::croak (qq<Can't locate method "$AUTOLOAD">);
90     }
91     } # AUTOLOAD
92    
93 wakaba 1.4 ## |Node| attributes
94    
95     sub node_name ($); # read-only trivial accessor
96    
97     sub node_type () { 6 } # ENTITY_NODE
98    
99     ## |Entity| attributes
100    
101     sub manakai_declaration_base_uri ($;$) {
102     ## NOTE: Same as |Notation|'s.
103    
104     if (@_ > 1) {
105     if (${${$_[0]}->{owner_document}}->{strict_error_checking} and
106     ${$_[0]}->{manakai_read_only}) {
107     report Message::DOM::DOMException
108     -object => $_[0],
109     -type => 'NO_MODIFICATION_ALLOWED_ERR',
110     -subtype => 'READ_ONLY_NODE_ERR';
111     }
112     if (defined $_[1]) {
113     ${$_[0]}->{manakai_declaration_base_uri} = ''.$_[1];
114     } else {
115     delete ${$_[0]}->{manakai_declaration_base_uri};
116     }
117     }
118    
119     if (defined wantarray) {
120     if (defined ${$_[0]}->{manakai_declaration_base_uri}) {
121     return ${$_[0]}->{manakai_declaration_base_uri};
122     } else {
123     local $Error::Depth = $Error::Depth + 1;
124     return $_[0]->base_uri;
125     }
126     }
127     } # manakai_declaration_base_uri
128    
129     sub manakai_entity_base_uri ($;$) {
130     my $self = $_[0];
131     if (@_ > 1) {
132     if (${$$self->{owner_document}}->{strict_error_checking}) {
133     if ($$self->{manakai_read_only}) {
134     report Message::DOM::DOMException
135     -object => $self,
136     -type => 'NO_MODIFICATION_ALLOWED_ERR',
137     -subtype => 'READ_ONLY_NODE_ERR';
138     }
139     }
140     if (defined $_[1]) {
141     $$self->{manakai_entity_base_uri} = ''.$_[1];
142     } else {
143     delete $$self->{manakai_entity_base_uri};
144     }
145     }
146    
147     if (defined wantarray) {
148     if (defined $$self->{manakai_entity_base_uri}) {
149     return $$self->{manakai_entity_base_uri};
150     } else {
151     local $Error::Depth = $Error::Depth + 1;
152     my $v = $self->manakai_entity_uri;
153     return $v if defined $v;
154     return $self->base_uri;
155     }
156     }
157     } # manakai_entity_base_uri
158    
159     sub manakai_entity_uri ($;$) {
160     my $self = $_[0];
161     if (@_ > 1) {
162     if (${$$self->{owner_document}}->{strict_error_checking}) {
163     if ($$self->{manakai_read_only}) {
164     report Message::DOM::DOMException
165     -object => $self,
166     -type => 'NO_MODIFICATION_ALLOWED_ERR',
167     -subtype => 'READ_ONLY_NODE_ERR';
168     }
169     }
170     if (defined $_[1]) {
171     $$self->{manakai_entity_uri} = ''.$_[1];
172     } else {
173     delete $$self->{manakai_entity_uri};
174     }
175     }
176 wakaba 1.1
177 wakaba 1.4 if (defined wantarray) {
178     return $$self->{manakai_entity_uri} if defined $$self->{manakai_entity_uri};
179 wakaba 1.2
180 wakaba 1.4 local $Error::Depth = $Error::Depth + 1;
181     my $v = $$self->{system_id};
182     if (defined $v) {
183     $v = ${$$self->{owner_document}}->{implementation}->create_uri_reference
184     ($v);
185     if (not defined $v->uri_scheme) {
186     my $base = $self->manakai_declaration_base_uri;
187     return $v->get_absolute_reference ($base)->uri_reference
188     if defined $base;
189     }
190     return $v->uri_reference;
191     } else {
192     return undef;
193     }
194     }
195     } # manakai_entity_uri
196    
197     ## NOTE: Setter is a manakai extension.
198 wakaba 1.6 ## TODO: Document it.
199     sub input_encoding ($;$);
200    
201     ## NOTE: Setter is a manakai extension.
202     ## TODO: Document it.
203     sub is_externally_declared ($;$);
204     # @@enDesc:
205     # Whether the entity is declared by an external markup declaration,
206     # i.e. a markup declaration occuring in the external subset or
207     # in a parameter entity.
208     # @@Type: boolean
209     # @@TrueCase:
210     # @@@enDesc:
211     # If the entity is declared by an external markup declaration.
212     # @@FalseCase:
213     # @@@enDesc:
214     # If the entity is declared by a markup declaration in
215     # the internal subset, or if the <IF::Entity> node
216     # is created in memory.
217    
218     ## NOTE: Setter is a manakai extension.
219 wakaba 1.5 sub notation_name ($;$);
220    
221 wakaba 1.7 ## NOTE: A manakai extension.
222     sub owner_document_type_definition ($);
223    
224 wakaba 1.5 ## NOTE: Setter is a manakai extension.
225 wakaba 1.4 sub public_id ($;$);
226    
227     ## NOTE: Setter is a manakai extension.
228     sub system_id ($;$);
229 wakaba 1.2
230 wakaba 1.5 ## NOTE: Setter is a manakai extension.
231     sub xml_encoding ($;$);
232    
233 wakaba 1.6 ## NOTE: Setter is a manakai extension.
234     ## TODO: Document it. ## TODO: e.g. xml_version = '3.7'
235     ## TODO: Spec does not mention |null| case
236     ## TODO: Should we provide default?
237     sub xml_version ($;$);
238    
239 wakaba 1.4 ## |Entity| methods
240 wakaba 1.2
241 wakaba 1.4 ## NOTE: A manakai extension
242     sub has_replacement_tree ($;$);
243 wakaba 1.1
244     package Message::IF::Entity;
245    
246     package Message::DOM::Document;
247    
248 wakaba 1.2 sub create_general_entity ($$) {
249 wakaba 1.8 if (${$_[0]}->{strict_error_checking}) {
250     my $xv = $_[0]->xml_version;
251     if (defined $xv) {
252     if ($xv eq '1.0' and
253     $_[1] =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) {
254     #
255     } elsif ($xv eq '1.1' and
256     $_[1] =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) {
257     #
258     } else {
259     report Message::DOM::DOMException
260     -object => $_[0],
261     -type => 'INVALID_CHARACTER_ERR',
262     -subtype => 'MALFORMED_NAME_ERR';
263     }
264     }
265     }
266    
267 wakaba 1.1 return Message::DOM::Entity->____new (@_[0, 1]);
268     } # create_general_entity
269    
270 wakaba 1.4 =head1 LICENSE
271    
272     Copyright 2007 Wakaba <w@suika.fam.cx>
273    
274     This program is free software; you can redistribute it and/or
275     modify it under the same terms as Perl itself.
276    
277     =cut
278    
279 wakaba 1.1 1;
280 wakaba 1.9 ## $Date: 2007/07/14 09:19:11 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24