annotate Lib/IMPL/DOM/Schema/Validator/Compare.pm @ 396:6f2a494579cb

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