annotate Lib/IMPL/DOM/Node.pm @ 130:06a34c197b05

Added support for utf-8 and old versions of CGI module
author wizard
date Wed, 16 Jun 2010 01:50:56 +0400
parents e30bdd040fe3
children e6447ad85cb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
1 package IMPL::DOM::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
5 use base qw(IMPL::Object);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
6
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
7 use IMPL::Object::List;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
8 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
9 use IMPL::Class::Property::Direct;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
10 use Scalar::Util qw(weaken);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
11
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
12 use IMPL::Exception;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
14 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
15 public _direct property nodeName => prop_get;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
16 public _direct property document => prop_get;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
17 public _direct property isComplex => { get => \&_getIsComplex } ;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
18 public _direct property nodeValue => prop_all;
102
cf3b6ef2be22 Schema beta version
wizard
parents: 75
diff changeset
19 public _direct property childNodes => { get => \&_getChildNodes }; # prop_list
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
20 public _direct property parentNode => prop_get ;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
21 private _direct property _propertyMap => prop_all ;
116
1722ca51537c minor changes.
wizard
parents: 113
diff changeset
22
1722ca51537c minor changes.
wizard
parents: 113
diff changeset
23 __PACKAGE__->class_data(property_bind => {});
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
24 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
25
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
26 our %Axes = (
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
27 parent => \&selectParent,
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
28 siblings => \&selectSiblings,
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
29 child => \&childNodes,
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
30 document => \&selectDocument
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
31 );
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
32
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
33 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
34 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
35
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
36 $this->{$nodeName} = delete $args{nodeName} or die new IMPL::InvalidArgumentException("A name is required");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
37 $this->{$nodeValue} = delete $args{nodeValue} if exists $args{nodeValue};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
38 if ( exists $args{document} ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
39 $this->{$document} = delete $args{document};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
40 weaken($this->{$document});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
41 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
42
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
43 while ( my ($key,$value) = each %args ) {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
44 $this->nodeProperty($key,$value);
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
45 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
46 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
48 sub insertNode {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
49 my ($this,$node,$pos) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
50
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
51 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if $this == $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
52
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
53 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
54
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
55 $this->childNodes->InsertAt($pos,$node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
56
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
57 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
58
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
59 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
60 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
61
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
62 sub appendChild {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
63 my ($this,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
64
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
65 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if $this == $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
66
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
67 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
68
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
69 my $children = $this->childNodes;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
70 $children->Append($node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
71
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
72 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
73
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
74 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
75 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
76
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
77 sub appendNode {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
78 goto &appendChild;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
79 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
80
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
81 sub appendRange {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
82 my ($this,@range) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
83
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
84 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if grep $_ == $this, @range;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
85
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
86 foreach my $node (@range) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
87 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
88 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
89 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
90
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
91 $this->childNodes->Append(@range);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
92
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
93 return $this;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
94 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
95
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
96 sub _getChildNodes {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
97 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
98
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
99 $this->{$childNodes} = new IMPL::Object::List() unless $this->{$childNodes};
102
cf3b6ef2be22 Schema beta version
wizard
parents: 75
diff changeset
100 return wantarray ? @{ $this->{$childNodes} } : $this->{$childNodes};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
101 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
102
109
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
103 sub childNodesRef {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
104 my ($this) = @_;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
105 return scalar $this->_getChildNodes;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
106 }
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
107
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
108 sub removeNode {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
109 my ($this,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
110
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
111 if ($this == $node->{$parentNode}) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
112 $this->childNodes->RemoveItem($node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
113 $node->_setParent(undef);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
114 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
115 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
116 die new IMPL::InvalidOperationException("The specified node isn't belong to this node");
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
117 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
118 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
119
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
120 sub replaceNodeAt {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
121 my ($this,$index,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
122
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
123 my $nodeOld = $this->childNodes->[$index];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
124
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
125 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if $this == $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
126
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
127 # unlink node from previous parent
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
128 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
129
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
130 # replace (or set) old node
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
131 $this->childNodes->[$index] = $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
132
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
133 # set new parent
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
134 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
135
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
136 # unlink old node if we have one
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
137 $nodeOld->_setParent(undef) if $nodeOld;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
138
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
139 # return old node
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
140 return $nodeOld;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
141 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
142
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
143 sub removeAt {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
144 my ($this,$pos) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
145
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
146 if ( my $node = $this->childNodes->RemoveAt($pos) ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
147 $node->_setParent(undef);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
148 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
149 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
150 return undef;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
151 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
152 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
153
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
154 sub removeLast {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
155 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
156
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
157 if ( my $node = $this->{$childNodes} ? $this->{$childNodes}->RemoveLast() : undef) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
158 $node->_setParent(undef);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
159 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
160 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
161 return undef;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
162 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
163 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
164
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
165 sub removeSelected {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
166 my ($this,$query) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
167
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
168 my @newSet;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
169 my @result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
170
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
171 if (ref $query eq 'CODE') {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
172 &$query($_) ? push @result, $_ : push @newSet, $_ foreach @{$this->childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
173 } elsif (defined $query) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
174 $_->nodeName eq $query ? push @result, $_ : push @newSet, $_ foreach @{$this->childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
175 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
176 my $children = $this->childNodes;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
177 $_->_setParent(undef) foreach @$children;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
178 delete $this->{$childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
179 return wantarray ? @$children : $children;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
180 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
181
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
182 $_->_setParent(undef) foreach @result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
183
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
184 $this->{$childNodes} = @newSet ? bless \@newSet ,'IMPL::Object::List' : undef;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
185
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
186 return wantarray ? @result : \@result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
187 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
188
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
189 sub resolveAxis {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
190 my ($this,$axis) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
191 return $Axes{$axis}->($this)
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
192 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
193
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
194 sub selectNodes {
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
195 my $this = shift;
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
196 my $path;
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
197
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
198 if (@_ == 1) {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
199 $path = $this->translatePath($_[0]);
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
200 } else {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
201 $path = [@_];
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
202 }
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
203
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
204 my @set = ($this);
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
205
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
206 while (@$path) {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
207 my $query = shift @$path;
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
208 @set = map $_->selectNodesAxis($query), @set;
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
209 }
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
210
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
211 return wantarray ? @set : \@set;
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
212 }
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
213
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
214 sub selectSingleNode {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
215 my $this = shift;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
216 my @result = $this->selectNodes(@_);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
217 return $result[0];
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
218 }
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
219
109
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
220 sub selectNodesRef {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
221 my $this = shift;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
222
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
223 my @result = $this->selectNodes(@_);
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
224 return \@result;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
225 }
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
226
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
227 sub translatePath {
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
228 my ($this,$path) = @_;
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
229
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
230 # TODO: Move path compilation here from IMPL::DOM::Schema::Validator::Compare
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
231 return [$path];
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
232 }
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
233
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
234 sub selectNodesAxis {
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
235 my ($this,$query,$axis) = @_;
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
236
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
237 $axis ||= 'child';
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
238
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
239 die new IMPL::InvalidOperationException('Unknown axis',$axis) unless exists $Axes{$axis};
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
240
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
241 my $nodes = $this->resolveAxis($axis);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
242
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
243 my @result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
244
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
245 if (ref $query eq 'CODE') {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
246 @result = grep &$query($_), @{$nodes};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
247 } elsif (ref $query eq 'ARRAY' ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
248 my %keys = map (($_,1),@$query);
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
249 @result = grep $keys{$_->nodeName}, @{$nodes};
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
250 } elsif (ref $query eq 'HASH') {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
251 while( my ($axis,$filter) = each %$query ) {
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
252 push @result, $this->selectNodesAxis($filter,$axis);
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
253 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
254 } elsif (defined $query) {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
255 @result = grep $_->nodeName eq $query, @{$nodes};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
256 } else {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
257 return wantarray ? @{$nodes} : $nodes;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
258 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
259
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
260 return wantarray ? @result : \@result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
261 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
262
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
263 sub selectParent {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
264 my ($this) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
265
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
266 if ($this->parentNode) {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
267 return wantarray ? $this->parentNode : [$this->parentNode];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
268 } else {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
269 return wantarray ? () : [];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
270 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
271 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
272
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
273 sub selectSiblings {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
274 my ($this) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
275
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
276 if ($this->parentNode) {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
277 return $this->parentNode->selectNodes( sub { $_ != $this } );
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
278 } else {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
279 return wantarray ? () : [];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
280 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
281 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
282
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
283 sub selectDocument {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
284 my ($this) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
285
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
286 if ($this->document) {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
287 return wantarray ? $this->document : [$this->document];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
288 } else {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
289 return wantarray ? () : [];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
290 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
291 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
292
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
293 sub firstChild {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
294 @_ >=2 ? $_[0]->replaceNodeAt(0,$_[1]) : $_[0]->childNodes->[0];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
295 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
296
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
297 sub _getIsComplex {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
298 $_[0]->childNodes->Count ? 1 : 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
299 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
300
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
301 sub _updateDocRefs {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
302 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
303
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
304 # this method is called by the parent node on his children, so we need no to check parent
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
305 $this->{$document} = $this->{$parentNode}->document;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
306
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
307 # prevent cyclic
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
308 weaken($this->{$document}) if $this->{$document};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
309
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
310 $_->_updateDocRefs foreach @{$this->{$childNodes}};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
311 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
312
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
313 sub _setParent {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
314 my ($this,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
315
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
316
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
317 if (($node || 0) != ($this->{$parentNode} || 0)) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
318 my $newOwner;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
319 if ($node) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
320 $this->{$parentNode} = $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
321 $newOwner = $node->document || 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
322
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
323 # prevent from creating cyclicreferences
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
324 weaken($this->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
325
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
326 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
327 delete $this->{$parentNode};
75
wizard
parents: 49
diff changeset
328
wizard
parents: 49
diff changeset
329 #keep document
wizard
parents: 49
diff changeset
330 $newOwner = $this->{$document};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
331 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
332
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
333 if (($this->{$document}||0) != $newOwner) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
334 $this->{$document} = $newOwner;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
335 weaken($this->{$document}) if $newOwner;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
336 $_->_updateDocRefs foreach @{$this->childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
337 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
338 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
339 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
340
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
341 sub text {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
342 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
343
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
344 join ('', $this->nodeValue || '', map ($_->text || '', @{$this->childNodes}));
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
345 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
346
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
347 sub nodeProperty {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
348 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
349 my $name = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
350
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
351 if (my $method = $this->can($name)) {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
352 return &$method($this,@_);
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
353 }
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
354
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
355 if (@_) {
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
356 # set
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
357 return $this->{$_propertyMap}{$name} = shift;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
358 } else {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
359 return $this->{$_propertyMap}{$name};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
360 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
361 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
362
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
363 sub listProperties {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
364 my ($this) = @_;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
365
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
366 my %props = map {$_->Name, 1} $this->get_meta(typeof IMPL::Class::PropertyInfo, sub { $_->Attributes->{domProperty}},1);
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
367
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
368 return (keys %props,keys %{$this->{$_propertyMap}});
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
369 }
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
370
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
371 sub qname {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
372 $_[0]->{$nodeName};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
373 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
374
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
375 sub path {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
376 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
377
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
378 if ($this->parentNode) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
379 return $this->parentNode->path.'.'.$this->qname;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
380 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
381 return $this->qname;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
382 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
383 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
384
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
385 1;
75
wizard
parents: 49
diff changeset
386
wizard
parents: 49
diff changeset
387 __END__
wizard
parents: 49
diff changeset
388
wizard
parents: 49
diff changeset
389 =pod
wizard
parents: 49
diff changeset
390
wizard
parents: 49
diff changeset
391 =head1 NAME
wizard
parents: 49
diff changeset
392
wizard
parents: 49
diff changeset
393 C<IMPL::DOM::Node> Элемент DOM модели
wizard
parents: 49
diff changeset
394
wizard
parents: 49
diff changeset
395 =head1 DESCRIPTION
wizard
parents: 49
diff changeset
396
wizard
parents: 49
diff changeset
397 Базовый узел DOM модели. От него можно наследовать другие элементы DOM модели.
wizard
parents: 49
diff changeset
398
wizard
parents: 49
diff changeset
399 =head1 MEMBERS
wizard
parents: 49
diff changeset
400
wizard
parents: 49
diff changeset
401 =head2 PROPERTIES
wizard
parents: 49
diff changeset
402
wizard
parents: 49
diff changeset
403 =over
wizard
parents: 49
diff changeset
404
wizard
parents: 49
diff changeset
405 =item C<[get] nodeName>
wizard
parents: 49
diff changeset
406
wizard
parents: 49
diff changeset
407 Имя узла. Задается при создании.
wizard
parents: 49
diff changeset
408
wizard
parents: 49
diff changeset
409 =item C<[get] document>
wizard
parents: 49
diff changeset
410
wizard
parents: 49
diff changeset
411 Документ к которому принадлежит узел. Задается при поздании узла.
wizard
parents: 49
diff changeset
412
wizard
parents: 49
diff changeset
413 =item C<[get] isComplex>
wizard
parents: 49
diff changeset
414
wizard
parents: 49
diff changeset
415 Определяет является ли узел сложным (тоесть есть ли дети).
wizard
parents: 49
diff changeset
416
wizard
parents: 49
diff changeset
417 C<true> - есть, C<false> - нет.
wizard
parents: 49
diff changeset
418
wizard
parents: 49
diff changeset
419 =item C<[get,set] nodeValue>
wizard
parents: 49
diff changeset
420
wizard
parents: 49
diff changeset
421 Значение узла, обычно простой скаляр, но ничто не мешает туда
wizard
parents: 49
diff changeset
422 устанавливать любое значение.
wizard
parents: 49
diff changeset
423
wizard
parents: 49
diff changeset
424 =item C<[get,list] childNodes>
wizard
parents: 49
diff changeset
425
wizard
parents: 49
diff changeset
426 Список детей, является списокм C<IMPL::Object::List>.
wizard
parents: 49
diff changeset
427
wizard
parents: 49
diff changeset
428 =item C<[get] parentNode>
wizard
parents: 49
diff changeset
429
wizard
parents: 49
diff changeset
430 Ссылка на родительский элемент, если таковой имеется.
wizard
parents: 49
diff changeset
431
wizard
parents: 49
diff changeset
432 =head2 METHODS
wizard
parents: 49
diff changeset
433
wizard
parents: 49
diff changeset
434 =cut