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

Diff of /messaging/manakai/lib/Message/DOM/EntityReference.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by wakaba, Sat Jun 16 08:05:48 2007 UTC revision 1.4 by wakaba, Sun Jun 17 13:37:40 2007 UTC
# Line 35  sub AUTOLOAD { Line 35  sub AUTOLOAD {
35      };      };
36      goto &{ $AUTOLOAD };      goto &{ $AUTOLOAD };
37    } elsif ({    } elsif ({
38      ## Read-write attributes (DOMString, trivial accessors)      ## Read-write attributes (boolean, trivial accessors)
39        manakai_expanded => 1,
40        manakai_external => 1,
41    }->{$method_name}) {    }->{$method_name}) {
42      no strict 'refs';      no strict 'refs';
43      eval qq{      eval qq{
44        sub $method_name (\$) {        sub $method_name (\$;\$) {
45          if (\@_ > 1) {          if (\@_ > 1) {
46            \${\$_[0]}->{$method_name} = ''.$_[1];            if (\${\${\$_[0]}->{owner_document}}->{manakai_strict_error_checking} and
47                  \${\$_[0]}->{manakai_read_only}) {
48                report Message::DOM::DOMException
49                    -object => \$_[0],
50                    -type => 'NO_MODIFICATION_ALLOWED_ERR',
51                    -subtype => 'READ_ONLY_NODE_ERR';
52              }
53              if (\$_[1]) {
54                \${\$_[0]}->{$method_name} = 1;
55              } else {
56                delete \${\$_[0]}->{$method_name};
57              }
58          }          }
59          return \${\$_[0]}->{$method_name};          return \${\$_[0]}->{$method_name};
60        }        }
61      };      };
62      goto &{ $AUTOLOAD };      goto &{ $AUTOLOAD };
# Line 53  sub AUTOLOAD { Line 66  sub AUTOLOAD {
66    }    }
67  } # AUTOLOAD  } # AUTOLOAD
68    
69  ## The |Node| interface - attribute  ## |Node| attributes
70    
71  ## Spec:  sub base_uri ($) {
72  ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D095>    ## NOTE: Same as |CharacterData|'s.
73  ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1950641247>  
74      my $self = $_[0];
75      local $Error::Depth = $Error::Depth + 1;
76      my $pe = $$self->{parent_node};
77      while (defined $pe) {
78        my $nt = $pe->node_type;
79        if ($nt == 1 or $nt == 2 or $nt == 6 or $nt == 9 or $nt == 11) {
80          ## Element, Attr, Entity, Document, or DocumentFragment
81          return $pe->base_uri;
82        } elsif ($nt == 5) {
83          ## EntityReference
84          return $pe->manakai_entity_base_uri if $pe->manakai_external;
85        }
86        $pe = $$pe->{parent_node};
87      }
88      return $pe->base_uri if $pe;
89      return $$self->{owner_document}->base_uri;
90    } # base_uri
91    
92  sub node_name ($); # read-only trivial accessor  sub node_name ($); # read-only trivial accessor
93    
94  ## Spec:  sub node_type () { 5 } # ENTITY_REFERENCE_NODE
95  ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-111237558>  
96    ## |EntityReference| attributes
97    
98    sub manakai_entity_base_uri ($;$) {
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 (defined $_[1]) {
110          $$self->{manakai_entity_base_uri} = ''.$_[1];
111        } else {
112          delete $$self->{manakai_entity_base_uri};
113        }
114      }
115      
116      if (defined $$self->{manakai_entity_base_uri}) {
117        return $$self->{manakai_entity_base_uri};
118      } else {
119        local $Error::Depth = $Error::Depth + 1;
120        return $self->base_uri;
121      }
122    } # manakai_entity_base_uri
123    
124    sub manakai_expanded ($;$);
125    
126  sub node_type ($) { 5 } # ENTITY_REFERENCE_NODE  sub manakai_external ($;$);
127    
128  package Message::IF::EntityReference;  package Message::IF::EntityReference;
129    
130  package Message::DOM::Document;  package Message::DOM::Document;
131    
 ## Spec:  
 ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-392B75AE>  
 ## Compatibility note:  
 ## <http://suika.fam.cx/gate/2005/sw/createEntityReference>  
   
132  sub create_entity_reference ($$) {  sub create_entity_reference ($$) {
133    return Message::DOM::EntityReference->____new (@_[0, 1]);    return Message::DOM::EntityReference->____new (@_[0, 1]);
134  } # create_entity_reference  } # create_entity_reference
135    
136    =head1 LICENSE
137    
138    Copyright 2007 Wakaba <w@suika.fam.cx>
139    
140    This program is free software; you can redistribute it and/or
141    modify it under the same terms as Perl itself.
142    
143    =cut
144    
145  1;  1;
 ## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL>  
146  ## $Date$  ## $Date$

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24