annotate lib/IMPL/DOM/Node.pm @ 407:c6e90e02dd17 ref20150831

renamed Lib->lib
author cin
date Fri, 04 Sep 2015 19:40:23 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::DOM::Node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3 use warnings;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5 use Scalar::Util qw(weaken);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 use IMPL::lang;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8 use IMPL::Object::List;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 use IMPL::Exception();
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 use IMPL::Const qw(:prop);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13 require => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14 PropertyInfo => '-IMPL::Class::PropertyInfo'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16 base => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 'IMPL::Object' => undef
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 ],
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 props => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 nodeName => PROP_RO | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21 document => PROP_RO | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 isComplex => { get => \&_getIsComplex },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23 nodeValue => PROP_RW | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 childNodes => { get => \&_getChildNodes, isList => 1, direct => 1 },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25 parentNode => PROP_RO | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 schemaNode => PROP_RO | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 schemaType => PROP_RO | PROP_DIRECT,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28 _propertyMap => PROP_RW | PROP_DIRECT
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 ]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32 our %Axes = (
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 parent => \&selectParent,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
34 siblings => \&selectSiblings,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
35 child => \&childNodes,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
36 document => \&selectDocument,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
37 ancestor => \&selectAncestors,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
38 descendant => \&selectDescendant
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
39 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
40
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
41 sub CTOR {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
42 my ($this,%args) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
43
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
44 $this->{$nodeName} = delete $args{nodeName} or die new IMPL::InvalidArgumentException("A name is required");
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
45 $this->{$nodeValue} = delete $args{nodeValue} if exists $args{nodeValue};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
46 if ( exists $args{document} ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
47 $this->{$document} = delete $args{document};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
48 weaken($this->{$document});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
49 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
50
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
51 while ( my ($key,$value) = each %args ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
52 $this->nodeProperty($key,$value);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
53 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
54 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
55
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
56 sub insertNode {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
57 my ($this,$node,$pos) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
58
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
59 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if $this == $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
60
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
61 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
62
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
63 $this->childNodes->InsertAt($pos,$node);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
64
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
65 $node->_setParent( $this );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
66
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
67 return $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
68 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
69
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
70 sub appendChild {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
71 my ($this,$node) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
72
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
73 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if $this == $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
74
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
75 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
76
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
77 my $children = $this->childNodes;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
78 $children->Push($node);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
79
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
80 $node->_setParent( $this );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
81
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
82 return $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
83 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
84
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
85 sub appendNode {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
86 goto &appendChild;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
87 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
88
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
89 sub appendRange {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
90 my ($this,@range) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
91
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
92 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if grep $_ == $this, @range;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
93
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
94 foreach my $node (@range) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
95 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
96 $node->_setParent( $this );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
97 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
98
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
99 $this->childNodes->Push(@range);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
100
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
101 return $this;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
102 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
103
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
104 sub _getChildNodes {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
105 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
106
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
107 $this->{$childNodes} = new IMPL::Object::List() unless $this->{$childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
108 return wantarray ? @{ $this->{$childNodes} } : $this->{$childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
109 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
110
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
111 sub childNodesRef {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
112 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
113 return scalar $this->_getChildNodes;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
114 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
115
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
116 sub removeNode {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
117 my ($this,$node) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
118
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
119 if ($this == $node->{$parentNode}) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
120 $this->childNodes->RemoveItem($node);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
121 $node->_setParent(undef);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
122 return $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
123 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
124 die new IMPL::InvalidOperationException("The specified node isn't belong to this node");
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
125 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
126 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
127
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
128 sub replaceNodeAt {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
129 my ($this,$index,$node) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
130
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
131 my $nodeOld = $this->childNodes->[$index];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
132
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
133 die new IMPL::InvalidOperationException("You can't insert the node to itselft") if $this == $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
134
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
135 # unlink node from previous parent
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
136 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
137
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
138 # replace (or set) old node
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
139 $this->childNodes->[$index] = $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
140
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
141 # set new parent
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
142 $node->_setParent( $this );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
143
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
144 # unlink old node if we have one
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
145 $nodeOld->_setParent(undef) if $nodeOld;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
146
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
147 # return old node
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
148 return $nodeOld;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
149 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
150
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
151 sub removeAt {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
152 my ($this,$pos) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
153
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
154 if ( my $node = $this->childNodes->RemoveAt($pos) ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
155 $node->_setParent(undef);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
156 return $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
157 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
158 return undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
159 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
160 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
161
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
162 sub removeLast {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
163 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
164
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
165 if ( my $node = $this->{$childNodes} ? $this->{$childNodes}->RemoveLast() : undef) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
166 $node->_setParent(undef);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
167 return $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
168 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
169 return undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
170 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
171 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
172
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
173 sub removeSelected {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
174 my ($this,$query) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
175
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
176 my @newSet;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
177 my @result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
178
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
179 if (ref $query eq 'CODE') {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
180 &$query($_) ? push @result, $_ : push @newSet, $_ foreach @{$this->childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
181 } elsif (defined $query) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
182 $_->nodeName eq $query ? push @result, $_ : push @newSet, $_ foreach @{$this->childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
183 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
184 my $children = $this->childNodes;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
185 $_->_setParent(undef) foreach @$children;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
186 delete $this->{$childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
187 return wantarray ? @$children : $children;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
188 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
189
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
190 $_->_setParent(undef) foreach @result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
191
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
192 $this->{$childNodes} = @newSet ? bless \@newSet ,'IMPL::Object::List' : undef;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
193
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
194 return wantarray ? @result : \@result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
195 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
196
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
197 sub resolveAxis {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
198 my ($this,$axis) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
199 return $Axes{$axis}->($this)
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
200 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
201
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
202 sub selectNodes {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
203 my $this = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
204 my $path;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
205
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
206 if (@_ == 1) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
207 $path = $this->translatePath($_[0]);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
208 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
209 $path = [@_];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
210 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
211
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
212 my @set = ($this);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
213
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
214 while (@$path) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
215 my $query = shift @$path;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
216 @set = map $_->selectNodesAxis($query), @set;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
217 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
218
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
219 return wantarray ? @set : \@set;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
220 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
221
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
222 sub selectSingleNode {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
223 my $this = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
224 my @result = $this->selectNodes(@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
225 return $result[0];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
226 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
227
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
228 sub selectNodesRef {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
229 my $this = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
230
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
231 my @result = $this->selectNodes(@_);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
232 return \@result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
233 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
234
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
235 sub translatePath {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
236 my ($this,$path) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
237
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
238 # TODO: Move path compilation here from IMPL::DOM::Schema::Validator::Compare
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
239 return [$path];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
240 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
241
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
242 sub selectNodesAxis {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
243 my ($this,$query,$axis) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
244
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
245 $axis ||= 'child';
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
246
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
247 die new IMPL::InvalidOperationException('Unknown axis',$axis) unless exists $Axes{$axis};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
248
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
249 my $nodes = $this->resolveAxis($axis);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
250
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
251 my @result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
252
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
253 if (ref $query eq 'CODE') {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
254 @result = grep &$query($_), @{$nodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
255 } elsif (ref $query eq 'ARRAY' ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
256 my %keys = map (($_,1),@$query);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
257 @result = grep $keys{$_->nodeName}, @{$nodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
258 } elsif (ref $query eq 'HASH') {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
259 while( my ($axis,$filter) = each %$query ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
260 push @result, $this->selectNodesAxis($filter,$axis);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
261 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
262 } elsif (defined $query) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
263 @result = grep $_->nodeName eq $query, @{$nodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
264 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
265 return wantarray ? @{$nodes} : $nodes;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
266 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
267
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
268 return wantarray ? @result : \@result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
269 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
270
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
271 sub selectParent {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
272 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
273
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
274 if ($this->parentNode) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
275 return wantarray ? $this->parentNode : [$this->parentNode];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
276 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
277 return wantarray ? () : [];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
278 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
279 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
280
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
281 sub selectSiblings {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
282 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
283
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
284 if ($this->parentNode) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
285 return $this->parentNode->selectNodes( sub { $_ != $this } );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
286 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
287 return wantarray ? () : [];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
288 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
289 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
290
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
291 sub selectDocument {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
292 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
293
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
294 if ($this->document) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
295 return wantarray ? $this->document : [$this->document];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
296 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
297 return wantarray ? () : [];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
298 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
299 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
300
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
301 sub selectDescendant {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
302 wantarray ?
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
303 map $_->selectAll(), $_[0]->childNodes :
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
304 [map $_->selectAll(), $_[0]->childNodes]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
305 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
306
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
307 sub selectAll {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
308 map(selectAll($_),@{$_[0]->childNodes}) , $_[0]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
309 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
310
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
311 sub selectAncestors {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
312 my $parent = $_[0]->parentNode;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
313
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
314 wantarray ?
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
315 ($parent ? ($parent->selectAncestors,$parent) : ()) :
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
316 [$parent ? ($parent->selectAncestors,$parent) : ()]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
317 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
318
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
319 sub firstChild {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
320 @_ >=2 ? $_[0]->replaceNodeAt(0,$_[1]) : $_[0]->childNodes->[0];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
321 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
322
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
323 sub _getIsComplex {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
324 ($_[0]->{$childNodes} and $_[0]->{$childNodes}->Count) ? 1 : 0;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
325 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
326
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
327 sub _updateDocRefs {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
328 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
329
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
330 # this method is called by the parent node on his children, so we need no to check parent
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
331 $this->{$document} = $this->{$parentNode}->document;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
332
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
333 # prevent cyclic
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
334 weaken($this->{$document}) if $this->{$document};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
335
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
336 map $_->_updateDocRefs, @{$this->{$childNodes}} if $this->{$childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
337 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
338
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
339 sub _setParent {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
340 my ($this,$node) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
341
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
342
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
343 if (($node || 0) != ($this->{$parentNode} || 0)) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
344 my $newOwner;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
345 if ($node) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
346 $this->{$parentNode} = $node;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
347 $newOwner = $node->document || 0;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
348
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
349 # prevent from creating cyclicreferences
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
350 weaken($this->{$parentNode});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
351
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
352 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
353 delete $this->{$parentNode};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
354
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
355 #keep document
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
356 $newOwner = $this->{$document};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
357 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
358
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
359 if (($this->{$document}||0) != $newOwner) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
360 $this->{$document} = $newOwner;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
361 weaken($this->{$document}) if $newOwner;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
362 $_->_updateDocRefs foreach @{$this->childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
363 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
364 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
365 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
366
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
367 sub text {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
368 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
369
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
370 join ('', $this->nodeValue || '', map ($_->text || '', @{$this->childNodes}));
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
371 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
372
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
373 sub nodeProperty {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
374 my $this = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
375 my $name = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
376
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
377 return unless defined $name;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
378
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
379 if (my $method = $this->can($name)) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
380 unshift @_,$this;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
381 # use goto to preserve calling context
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
382 goto &$method;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
383 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
384 # dynamic property
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
385 if (@_) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
386 # set
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
387 return $this->{$_propertyMap}{$name} = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
388 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
389 return $this->{$_propertyMap}{$name};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
390 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
391 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
392
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
393 sub listProperties {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
394 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
395
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
396 my %props = map {$_->name, 1} $this->GetMeta(PropertyInfo, sub { $_->attributes->{dom} },1);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
397
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
398 return (keys %props,keys %{$this->{$_propertyMap}});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
399 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
400
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
401 sub save {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
402 my ($this,$writer) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
403
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
404 if ( not ( $this->isComplex or defined $this->{$nodeValue} ) ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
405 $writer->emptyTag(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
406 $this->{$nodeName},
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
407 map {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
408 $_,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
409 $this->nodeProperty($_)
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
410 } grep defined $this->nodeProperty($_), $this->listProperties
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
411 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
412 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
413 $writer->startTag(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
414 $this->{$nodeName},
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
415 map {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
416 $_,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
417 $this->nodeProperty($_)
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
418 } grep defined $this->nodeProperty($_), $this->listProperties
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
419 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
420 $writer->characters($this->{$nodeValue}) if $this->{$nodeValue};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
421
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
422 $_->save($writer) foreach $this->childNodes;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
423
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
424 $writer->endTag($this->{$nodeName});
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
425 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
426 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
427
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
428 sub qname {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
429 $_[0]->{$nodeName};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
430 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
431
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
432 sub path {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
433 my ($this) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
434
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
435 if ($this->parentNode) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
436 return $this->parentNode->path.'.'.$this->qname;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
437 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
438 return $this->qname;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
439 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
440 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
441
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
442 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
443
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
444 __END__
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
445
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
446 =pod
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
447
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
448 =head1 NAME
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
449
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
450 C<IMPL::DOM::Node> Элемент DOM модели
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
451
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
452 =head1 DESCRIPTION
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
453
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
454 Базовый узел DOM модели. От него можно наследовать другие элементы DOM модели.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
455
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
456 =head1 MEMBERS
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
457
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
458 =head2 PROPERTIES
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
459
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
460 =over
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
461
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
462 =item C<[get] nodeName>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
463
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
464 Имя узла. Задается при создании.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
465
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
466 =item C<[get] document>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
467
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
468 Документ к которому принадлежит узел. Задается при поздании узла.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
469
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
470 =item C<[get] isComplex>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
471
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
472 Определяет является ли узел сложным (тоесть есть ли дети).
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
473
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
474 C<true> - есть, C<false> - нет.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
475
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
476 =item C<[get,set] nodeValue>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
477
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
478 Значение узла, обычно простой скаляр, но ничто не мешает туда
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
479 устанавливать любое значение.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
480
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
481 =item C<[get,list] childNodes>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
482
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
483 Список детей, является списокм C<IMPL::Object::List>.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
484
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
485 =item C<[get] parentNode>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
486
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
487 Ссылка на родительский элемент, если таковой имеется.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
488
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
489 =item C<[get] schemaType>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
490
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
491 Ссылка на узел из C<IMPL::DOM::Schema>, представляющий схему данных текущего узла. Может быть C<undef>.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
492
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
493 =item C<[get] schemaNode>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
494
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
495 Ссылка на узел из C<IMPL::DOM::Schema>, представляющий элемент схемы, объявляющий данный узел. Может быть C<undef>.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
496
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
497 Отличается от свойства C<schemaType> тем, что узел в случае ссылки на тип узла, данной свойство будет содержать
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
498 описание ссылки C<IMPL::DOM::Schema::Node>, а свойство C<schema> например будет ссылаться на
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
499 C<IMPL::DOM::Schema::ComplexType>.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
500
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
501 =back
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
502
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
503 =head2 METHODS
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
504
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
505 =cut