/[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.11 - (show annotations) (download)
Sat Jul 14 09:19:11 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.10: +23 -15 lines
++ manakai/t/ChangeLog	14 Jul 2007 09:19:01 -0000
	* DOM-Node.t: Test data for new constants and attributes
	are added.

	* DOM-TypeInfo.t: Tests for constants are added.

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

++ manakai/lib/Message/DOM/ChangeLog	14 Jul 2007 09:17:51 -0000
	* AttributeDefinition.pm (node_value): Implemented.
	(create_attribute_definition): Implemented.

	* DOMConfiguration.pm (%{}, TIEHASH,
	get_parameter, set_parameter, can_set_parameter,
	EXISTS, DELETE, parameter_names, FETCH, STORE,
	FIRSTKEY, LASTKEY): Implemented.

	* DOMDocument.pm (____new): Set |error-handler| default.
	(get_elements_by_tag_name, get_elements_by_tag_name_ns): Implemented.

	* DOMElement.pm (get_elements_by_tag_name, get_elements_by_tag_name_ns):
	Implemented.

	* DOMException.pm: Error types for |DOMConfiguration|
	are added.

	* DOMStringList.pm (Message::DOM::DOMStringList::StaticList): New
	class.

	* DocumentType.pm (get_element_type_definition_node,
	get_general_entity_node, get_notation_node,
	set_element_type_definition_node, set_general_entity_node,
	set_notation_node, create_document_type_definition): Implemented.

	* ElementTypeDefinition.pm (get_attribute_definition_node,
	set_attribute_definition_node, create_element_type_definition):
	Implemented.

	* Entity.pm (create_general_entity): Implemented.

	* Node.pm: Constants in |OperationType| definition
	group are added.
	(manakai_language): Implemented.

	* NodeList.pm (Message::DOM::NodeList::GetElementsList): New
	class.

	* Notation.pm (create_notation): Implemented.

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

1 package Message::DOM::AttributeDefinition;
2 use strict;
3 our $VERSION=do{my @r=(q$Revision: 1.10 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 push our @ISA, 'Message::DOM::Node', 'Message::IF::AttributeDefinition';
5 require Message::DOM::Node;
6 require Message::DOM::Attr;
7
8 sub ____new ($$$) {
9 my $self = shift->SUPER::____new (shift);
10 $$self->{node_name} = $_[0];
11 $$self->{child_nodes} = [];
12 $$self->{allowed_tokens} = [];
13 return $self;
14 } # ____new
15
16 sub AUTOLOAD {
17 my $method_name = our $AUTOLOAD;
18 $method_name =~ s/.*:://;
19 return if $method_name eq 'DESTROY';
20
21 if ({
22 ## Read-only attributes (trivial accessors)
23 node_name => 1,
24 owner_element_type_definition => 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 } else {
38 require Carp;
39 Carp::croak (qq<Can't locate method "$AUTOLOAD">);
40 }
41 } # AUTOLOAD
42
43 ## |AttributeDefinition| constants
44
45 ## |DeclaredValueType|
46 sub NO_TYPE_ATTR () { 0 }
47 sub CDATA_ATTR () { 1 }
48 sub ID_ATTR () { 2 }
49 sub IDREF_ATTR () { 3 }
50 sub IDREFS_ATTR () { 4 }
51 sub ENTITY_ATTR () { 5 }
52 sub ENTITIES_ATTR () { 6 }
53 sub NMTOKEN_ATTR () { 7 }
54 sub NMTOKENS_ATTR () { 8 }
55 sub NOTATION_ATTR () { 9 }
56 sub ENUMERATION_ATTR () { 10 }
57 sub UNKNOWN_ATTR () { 11 }
58
59 ## |DefaultValueType|
60 sub UNKNOWN_DEFAULT () { 0 }
61 sub FIXED_DEFAULT () { 1 }
62 sub REQUIRED_DEFAULT () { 2 }
63 sub IMPLIED_DEFAULT () { 3 }
64 sub EXPLICIT_DEFAULT () { 4 }
65
66 ## |Node| attributes
67
68 sub node_name ($); # read-only trivial accessor
69
70 sub node_type () { 81002 } # ATTRIBUTE_DEFINITION_NODE
71
72 *node_value = \&Message::DOM::Node::text_content;
73
74 ## |Node| methods
75
76 *append_child = \&Message::DOM::Attr::append_child;
77
78 *insert_before = \&Message::DOM::Attr::insert_before;
79
80 *replace_child = \&Message::DOM::Attr::replace_child;
81
82 ## |AttributeDefinition| attributes
83
84 sub allowed_tokens ($) {
85 require Message::DOM::DOMStringList;
86 return bless \[$_[0], 'allowed_tokens'], 'Message::DOM::DOMStringList';
87 } # allowed_tokens
88
89 sub declared_type ($;$) {
90 my $self = $_[0];
91 if (@_ > 1) {
92 if (${$$self->{owner_document}}->{strict_error_checking}) {
93 if ($$self->{manakai_read_only}) {
94 report Message::DOM::DOMException
95 -object => $self,
96 -type => 'NO_MODIFICATION_ALLOWED_ERR',
97 -subtype => 'READ_ONLY_NODE_ERR';
98 }
99 }
100 if ($_[1]) {
101 $$self->{declared_type} = 0+$_[1];
102 } else {
103 delete $$self->{declared_type};
104 }
105 }
106
107 return $$self->{declared_type} || 0;
108 } # declared_type
109
110 sub default_type ($;$) {
111 my $self = $_[0];
112 if (@_ > 1) {
113 if (${$$self->{owner_document}}->{strict_error_checking}) {
114 if ($$self->{manakai_read_only}) {
115 report Message::DOM::DOMException
116 -object => $self,
117 -type => 'NO_MODIFICATION_ALLOWED_ERR',
118 -subtype => 'READ_ONLY_NODE_ERR';
119 }
120 }
121 if ($_[1]) {
122 $$self->{default_type} = 0+$_[1];
123 } else {
124 delete $$self->{default_type};
125 }
126 }
127
128 return $$self->{default_type} || 0;
129 } # default_type
130
131 sub owner_element_type_definition ($);
132
133 package Message::IF::AttributeDefinition;
134
135 package Message::DOM::Document;
136
137 sub create_attribute_definition ($$) {
138 if (${$_[0]}->{strict_error_checking}) {
139 my $xv = $_[0]->xml_version;
140 if (defined $xv) {
141 if ($xv eq '1.0' and
142 $_[1] =~ /\A\p{InXML_NameStartChar10}\p{InXMLNameChar10}*\z/) {
143 #
144 } elsif ($xv eq '1.1' and
145 $_[1] =~ /\A\p{InXMLNameStartChar11}\p{InXMLNameChar11}*\z/) {
146 #
147 } else {
148 report Message::DOM::DOMException
149 -object => $_[0],
150 -type => 'INVALID_CHARACTER_ERR',
151 -subtype => 'MALFORMED_NAME_ERR';
152 }
153 }
154 }
155
156 return Message::DOM::AttributeDefinition->____new (@_[0, 1]);
157 } # create_attribute_definition
158
159 =head1 LICENSE
160
161 Copyright 2007 Wakaba <w@suika.fam.cx>
162
163 This program is free software; you can redistribute it and/or
164 modify it under the same terms as Perl itself.
165
166 =cut
167
168 1;
169 ## $Date: 2007/07/12 13:54:46 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24