annotate lib/IMPL/DOM/Schema/Validator/Compare.pm @ 417:3ed0c58e9da3 ref20150831

working on di container, tests
author cin
date Mon, 02 Nov 2015 01:56:53 +0300
parents c6e90e02dd17
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::Schema::Validator::Compare;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4 use IMPL::Const qw(:prop);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6 require => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 Label => 'IMPL::DOM::Schema::Label',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8 ValidationError => 'IMPL::DOM::Schema::ValidationError'
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 },
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 base => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 'IMPL::DOM::Schema::Validator' => sub {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 my %args = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13 $args{nodeName} ||= 'Compare';
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14 delete @args{qw(targetProperty op nodePath optional message)};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 %args;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17 ],
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 props => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 targetProperty => PROP_RW,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 op => PROP_RW,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21 nodePath => PROP_RW,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 optional => PROP_RW,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23 _pathTranslated => PROP_RW,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 _targetNode => PROP_RW,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25 _schemaNode => PROP_RW,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 message => PROP_RW
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 ]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 use IMPL::Resources::Format qw(FormatMessage);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31 our %Ops = (
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32 '=' => \&_equals,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 'eq' => \&_equalsString,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
34 '!=' => \&_notEquals,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
35 'ne' => \&_notEqualsString,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
36 '=~' => \&_matchRx,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
37 '!~' => \&_notMatchRx,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
38 '<' => \&_less,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
39 '>' => \&_greater,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
40 'lt' => \&_lessString,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
41 'gt' => \&_greaterString
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
42 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
43
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
44 my $rxOps = map qr/$_/, join( '|', keys %Ops );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
45
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
46 sub CTOR {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
47 my ($this,%args) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
48
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
49 $this->targetProperty($args{targetProperty} || 'nodeValue');
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
50 $this->op( $Ops{ $args{op} || '=' } ) or die new IMPL::InvalidArgumentException("Invalid parameter value",'op',$args{op},$this->path);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
51 $this->nodePath($args{nodePath}) or die new IMPL::InvalidArgumentException("The argument is required", 'nodePath', $this->path);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
52 $this->message($args{message} || 'The value of %node.path% %schemaNode.op% %value% (%schemaNode.nodePath%)' );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
53 $this->optional($args{optional}) if $args{optional};
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 TranslatePath {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
57 my ($this,$path) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
58
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
59 $path ||= '';
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
60
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
61 my @selectQuery;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
62
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
63 my $i = 0;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
64
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
65 foreach my $chunk (split /\//,$path) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
66 $chunk = 'document:*' if $i == 0 and not length $chunk;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
67 next if not length $chunk;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
68
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
69 my $query;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
70 my ($axis,$filter) = ( $chunk =~ /^(?:(\w+):)?(.*)$/);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
71
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
72 if ($filter =~ /^\w+|\*$/ ) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
73 $query = $filter eq '*' ? undef : $filter;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
74 } elsif ( $filter =~ /^(\w+|\*)\s*((?:\[\s*\w+\s*(?:=|!=|=~|!~|eq|ne|lt|gt)\s*["'](?:[^\\'"]|\\[\\"'])*["']\])+)$/) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
75 my ($nodeName,$filterArgs) = ($1,$2);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
76
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
77
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
78 my @parsedFilters = map {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
79 my ($prop,$op,$value) = ($_ =~ /\s*(\w+)\s*(=|!=|=~|!~|eq|ne|lt|gt)\s*(?:["']((?:[^\\'"]|\\[\\"'])*)["'])/);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
80
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
81 $value =~ s/\\[\\'"]/$1/g;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
82 {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
83 prop => $prop,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
84 op => $Ops{$op},
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
85 value => $value
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
86 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
87 } grep ( $_, split ( /[\]\[]+/,$filterArgs ) );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
88
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
89 $query = sub {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
90 my ($node) = shift;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
91
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
92 $node->nodeName eq $nodeName or return 0 if $nodeName ne '*';
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
93 $_->{op}->(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
94 _resovleProperty($node,$_->{prop}),
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
95 FormatMessage($_->{value},{
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
96 Schema => $this->parentNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
97 Node => $this->_targetNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
98 schema => $this->parentNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
99 schemaType => $this->parentNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
100 node => $this->_targetNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
101 source => $this->_schemaNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
102 schemaNode => $this->_schemaNode
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
103 },\&_resovleProperty)
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
104 ) or return 0 foreach @parsedFilters;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
105 return 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
106 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
107 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
108 die new IMPL::Exception("Invalid query syntax",$path,$chunk);
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 push @selectQuery, $axis ? { $axis => $query } : $query;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
112
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
113 $i++;
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 return \@selectQuery;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
117 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
118
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
119 sub Validate {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
120 my ($this,$node,$ctx) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
121
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
122 my @result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
123
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
124 my $schemaNode = $ctx->{schemaNode};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
125 my $schemaType = $ctx->{schemaType};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
126
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
127 $this->_schemaNode($schemaNode);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
128
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
129 $this->_targetNode($node);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
130
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
131 my $query = $this->_pathTranslated() || $this->_pathTranslated($this->TranslatePath($this->nodePath));
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
132
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
133 my ($foreignNode) = $node->selectNodes(@$query);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
134
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
135
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
136
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
137 if ($foreignNode) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
138 my $value = $this->nodeValue;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
139
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
140 if ($value) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
141 $value = FormatMessage($value, { Schema => $this->parentNode, Node => $this->_targetNode, ForeignNode => $foreignNode },\&_resovleProperty);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
142 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
143 $value = $foreignNode->nodeValue;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
144 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
145
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
146 push @result, ValidationError->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
147 node => $node,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
148 foreignNode => $foreignNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
149 value => $value,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
150 schemaNode => $schemaNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
151 schemaType => $schemaType,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
152 message => $this->_MakeLabel($this->message)
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
153 ) unless $this->op->(_resovleProperty($node,$this->targetProperty),$value);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
154 } elsif (not $this->optional) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
155 push @result, ValidationError->new(
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
156 node => $node,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
157 value => '',
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
158 schemaNode => $schemaNode,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
159 schemaType => $schemaType,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
160 message => $this->_MakeLabel( $this->message )
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
161 );
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
162 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
163
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
164 $this->_targetNode(undef);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
165 $this->_schemaNode(undef);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
166
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
167 return @result;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
168 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
169
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
170 sub _resovleProperty {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
171 my ($node,$prop) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
172
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
173 return $node->can($prop) ? $node->$prop() : $node->nodeProperty($prop);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
174 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
175
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
176 sub _matchRx {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
177 $_[0] =~ $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
178 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
179
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
180 sub _notMatchRx {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
181 $_[0] !~ $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
182 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
183
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
184 sub _equals {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
185 $_[0] == $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
186 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
187
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
188 sub _notEquals {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
189 $_[0] != $_[0];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
190 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
191
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
192 sub _equalsString {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
193 $_[0] eq $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
194 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
195
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
196 sub _notEqualsString {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
197 $_[0] ne $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
198 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
199
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
200 sub _less {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
201 $_[0] < $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
202 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
203
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
204 sub _greater {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
205 $_[0] > $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
206 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
207
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
208 sub _lessString {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
209 $_[0] lt $_[1];
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 sub _greaterString {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
213 $_[0] gt $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
214 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
215
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
216 sub _lessEq {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
217 $_[0] <= $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
218 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
219
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
220 sub _greaterEq {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
221 $_[0] >= $_[1];
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
222 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
223
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
224 sub _MakeLabel {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
225 my ($this,$label) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
226
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
227 if ($label =~ /^ID:(\w+)$/) {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
228 return Label->new($this->document->stringMap, $1);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
229 } else {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
230 return $label;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
231 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
232 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
233
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
234 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
235
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
236 __END__
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
237
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
238 =pod
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
239
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
240 =head1 NAME
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
241
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
242 C<IMPL::DOM::Schema::Validator::Compare> - ограничение на содержимое текущего узла,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
243 сравнивая его со значением другого узла.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
244
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
245 =head1 SYNOPSIS
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
246
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
247 Пример типа описания поля с проверочным полем
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
248
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
249 =begin code xml
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
250
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
251 <schema>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
252 <SimpleType type="retype_field">
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
253 <Property name="linkedNode" message="Для узла %node.nodeName% необходимо задать свойство %schemaNode.name%"/>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
254 <Compare op="eq" nodePath="sibling:*[nodeName eq '%node.linkedNode%']"/>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
255 </SimpleType>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
256 </schema>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
257
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
258 =begin code xml
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
259
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
260 =head1 DESCRIPTION
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
261
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
262 Позволяет сравнивать значение текущего узла со значением другого узла.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
263
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
264 =cut