/[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.9 - (show annotations) (download)
Sun Jul 8 13:04:36 2007 UTC (17 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +2 -15 lines
++ manakai/t/ChangeLog	8 Jul 2007 13:03:58 -0000
	* DOM-Element.t: Tests for |attributes| are added.

	* DOM-Entity.t: Tests for |is_externally_declared|
	and |input_encoding| are added.

	* DOM-Node.t: Test data for |tag_name| and
	|get_feature| are added.

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

++ manakai/lib/Message/DOM/ChangeLog	8 Jul 2007 13:02:01 -0000
	* Attr.pm (value, node_value): Now it is defined
	as |text_content| itself.

	* AttributeDefinition.pm, ElementTypeDefinition.pm,
	Node.pm (AUTOLOAD): Unused block is removed.

	* CDATASection.pm, DocumentFragment.pm (AUTOLOAD): Removed.  Unused.

	* DocumentType.pm (internal_subset): Implemented.

	* Entity.pm (is_externally_declared, input_encoding,
	xml_version): Implemented.

	* ProcessingInstruction.pm (target, data): Implemented.

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

1 package Message::DOM::AttributeDefinition;
2 use strict;
3 our $VERSION=do{my @r=(q$Revision: 1.8 $=~/\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 }->{$method_name}) {
25 no strict 'refs';
26 eval qq{
27 sub $method_name (\$) {
28 if (\@_ > 1) {
29 require Carp;
30 Carp::croak (qq<Can't modify read-only attribute>);
31 }
32 return \${\$_[0]}->{$method_name};
33 }
34 };
35 goto &{ $AUTOLOAD };
36 } else {
37 require Carp;
38 Carp::croak (qq<Can't locate method "$AUTOLOAD">);
39 }
40 } # AUTOLOAD
41
42 ## |AttributeDefinition| constants
43
44 ## |DeclaredValueType|
45 sub NO_TYPE_ATTR () { 0 }
46 sub CDATA_ATTR () { 1 }
47 sub ID_ATTR () { 2 }
48 sub IDREF_ATTR () { 3 }
49 sub IDREFS_ATTR () { 4 }
50 sub ENTITY_ATTR () { 5 }
51 sub ENTITIES_ATTR () { 6 }
52 sub NMTOKEN_ATTR () { 7 }
53 sub NMTOKENS_ATTR () { 8 }
54 sub NOTATION_ATTR () { 9 }
55 sub ENUMERATION_ATTR () { 10 }
56 sub UNKNOWN_ATTR () { 11 }
57
58 ## |DefaultValueType|
59 sub UNKNOWN_DEFAULT () { 0 }
60 sub FIXED_DEFAULT () { 1 }
61 sub REQUIRED_DEFAULT () { 2 }
62 sub IMPLIED_DEFAULT () { 3 }
63 sub EXPLICIT_DEFAULT () { 4 }
64
65 ## The |Node| interface - attribute
66
67 ## Spec:
68 ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D095>
69 ## <http://suika.fam.cx/gate/2005/sw/AttributeDefinition>
70
71 sub node_name ($); # read-only trivial accessor
72
73 ## Spec:
74 ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-111237558>
75
76 sub node_type ($) { 81002 } # ATTRIBUTE_DEFINITION_NODE
77
78 ## Spec:
79 ## <http://suika.fam.cx/gate/2005/sw/AttributeDefinition#anchor-2>
80
81 ## TODO: node_value
82
83 ## |Node| methods
84
85 *append_child = \&Message::DOM::Attr::append_child;
86
87 *insert_before = \&Message::DOM::Attr::insert_before;
88
89 *replace_child = \&Message::DOM::Attr::replace_child;
90
91 ## |AttributeDefinition| attributes
92
93 sub allowed_tokens ($) {
94 require Message::DOM::DOMStringList;
95 return bless \[$_[0], 'allowed_tokens'], 'Message::DOM::DOMStringList';
96 } # allowed_tokens
97
98 sub declared_type ($;$) {
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 ($_[1]) {
110 $$self->{declared_type} = 0+$_[1];
111 } else {
112 delete $$self->{declared_type};
113 }
114 }
115
116 return $$self->{declared_type} || 0;
117 } # declared_type
118
119 sub default_type ($;$) {
120 my $self = $_[0];
121 if (@_ > 1) {
122 if (${$$self->{owner_document}}->{strict_error_checking}) {
123 if ($$self->{manakai_read_only}) {
124 report Message::DOM::DOMException
125 -object => $self,
126 -type => 'NO_MODIFICATION_ALLOWED_ERR',
127 -subtype => 'READ_ONLY_NODE_ERR';
128 }
129 }
130 if ($_[1]) {
131 $$self->{default_type} = 0+$_[1];
132 } else {
133 delete $$self->{default_type};
134 }
135 }
136
137 return $$self->{default_type} || 0;
138 } # default_type
139
140 package Message::IF::AttributeDefinition;
141
142 package Message::DOM::Document;
143
144 ## Spec:
145 ## <http://suika.fam.cx/gate/2005/sw/DocumentXDoctype>
146
147 sub create_attribute_definition ($$) {
148 return Message::DOM::AttributeDefinition->____new (@_[0, 1]);
149 } # create_attribute_definition
150
151 1;
152 ## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL>
153 ## $Date: 2007/07/08 05:42:36 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24