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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Sun Jun 17 13:37:40 2007 UTC (17 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +81 -19 lines
++ manakai/t/ChangeLog	17 Jun 2007 13:37:22 -0000
2007-06-17  Wakaba  <wakaba@suika.fam.cx>

	* DOM-Attr.t, DOM-AttributeDefinition.t, DOM-DocumentType.t,
	DOM-Element.t, DOM-Entity.t, DOM-EntityReference.t,
	DOM-Notation.t, DOM-ProcessingInstruction.t: New.

	* DOM-Document.t, DOM-Node.t: Tests for newly-implemented attributes
	and methods are added.

	* Makefile (test-module-dom-old): Renamed from |test-module-dom|.
	(test-module-dom): New.

++ manakai/lib/Message/DOM/ChangeLog	17 Jun 2007 13:34:54 -0000
2007-06-17  Wakaba  <wakaba@suika.fam.cx>

	* Attr.pm (____new): Initialize |specified| as 1.
	(base_uri, manakai_attribute_type, specified): Implemented.
	(prefix): Don't check read-only flag unless |strict_error_checking|.
	(value): Call |text_content| for now.

	* AttributeDefinition.pm (DeclaredValueType, DefaultValueType): Added.
	(declared_type, default_type): Implemented.

	* CharacterData.pm (____new): Allow a scalar reference
	as an input for the |data| attribute.
	(base_uri, manakai_append_text): Implemented.

	* DOMConfiguration.pm (set_parameter): Resetting implemented.

	* DOMDocument.pm (____new): Set default values to
	configuration parameter whose default is true.
	(document_uri, input_encoding): Implemented.
	(all_declarations_processed, manakai_is_html): Implemented.
	(base_uri, manakai_append_text,
	manakai_entity_base_uri, strict_error_checking,
	xml_encoding, xml_version, xml_standalone): Implemented.

	* DOMElement.pm (manakai_base_uri, base_uri): Implemented.
	(get_attribute, get_attribute_node): Alpha version.
	(set_attribute_node, set_attribute_node_ns): Implemented.
	(set_attribute_ns): Accept non-ARRAY qualified name.

	* DOMException.pm (___error_def): |WRONG_DOCUMENT_ERR|,
	|NOT_SUPPORTED_ERR|, and |INUSE_ATTRIBUTE_ERR| are added.

	* DocumentType.pm (public_id, system_id): Implemented.
	(base_uri, declaration_base_uri, manakai_declaration_base_uri,
	manakai_append_text): Implemented.
	(element_types, general_entities, notations,
	set_element_type_definition_node, set_general_entity_node,
	set_notation_node): Alpha version.

	* ElementTypeDefinition.pm (manakai_append_text): Implemented.
	(attribute_definitions, set_attribute_definition_node): Alpha version.

	* Entity.pm (has_replacement_tree, public_id, system_id,
	manakai_declaration_base_uri, manakai_entity_base_uri,
	manakai_entity_uri): Implemented.

	* EntityReference.pm (manakai_expanded, manakai_external): Implemented.
	(base_uri, manakai_entity_base_uri): Implemented.

	* Node.pm (base_uri): Implemented.
	(text_content): Don't check read-only or not
	unless |strict_error_checking|.
	(manakai_append_text): Implemented.
	(get_feature): Alpha.
	(manakai_set_read_only): Implemented.

	* Notation.pm (public_id, system_id, manakai_append_text,
	manakai_declaration_base_uri): Implemented.

	* ProcessingInstruction.pm (manakai_base_uri,
	base_uri, manakai_append_text): Implemented.

1 package Message::DOM::EntityReference;
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::EntityReference';
5 require Message::DOM::Node;
6
7 ## Spec:
8 ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-11C98490>
9
10 sub ____new ($$$) {
11 my $self = shift->SUPER::____new (shift);
12 $$self->{node_name} = $_[0];
13 $$self->{child_nodes} = [];
14 return $self;
15 } # ____new
16
17 sub AUTOLOAD {
18 my $method_name = our $AUTOLOAD;
19 $method_name =~ s/.*:://;
20 return if $method_name eq 'DESTROY';
21
22 if ({
23 ## Read-only attributes (trivial accessors)
24 node_name => 1,
25 }->{$method_name}) {
26 no strict 'refs';
27 eval qq{
28 sub $method_name (\$) {
29 if (\@_ > 1) {
30 require Carp;
31 Carp::croak (qq<Can't modify read-only attribute>);
32 }
33 return \${\$_[0]}->{$method_name};
34 }
35 };
36 goto &{ $AUTOLOAD };
37 } elsif ({
38 ## Read-write attributes (boolean, trivial accessors)
39 manakai_expanded => 1,
40 manakai_external => 1,
41 }->{$method_name}) {
42 no strict 'refs';
43 eval qq{
44 sub $method_name (\$;\$) {
45 if (\@_ > 1) {
46 if (\${\${\$_[0]}->{owner_document}}->{manakai_strict_error_checking} and
47 \${\$_[0]}->{manakai_read_only}) {
48 report Message::DOM::DOMException
49 -object => \$_[0],
50 -type => 'NO_MODIFICATION_ALLOWED_ERR',
51 -subtype => 'READ_ONLY_NODE_ERR';
52 }
53 if (\$_[1]) {
54 \${\$_[0]}->{$method_name} = 1;
55 } else {
56 delete \${\$_[0]}->{$method_name};
57 }
58 }
59 return \${\$_[0]}->{$method_name};
60 }
61 };
62 goto &{ $AUTOLOAD };
63 } else {
64 require Carp;
65 Carp::croak (qq<Can't locate method "$AUTOLOAD">);
66 }
67 } # AUTOLOAD
68
69 ## |Node| attributes
70
71 sub base_uri ($) {
72 ## NOTE: Same as |CharacterData|'s.
73
74 my $self = $_[0];
75 local $Error::Depth = $Error::Depth + 1;
76 my $pe = $$self->{parent_node};
77 while (defined $pe) {
78 my $nt = $pe->node_type;
79 if ($nt == 1 or $nt == 2 or $nt == 6 or $nt == 9 or $nt == 11) {
80 ## Element, Attr, Entity, Document, or DocumentFragment
81 return $pe->base_uri;
82 } elsif ($nt == 5) {
83 ## EntityReference
84 return $pe->manakai_entity_base_uri if $pe->manakai_external;
85 }
86 $pe = $$pe->{parent_node};
87 }
88 return $pe->base_uri if $pe;
89 return $$self->{owner_document}->base_uri;
90 } # base_uri
91
92 sub node_name ($); # read-only trivial accessor
93
94 sub node_type () { 5 } # ENTITY_REFERENCE_NODE
95
96 ## |EntityReference| attributes
97
98 sub manakai_entity_base_uri ($;$) {
99 my $self = $_[0];
100 if (@_ > 1) {
101 if (${$$self->{owner_document}}->{strict_error_checking}) {
102 if ($$self->{manakai_read_only}) {
103 report Message::DOM::DOMException
104 -object => $self,
105 -type => 'NO_MODIFICATION_ALLOWED_ERR',
106 -subtype => 'READ_ONLY_NODE_ERR';
107 }
108 }
109 if (defined $_[1]) {
110 $$self->{manakai_entity_base_uri} = ''.$_[1];
111 } else {
112 delete $$self->{manakai_entity_base_uri};
113 }
114 }
115
116 if (defined $$self->{manakai_entity_base_uri}) {
117 return $$self->{manakai_entity_base_uri};
118 } else {
119 local $Error::Depth = $Error::Depth + 1;
120 return $self->base_uri;
121 }
122 } # manakai_entity_base_uri
123
124 sub manakai_expanded ($;$);
125
126 sub manakai_external ($;$);
127
128 package Message::IF::EntityReference;
129
130 package Message::DOM::Document;
131
132 sub create_entity_reference ($$) {
133 return Message::DOM::EntityReference->____new (@_[0, 1]);
134 } # create_entity_reference
135
136 =head1 LICENSE
137
138 Copyright 2007 Wakaba <w@suika.fam.cx>
139
140 This program is free software; you can redistribute it and/or
141 modify it under the same terms as Perl itself.
142
143 =cut
144
145 1;
146 ## $Date: 2007/06/16 15:27:45 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24