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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Sun Jun 17 13:37:40 2007 UTC (17 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +69 -5 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 wakaba 1.1 package Message::DOM::AttributeDefinition;
2     use strict;
3 wakaba 1.4 our $VERSION=do{my @r=(q$Revision: 1.3 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 wakaba 1.1 push our @ISA, 'Message::DOM::Node', 'Message::IF::AttributeDefinition';
5     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.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     }->{$method_name}) {
37     no strict 'refs';
38     eval qq{
39     sub $method_name (\$) {
40     if (\@_ > 1) {
41     \${\$_[0]}->{$method_name} = ''.$_[1];
42     }
43     return \${\$_[0]}->{$method_name};
44     }
45     };
46     goto &{ $AUTOLOAD };
47     } else {
48     require Carp;
49     Carp::croak (qq<Can't locate method "$AUTOLOAD">);
50     }
51     } # AUTOLOAD
52    
53 wakaba 1.4 ## |AttributeDefinition| constants
54    
55     ## |DeclaredValueType|
56     sub NO_TYPE_ATTR () { 0 }
57     sub CDATA_ATTR () { 1 }
58     sub ID_ATTR () { 2 }
59     sub IDREF_ATTR () { 3 }
60     sub IDREFS_ATTR () { 4 }
61     sub ENTITY_ATTR () { 5 }
62     sub ENTITIES_ATTR () { 6 }
63     sub NMTOKEN_ATTR () { 7 }
64     sub NMTOKENS_ATTR () { 8 }
65     sub NOTATION_ATTR () { 9 }
66     sub ENUMERATION_ATTR () { 10 }
67     sub UNKNOWN_ATTR () { 11 }
68    
69     ## |DefaultValueType|
70     sub UNKNOWN_DEFAULT () { 0 }
71     sub FIXED_DEFAULT () { 1 }
72     sub REQUIRED_DEFAULT () { 2 }
73     sub IMPLIED_DEFAULT () { 3 }
74     sub EXPLICIT_DEFAULT () { 4 }
75    
76 wakaba 1.1 ## The |Node| interface - attribute
77    
78 wakaba 1.2 ## Spec:
79     ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D095>
80     ## <http://suika.fam.cx/gate/2005/sw/AttributeDefinition>
81    
82     sub node_name ($); # read-only trivial accessor
83    
84     ## Spec:
85     ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-111237558>
86    
87     sub node_type ($) { 81002 } # ATTRIBUTE_DEFINITION_NODE
88    
89     ## Spec:
90     ## <http://suika.fam.cx/gate/2005/sw/AttributeDefinition#anchor-2>
91    
92     ## TODO: node_value
93 wakaba 1.1
94 wakaba 1.4 ## |AttributeDefinition| attributes
95    
96     sub declared_type ($;$) {
97     my $self = $_[0];
98     if (@_ > 1) {
99     if (${$$self->{owner_document}}->{strict_error_checking}) {
100     if ($$self->{manakai_read_only}) {
101     report Message::DOM::DOMException
102     -object => $self,
103     -type => 'NO_MODIFICATION_ALLOWED_ERR',
104     -subtype => 'READ_ONLY_NODE_ERR';
105     }
106     }
107     if ($_[1]) {
108     $$self->{declared_type} = 0+$_[1];
109     } else {
110     delete $$self->{declared_type};
111     }
112     }
113    
114     return $$self->{declared_type} || 0;
115     } # declared_type
116    
117     sub default_type ($;$) {
118     my $self = $_[0];
119     if (@_ > 1) {
120     if (${$$self->{owner_document}}->{strict_error_checking}) {
121     if ($$self->{manakai_read_only}) {
122     report Message::DOM::DOMException
123     -object => $self,
124     -type => 'NO_MODIFICATION_ALLOWED_ERR',
125     -subtype => 'READ_ONLY_NODE_ERR';
126     }
127     }
128     if ($_[1]) {
129     $$self->{default_type} = 0+$_[1];
130     } else {
131     delete $$self->{default_type};
132     }
133     }
134    
135     return $$self->{default_type} || 0;
136     } # default_type
137    
138 wakaba 1.1 package Message::IF::AttributeDefinition;
139    
140     package Message::DOM::Document;
141    
142     ## Spec:
143     ## <http://suika.fam.cx/gate/2005/sw/DocumentXDoctype>
144    
145 wakaba 1.2 sub create_attribute_definition ($$) {
146 wakaba 1.1 return Message::DOM::AttributeDefinition->____new (@_[0, 1]);
147     } # create_attribute_definition
148    
149     1;
150     ## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL>
151 wakaba 1.4 ## $Date: 2007/06/16 08:05:48 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24