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

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

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

revision 1.4 by wakaba, Sat Jun 16 15:27:45 2007 UTC revision 1.5 by wakaba, Sun Jun 17 13:37:40 2007 UTC
# Line 33  sub AUTOLOAD { Line 33  sub AUTOLOAD {
33      goto &{ $AUTOLOAD };      goto &{ $AUTOLOAD };
34    } elsif ({    } elsif ({
35      ## Read-write attributes (DOMString, trivial accessors)      ## Read-write attributes (DOMString, trivial accessors)
36        manakai_base_uri => 1,
37    }->{$method_name}) {    }->{$method_name}) {
38      no strict 'refs';      no strict 'refs';
39      eval qq{      eval qq{
40        sub $method_name (\$) {        sub $method_name (\$;\$) {
41          if (\@_ > 1) {          if (\@_ > 1) {
42            \${\$_[0]}->{$method_name} = ''.$_[1];            if (\${\${\$_[0]}->{owner_document}}->{strict_error_checking} and
43                  \${\$_[0]}->{manakai_read_only}) {
44                report Message::DOM::DOMException
45                    -object => \$_[0],
46                    -type => 'NO_MODIFICATION_ALLOWED_ERR',
47                    -subtype => 'READ_ONLY_NODE_ERR';
48              }
49              if (defined \$_[1]) {
50                \${\$_[0]}->{$method_name} = ''.\$_[1];
51              } else {
52                delete \${\$_[0]}->{$method_name};
53              }
54          }          }
55          return \${\$_[0]}->{$method_name};          return \${\$_[0]}->{$method_name};
56        }        }
57      };      };
58      goto &{ $AUTOLOAD };      goto &{ $AUTOLOAD };
# Line 52  sub AUTOLOAD { Line 64  sub AUTOLOAD {
64  sub target ($);  sub target ($);
65  sub data ($);  sub data ($);
66    
67  ## The |Node| interface - attribute  ## |Node| attributes
68    
69    sub base_uri ($) {
70      my $self = $_[0];
71      return $$self->{manakai_base_uri} if defined $$self->{manakai_base_uri};
72      
73      local $Error::Depth = $Error::Depth + 1;
74      my $node = $$self->{parent_node};
75      while (defined $node) {
76        my $nt = $node->node_type;
77        if ($nt == 1 or $nt == 6 or $nt == 9 or $nt == 10 or $nt == 11) {
78          ## Element, Entity, Document, DocumentType, or DocumentFragment
79          return $node->base_uri;
80        } elsif ($nt == 5) {
81          ## EntityReference
82          return $node->manakai_entity_base_uri if $node->manakai_external;
83        }
84        $node = $$node->{parent_node};
85      }
86      return $node->base_uri if $node;
87      return $self->owner_document->base_uri;
88    } # base_uri
89    
90  sub child_nodes ($) {  sub child_nodes ($) {
91    require Message::DOM::NodeList;    require Message::DOM::NodeList;
# Line 64  sub child_nodes ($) { Line 97  sub child_nodes ($) {
97    
98  *node_name = \⌖  *node_name = \⌖
99    
100  ## Spec:  sub node_type () { 7 } # PROCESSING_INSTRUCTION_NODE
 ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-111237558>  
   
 sub node_type ($) { 7 } # PROCESSING_INSTRUCTION_NODE  
101    
102  ## The entire content exclude the target [DOM1, DOM2].  ## The entire content exclude the target [DOM1, DOM2].
103  ## Same as |ProcessingInstruction.data| [DOM3].  ## Same as |ProcessingInstruction.data| [DOM3].
# Line 76  sub node_type ($) { 7 } # PROCESSING_INS Line 106  sub node_type ($) { 7 } # PROCESSING_INS
106    
107  *text_content = \&node_value;  *text_content = \&node_value;
108    
109    ## |Node| methods
110    
111    sub manakai_append_text ($$) {
112      ## NOTE: Same as |CharacterData|'s.
113      if (${${$_[0]}->{owner_document}}->{strict_error_checking} and
114          ${$_[0]}->{manakai_read_only}) {
115        report Message::DOM::DOMException
116            -object => $_[0],
117            -type => 'NO_MODIFICATION_ALLOWED_ERR',
118            -subtype => 'READ_ONLY_NODE_ERR';
119      }
120      ${$_[0]}->{data} .= ref $_[1] eq 'SCALAR' ? ${$_[1]} : $_[1];
121    } # manakai_append_text
122    
123    ## |ProcessingInstruction| attributes
124    
125    sub manakai_base_uri ($;$);
126    
127  package Message::IF::ProcessingInstruction;  package Message::IF::ProcessingInstruction;
128    
129  package Message::DOM::Document;  package Message::DOM::Document;
130    
 ## Spec:  
 ## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-135944439>  
 ## Compatibility note:  
 ## <http://suika.fam.cx/gate/2005/sw/createProcessingInstruction>  
   
131  sub create_processing_instruction ($$$) {  sub create_processing_instruction ($$$) {
132    return Message::DOM::ProcessingInstruction->____new (@_[0, 1, 2]);    return Message::DOM::ProcessingInstruction->____new (@_[0, 1, 2]);
133  } # create_processing_instruction  } # create_processing_instruction
134    
135    =head1 LICENSE
136    
137    Copyright 2007 Wakaba <w@suika.fam.cx>
138    
139    This program is free software; you can redistribute it and/or
140    modify it under the same terms as Perl itself.
141    
142    =cut
143    
144  1;  1;
 ## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL>  
145  ## $Date$  ## $Date$

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24