annotate Lib/IMPL/DOM/Node.pm @ 163:6ce1f052b90a

temp commit
author wizard
date Tue, 15 Mar 2011 02:32:42 +0300
parents 1e7f03414b65
children 76515373dac0
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
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
20 public _direct property parentNode => prop_get | owner_set;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
21 public _direct property schema => prop_get | owner_set;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
22 public _direct property schemaSource => prop_get | owner_set;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
23 private _direct property _propertyMap => prop_all ;
116
1722ca51537c minor changes.
wizard
parents: 113
diff changeset
24
1722ca51537c minor changes.
wizard
parents: 113
diff changeset
25 __PACKAGE__->class_data(property_bind => {});
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
26 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
27
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
28 our %Axes = (
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
29 parent => \&selectParent,
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
30 siblings => \&selectSiblings,
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
31 child => \&childNodes,
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
32 document => \&selectDocument,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
33 ancestor => \&selectAncestors,
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
34 descendant => \&selectDescendant
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
35 );
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
36
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
37 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
38 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
39
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
40 $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
41 $this->{$nodeValue} = delete $args{nodeValue} if exists $args{nodeValue};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
42 if ( exists $args{document} ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
43 $this->{$document} = delete $args{document};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
44 weaken($this->{$document});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
45 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
46
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
47 while ( my ($key,$value) = each %args ) {
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
48 $this->nodeProperty($key,$value);
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 122
diff changeset
49 }
49
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
52 sub insertNode {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
53 my ($this,$node,$pos) = @_;
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 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
56
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
57 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
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 $this->childNodes->InsertAt($pos,$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 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
62
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
63 return $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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
66 sub appendChild {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
67 my ($this,$node) = @_;
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 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
70
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
71 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
72
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
73 my $children = $this->childNodes;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
74 $children->Append($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 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
77
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
78 return $node;
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 appendNode {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
82 goto &appendChild;
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
85 sub appendRange {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
86 my ($this,@range) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
87
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
88 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
89
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
90 foreach my $node (@range) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
91 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
92 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
93 }
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 $this->childNodes->Append(@range);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
96
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
97 return $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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
100 sub _getChildNodes {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
101 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
102
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
103 $this->{$childNodes} = new IMPL::Object::List() unless $this->{$childNodes};
102
cf3b6ef2be22 Schema beta version
wizard
parents: 75
diff changeset
104 return wantarray ? @{ $this->{$childNodes} } : $this->{$childNodes};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
105 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
106
109
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
107 sub childNodesRef {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
108 my ($this) = @_;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
109 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
110 }
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
111
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
112 sub removeNode {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
113 my ($this,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
114
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
115 if ($this == $node->{$parentNode}) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
116 $this->childNodes->RemoveItem($node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
117 $node->_setParent(undef);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
118 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
119 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
120 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
121 }
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
124 sub replaceNodeAt {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
125 my ($this,$index,$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 my $nodeOld = $this->childNodes->[$index];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
128
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
129 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
130
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
131 # unlink node from previous parent
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
132 $node->{$parentNode}->removeNode($node) if ($node->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
133
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
134 # replace (or set) old node
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
135 $this->childNodes->[$index] = $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
136
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
137 # set new parent
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
138 $node->_setParent( $this );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
139
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
140 # unlink old node if we have one
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
141 $nodeOld->_setParent(undef) if $nodeOld;
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 # return old node
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
144 return $nodeOld;
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
147 sub removeAt {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
148 my ($this,$pos) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
149
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
150 if ( my $node = $this->childNodes->RemoveAt($pos) ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
151 $node->_setParent(undef);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
152 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
153 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
154 return undef;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
155 }
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
158 sub removeLast {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
159 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
160
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
161 if ( my $node = $this->{$childNodes} ? $this->{$childNodes}->RemoveLast() : undef) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
162 $node->_setParent(undef);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
163 return $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
164 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
165 return undef;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
166 }
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
169 sub removeSelected {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
170 my ($this,$query) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
171
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
172 my @newSet;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
173 my @result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
174
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
175 if (ref $query eq 'CODE') {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
176 &$query($_) ? push @result, $_ : push @newSet, $_ foreach @{$this->childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
177 } elsif (defined $query) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
178 $_->nodeName eq $query ? push @result, $_ : push @newSet, $_ foreach @{$this->childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
179 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
180 my $children = $this->childNodes;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
181 $_->_setParent(undef) foreach @$children;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
182 delete $this->{$childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
183 return wantarray ? @$children : $children;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
184 }
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 $_->_setParent(undef) foreach @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 $this->{$childNodes} = @newSet ? bless \@newSet ,'IMPL::Object::List' : undef;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
189
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
190 return wantarray ? @result : \@result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
191 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
192
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
193 sub resolveAxis {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
194 my ($this,$axis) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
195 return $Axes{$axis}->($this)
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
196 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
197
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
198 sub selectNodes {
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
199 my $this = shift;
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
200 my $path;
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
201
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
202 if (@_ == 1) {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
203 $path = $this->translatePath($_[0]);
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
204 } else {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
205 $path = [@_];
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
206 }
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
207
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
208 my @set = ($this);
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
209
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
210 while (@$path) {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
211 my $query = shift @$path;
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
212 @set = map $_->selectNodesAxis($query), @set;
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
213 }
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
214
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
215 return wantarray ? @set : \@set;
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
216 }
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
217
113
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
218 sub selectSingleNode {
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
219 my $this = shift;
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
220 my @result = $this->selectNodes(@_);
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
221 return $result[0];
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
222 }
7b14e0122b79 Updated PostToDOM transformation
wizard
parents: 109
diff changeset
223
109
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
224 sub selectNodesRef {
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
225 my $this = shift;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
226
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
227 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
228 return \@result;
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
229 }
ddf0f037d460 IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT)
wizard
parents: 108
diff changeset
230
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
231 sub translatePath {
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
232 my ($this,$path) = @_;
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
233
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
234 # TODO: Move path compilation here from IMPL::DOM::Schema::Validator::Compare
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
235 return [$path];
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
236 }
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
237
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
238 sub selectNodesAxis {
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
239 my ($this,$query,$axis) = @_;
104
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 $axis ||= 'child';
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
242
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
243 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
244
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
245 my $nodes = $this->resolveAxis($axis);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
246
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
247 my @result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
248
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
249 if (ref $query eq 'CODE') {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
250 @result = grep &$query($_), @{$nodes};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
251 } elsif (ref $query eq 'ARRAY' ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
252 my %keys = map (($_,1),@$query);
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
253 @result = grep $keys{$_->nodeName}, @{$nodes};
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
254 } elsif (ref $query eq 'HASH') {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
255 while( my ($axis,$filter) = each %$query ) {
108
c6fb6964de4c Removed absolute modules
wizard
parents: 104
diff changeset
256 push @result, $this->selectNodesAxis($filter,$axis);
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
257 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
258 } elsif (defined $query) {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
259 @result = grep $_->nodeName eq $query, @{$nodes};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
260 } else {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
261 return wantarray ? @{$nodes} : $nodes;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
262 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
263
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
264 return wantarray ? @result : \@result;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
265 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
266
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
267 sub selectParent {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
268 my ($this) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
269
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
270 if ($this->parentNode) {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
271 return wantarray ? $this->parentNode : [$this->parentNode];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
272 } else {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
273 return wantarray ? () : [];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
274 }
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
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
277 sub selectSiblings {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
278 my ($this) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
279
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
280 if ($this->parentNode) {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
281 return $this->parentNode->selectNodes( sub { $_ != $this } );
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
282 } else {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
283 return wantarray ? () : [];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
284 }
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
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
287 sub selectDocument {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
288 my ($this) = @_;
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
289
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
290 if ($this->document) {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
291 return wantarray ? $this->document : [$this->document];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
292 } else {
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
293 return wantarray ? () : [];
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
294 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
295 }
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 102
diff changeset
296
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
297 sub selectDescendant {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
298 wantarray ?
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
299 map $_->selectAll(), $_[0]->childNodes :
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
300 [map $_->selectAll(), $_[0]->childNodes]
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
301 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
302
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
303 sub selectAll {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
304 map(selectAll($_),@{$_[0]->childNodes}) , $_[0]
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
305 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
306
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
307 sub selectAncestors {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
308 my $parent = $_[0]->parentNode;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
309
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
310 wantarray ?
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
311 ($parent ? ($parent->selectAncestors,$parent) : ()) :
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
312 [$parent ? ($parent->selectAncestors,$parent) : ()]
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
313 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
314
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
315 sub firstChild {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
316 @_ >=2 ? $_[0]->replaceNodeAt(0,$_[1]) : $_[0]->childNodes->[0];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
317 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
318
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
319 sub _getIsComplex {
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
320 ($_[0]->{$childNodes} and $_[0]->{$childNodes}->Count) ? 1 : 0;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
321 }
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 sub _updateDocRefs {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
324 my ($this) = @_;
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 # 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
327 $this->{$document} = $this->{$parentNode}->document;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
328
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
329 # prevent cyclic
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
330 weaken($this->{$document}) if $this->{$document};
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 $_->_updateDocRefs foreach @{$this->{$childNodes}};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
333 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
334
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
335 sub _setParent {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
336 my ($this,$node) = @_;
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 if (($node || 0) != ($this->{$parentNode} || 0)) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
340 my $newOwner;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
341 if ($node) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
342 $this->{$parentNode} = $node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
343 $newOwner = $node->document || 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
344
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
345 # prevent from creating cyclicreferences
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
346 weaken($this->{$parentNode});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
347
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
348 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
349 delete $this->{$parentNode};
75
wizard
parents: 49
diff changeset
350
wizard
parents: 49
diff changeset
351 #keep document
wizard
parents: 49
diff changeset
352 $newOwner = $this->{$document};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
353 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
354
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
355 if (($this->{$document}||0) != $newOwner) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
356 $this->{$document} = $newOwner;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
357 weaken($this->{$document}) if $newOwner;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
358 $_->_updateDocRefs foreach @{$this->childNodes};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
359 }
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
363 sub text {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
364 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
365
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
366 join ('', $this->nodeValue || '', map ($_->text || '', @{$this->childNodes}));
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
367 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
368
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
369 sub nodeProperty {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
370 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
371 my $name = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
372
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
373 if (my $method = $this->can($name)) {
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
374 unshift @_,$this;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
375 # use goto to preserve calling context
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
376 goto &$method;
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
377 }
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
378 # dynamic property
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
379 if (@_) {
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
380 # set
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
381 return $this->{$_propertyMap}{$name} = shift;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
382 } else {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
383 return $this->{$_propertyMap}{$name};
49
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 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
386
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
387 sub listProperties {
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
388 my ($this) = @_;
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
389
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
390 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
391
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
392 return (keys %props,keys %{$this->{$_propertyMap}});
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
393 }
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 116
diff changeset
394
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
395 sub save {
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
396 my ($this,$writer) = @_;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
397
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
398 if ( not ( $this->isComplex or defined $this->{$nodeValue} ) ) {
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
399 $writer->emptyTag(
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
400 $this->{$nodeName},
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
401 map {
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
402 $_,
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
403 $this->nodeProperty($_)
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
404 } grep defined $this->nodeProperty($_), $this->listProperties
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
405 );
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
406 } else {
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
407 $writer->startTag(
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
408 $this->{$nodeName},
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
409 map {
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
410 $_,
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
411 $this->nodeProperty($_)
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
412 } grep defined $this->nodeProperty($_), $this->listProperties
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
413 );
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
414 $writer->characters($this->{$nodeValue}) if $this->{$nodeValue};
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
415
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
416 $_->save($writer) foreach $this->childNodes;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
417
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
418 $writer->endTag($this->{$nodeName});
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
419 }
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
420 }
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
421
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
422 sub qname {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
423 $_[0]->{$nodeName};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
424 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
425
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
426 sub path {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
427 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
428
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
429 if ($this->parentNode) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
430 return $this->parentNode->path.'.'.$this->qname;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
431 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
432 return $this->qname;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
433 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
434 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
435
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
436 1;
75
wizard
parents: 49
diff changeset
437
wizard
parents: 49
diff changeset
438 __END__
wizard
parents: 49
diff changeset
439
wizard
parents: 49
diff changeset
440 =pod
wizard
parents: 49
diff changeset
441
wizard
parents: 49
diff changeset
442 =head1 NAME
wizard
parents: 49
diff changeset
443
wizard
parents: 49
diff changeset
444 C<IMPL::DOM::Node> Элемент DOM модели
wizard
parents: 49
diff changeset
445
wizard
parents: 49
diff changeset
446 =head1 DESCRIPTION
wizard
parents: 49
diff changeset
447
wizard
parents: 49
diff changeset
448 Базовый узел DOM модели. От него можно наследовать другие элементы DOM модели.
wizard
parents: 49
diff changeset
449
wizard
parents: 49
diff changeset
450 =head1 MEMBERS
wizard
parents: 49
diff changeset
451
wizard
parents: 49
diff changeset
452 =head2 PROPERTIES
wizard
parents: 49
diff changeset
453
wizard
parents: 49
diff changeset
454 =over
wizard
parents: 49
diff changeset
455
wizard
parents: 49
diff changeset
456 =item C<[get] nodeName>
wizard
parents: 49
diff changeset
457
wizard
parents: 49
diff changeset
458 Имя узла. Задается при создании.
wizard
parents: 49
diff changeset
459
wizard
parents: 49
diff changeset
460 =item C<[get] document>
wizard
parents: 49
diff changeset
461
wizard
parents: 49
diff changeset
462 Документ к которому принадлежит узел. Задается при поздании узла.
wizard
parents: 49
diff changeset
463
wizard
parents: 49
diff changeset
464 =item C<[get] isComplex>
wizard
parents: 49
diff changeset
465
wizard
parents: 49
diff changeset
466 Определяет является ли узел сложным (тоесть есть ли дети).
wizard
parents: 49
diff changeset
467
wizard
parents: 49
diff changeset
468 C<true> - есть, C<false> - нет.
wizard
parents: 49
diff changeset
469
wizard
parents: 49
diff changeset
470 =item C<[get,set] nodeValue>
wizard
parents: 49
diff changeset
471
wizard
parents: 49
diff changeset
472 Значение узла, обычно простой скаляр, но ничто не мешает туда
wizard
parents: 49
diff changeset
473 устанавливать любое значение.
wizard
parents: 49
diff changeset
474
wizard
parents: 49
diff changeset
475 =item C<[get,list] childNodes>
wizard
parents: 49
diff changeset
476
wizard
parents: 49
diff changeset
477 Список детей, является списокм C<IMPL::Object::List>.
wizard
parents: 49
diff changeset
478
wizard
parents: 49
diff changeset
479 =item C<[get] parentNode>
wizard
parents: 49
diff changeset
480
wizard
parents: 49
diff changeset
481 Ссылка на родительский элемент, если таковой имеется.
wizard
parents: 49
diff changeset
482
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
483 =item C<[get] schema>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
484
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
485 Ссылка на узел из C<IMPL::DOM::Schema>, представляющий схему данных текущего узла. Может быть C<undef>.
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
486
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
487 =item C<[get] schema>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
488
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
489 Ссылка на узел из C<IMPL::DOM::Schema>, представляющий элемент схемы, объявляющий данный узел. Может быть C<undef>.
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
490
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
491 Отличается от свойства C<schema> тем, что узел в случае ссылки на тип узла, данной свойство будет содержать
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
492 описание ссылки C<IMPL::DOM::Schema::Node>, а свойство C<schema> например будет ссылаться на
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
493 C<IMPL::DOM::Schema::ComplexType>.
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
494
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
495 =back
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 124
diff changeset
496
75
wizard
parents: 49
diff changeset
497 =head2 METHODS
wizard
parents: 49
diff changeset
498
wizard
parents: 49
diff changeset
499 =cut