1 |
wakaba |
1.1 |
package Message::DOM::AttributeDefinition; |
2 |
|
|
use strict; |
3 |
wakaba |
1.10 |
our $VERSION=do{my @r=(q$Revision: 1.9 $=~/\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 |
wakaba |
1.8 |
require Message::DOM::Attr; |
7 |
wakaba |
1.1 |
|
8 |
|
|
sub ____new ($$$) { |
9 |
|
|
my $self = shift->SUPER::____new (shift); |
10 |
|
|
$$self->{node_name} = $_[0]; |
11 |
wakaba |
1.3 |
$$self->{child_nodes} = []; |
12 |
wakaba |
1.6 |
$$self->{allowed_tokens} = []; |
13 |
wakaba |
1.1 |
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 |
wakaba |
1.2 |
node_name => 1, |
24 |
wakaba |
1.10 |
owner_element_type_definition => 1, |
25 |
wakaba |
1.1 |
}->{$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 |
wakaba |
1.4 |
## |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 |
wakaba |
1.1 |
## The |Node| interface - attribute |
67 |
|
|
|
68 |
wakaba |
1.2 |
## Spec: |
69 |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D095> |
70 |
|
|
## <http://suika.fam.cx/gate/2005/sw/AttributeDefinition> |
71 |
|
|
|
72 |
|
|
sub node_name ($); # read-only trivial accessor |
73 |
|
|
|
74 |
|
|
## Spec: |
75 |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-111237558> |
76 |
|
|
|
77 |
|
|
sub node_type ($) { 81002 } # ATTRIBUTE_DEFINITION_NODE |
78 |
|
|
|
79 |
|
|
## Spec: |
80 |
|
|
## <http://suika.fam.cx/gate/2005/sw/AttributeDefinition#anchor-2> |
81 |
|
|
|
82 |
|
|
## TODO: node_value |
83 |
wakaba |
1.1 |
|
84 |
wakaba |
1.8 |
## |Node| methods |
85 |
|
|
|
86 |
|
|
*append_child = \&Message::DOM::Attr::append_child; |
87 |
|
|
|
88 |
|
|
*insert_before = \&Message::DOM::Attr::insert_before; |
89 |
|
|
|
90 |
|
|
*replace_child = \&Message::DOM::Attr::replace_child; |
91 |
|
|
|
92 |
wakaba |
1.4 |
## |AttributeDefinition| attributes |
93 |
|
|
|
94 |
wakaba |
1.6 |
sub allowed_tokens ($) { |
95 |
wakaba |
1.7 |
require Message::DOM::DOMStringList; |
96 |
|
|
return bless \[$_[0], 'allowed_tokens'], 'Message::DOM::DOMStringList'; |
97 |
|
|
} # allowed_tokens |
98 |
wakaba |
1.5 |
|
99 |
wakaba |
1.4 |
sub declared_type ($;$) { |
100 |
|
|
my $self = $_[0]; |
101 |
|
|
if (@_ > 1) { |
102 |
|
|
if (${$$self->{owner_document}}->{strict_error_checking}) { |
103 |
|
|
if ($$self->{manakai_read_only}) { |
104 |
|
|
report Message::DOM::DOMException |
105 |
|
|
-object => $self, |
106 |
|
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
107 |
|
|
-subtype => 'READ_ONLY_NODE_ERR'; |
108 |
|
|
} |
109 |
|
|
} |
110 |
|
|
if ($_[1]) { |
111 |
|
|
$$self->{declared_type} = 0+$_[1]; |
112 |
|
|
} else { |
113 |
|
|
delete $$self->{declared_type}; |
114 |
|
|
} |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
return $$self->{declared_type} || 0; |
118 |
|
|
} # declared_type |
119 |
|
|
|
120 |
|
|
sub default_type ($;$) { |
121 |
|
|
my $self = $_[0]; |
122 |
|
|
if (@_ > 1) { |
123 |
|
|
if (${$$self->{owner_document}}->{strict_error_checking}) { |
124 |
|
|
if ($$self->{manakai_read_only}) { |
125 |
|
|
report Message::DOM::DOMException |
126 |
|
|
-object => $self, |
127 |
|
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
128 |
|
|
-subtype => 'READ_ONLY_NODE_ERR'; |
129 |
|
|
} |
130 |
|
|
} |
131 |
|
|
if ($_[1]) { |
132 |
|
|
$$self->{default_type} = 0+$_[1]; |
133 |
|
|
} else { |
134 |
|
|
delete $$self->{default_type}; |
135 |
|
|
} |
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
return $$self->{default_type} || 0; |
139 |
|
|
} # default_type |
140 |
|
|
|
141 |
wakaba |
1.10 |
sub owner_element_type_definition ($); |
142 |
|
|
|
143 |
wakaba |
1.1 |
package Message::IF::AttributeDefinition; |
144 |
|
|
|
145 |
|
|
package Message::DOM::Document; |
146 |
|
|
|
147 |
wakaba |
1.2 |
sub create_attribute_definition ($$) { |
148 |
wakaba |
1.1 |
return Message::DOM::AttributeDefinition->____new (@_[0, 1]); |
149 |
|
|
} # create_attribute_definition |
150 |
|
|
|
151 |
wakaba |
1.10 |
=head1 LICENSE |
152 |
|
|
|
153 |
|
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
154 |
|
|
|
155 |
|
|
This program is free software; you can redistribute it and/or |
156 |
|
|
modify it under the same terms as Perl itself. |
157 |
|
|
|
158 |
|
|
=cut |
159 |
|
|
|
160 |
wakaba |
1.1 |
1; |
161 |
wakaba |
1.10 |
## $Date: 2007/07/08 13:04:36 $ |