/[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.13 - (hide annotations) (download)
Sat Dec 22 06:29:32 2007 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +3 -3 lines
++ manakai/lib/Message/DOM/ChangeLog	22 Dec 2007 06:29:10 -0000
2007-12-22  Wakaba  <wakaba@suika.fam.cx>

	* CSSStyleSheet.pm, CSSRule.pm, CSSRuleList.pm, CSSStyleDeclaration.pm:
	First version of CSSOM implementation.

++ manakai/lib/Message/Charset/ChangeLog	23 Nov 2007 04:23:29 -0000
2007-11-23  Wakaba  <wakaba@suika.fam.cx>

	* Info.pm (is_syntactically_valid_iana_charset_name): Function
	name was misspelled.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24