Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/Validator/Compare.pm @ 108:c6fb6964de4c
Removed absolute modules
Updated DOM model, selectNodes can now select a complex path
Web DOM model release candidate
author | wizard |
---|---|
date | Fri, 14 May 2010 16:06:06 +0400 |
parents | 196bf443b5e1 |
children | a4b0a819bbda |
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 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
4 use base qw(IMPL::DOM::Schema::Validator); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
5 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
6 use IMPL::Resources::Format qw(FormatMessage); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
7 use IMPL::Class::Property; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
8 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
9 BEGIN { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
10 public property targetProperty => prop_all; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
11 public property op => prop_all; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
12 public property nodePath => prop_get | owner_set; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
13 public property optional => prop_all; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
14 private property _pathTranslated => prop_all; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
15 private property _targetNode => prop_all; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
16 public property message => prop_all; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
17 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
18 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
19 our %CTOR = ( |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
20 'IMPL::DOM::Schema::Validator' => sub { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
21 my %args = @_; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
22 $args{nodeName} ||= 'Compare'; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
23 %args; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
24 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
25 ); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
26 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
27 our %Ops = ( |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
28 '=' => \&_equals, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
29 'eq' => \&_equalsString, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
30 '!=' => \&_notEquals, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
31 'ne' => \&_notEqualsString, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
32 '=~' => \&_matchRx, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
33 '!~' => \&_notMatchRx, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
34 '<' => \&_less, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
35 '>' => \&_greater, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
36 'lt' => \&_lessString, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
37 'gt' => \&_greaterString |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
38 ); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
39 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
40 my $rxOps = map qr/$_/, join( '|', keys %Ops ); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
41 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
42 sub CTOR { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
43 my ($this,%args) = @_; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
44 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
45 $this->targetProperty($args{targetProperty} || 'nodeValue'); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
46 $this->op( $Ops{ $args{op} || '=' } ) or die new IMPL::InvalidArgumentException("Invalid parameter value",'op',$args{op},$this->path); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
47 $this->nodePath($args{nodePath}) or die new IMPL::InvalidArgumentException("The argument is required", 'nodePath', $this->path); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
48 $this->message($args{message} || 'The value of %Node.path% %Source.op% %Value% (%Source.nodePath%)' ); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
49 $this->optional($args{optional}) if $args{optional}; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
50 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
51 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
52 sub TranslatePath { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
53 my ($this,$path) = @_; |
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 $path ||= ''; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
56 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
57 my @selectQuery; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
58 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
59 my $i = 0; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
60 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
61 foreach my $chunk (split /\//,$path) { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
62 $chunk = 'document:*' if $i == 0 and not length $chunk; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
63 next if not length $chunk; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
64 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
65 my $query; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
66 my ($axis,$filter) = ( $chunk =~ /^(?:(\w+):)?(.*)$/); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
67 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
68 if ($filter =~ /^\w+|\*$/ ) { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
69 $query = $filter eq '*' ? undef : $filter; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
70 } elsif ( $filter =~ /^(\w+|\*)\s*((?:\[\s*\w+\s*(?:=|!=|=~|!~|eq|ne|lt|gt|)\s*["'](?:[\\'"]|\\[\\"'])*["']\])+)$/) { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
71 my ($nodeName,$filterArgs) = ($1,$2); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
72 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
73 my @parsedFilters = map { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
74 my ($prop,$op,$value) = ($_ =~ /\s*(\w+)\s*(=|!=|=~|!~)\s*(["'](?:[\\'"]|\\[\\"'])*["'])/); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
75 $value =~ s/\\[\\'"]/$1/g; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
76 { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
77 prop => $prop, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
78 op => $Ops{$op}, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
79 value => $value |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
80 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
81 } grep ( $_, split ( /[\]\[]+/,$filterArgs ) ); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
82 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
83 $query = sub { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
84 my ($node) = shift; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
85 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
86 $node->nodeName eq $nodeName or return 0 if $nodeName ne '*'; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
87 $_->{op}->( |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
88 _resovleProperty($node,$_->{prop}), |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
89 FormatMessage($_->{value},{ |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
90 Schema => $this->parentNode, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
91 Node => $this->_targetNode |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
92 },\&_resovleProperty) |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
93 ) or return 0 foreach @parsedFilters; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
94 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
95 }; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
96 } else { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
97 die new IMPL::Exception("Invalid query syntax",$path,$chunk); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
98 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
99 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
100 push @selectQuery, $axis ? { $axis => $query } : $query; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
101 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
102 $i++; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
103 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
104 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
105 return \@selectQuery; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
106 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
107 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
108 sub Validate { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
109 my ($this,$node,$ctx) = @_; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
110 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
111 my @result; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
112 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
113 $this->_targetNode($node); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
114 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
115 my $query = $this->_pathTranslated() || $this->_pathTranslated($this->TranslatePath($this->nodePath)); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
116 |
108 | 117 my ($foreignNode) = $node->selectNodes($query); |
104
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 my $Source = $ctx && $ctx->{Source} || $this->parentNode; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
120 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
121 if ($foreignNode) { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
122 my $value = $this->nodeValue; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
123 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
124 if ($value) { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
125 $value = FormatMessage($value, { Schema => $this->parentNode, Node => $this->_targetNode, ForeignNode => $foreignNode },\&_resovleProperty); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
126 } else { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
127 $value = $foreignNode->nodeValue; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
128 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
129 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
130 push @result, new IMPL::DOM::Schema::ValidationError( |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
131 Node => $node, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
132 ForeignNode => $foreignNode, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
133 Value => $value, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
134 Source => $Source, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
135 Schema => $this->parentNode, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
136 Message => $this->message |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
137 ) unless $this->op->(_resovleProperty($node,$this->targetProperty),$value); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
138 } elsif (not $this->optional) { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
139 push @result, new IMPL::DOM::Schema::ValidationError( |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
140 Node => $node, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
141 Value => '', |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
142 Source => $Source, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
143 Schema => $this->parentNode, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
144 Message => $this->message |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
145 ); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
146 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
147 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
148 $this->_targetNode(undef); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
149 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
150 return @result; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
151 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
152 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
153 sub _resovleProperty { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
154 my ($node,$prop) = @_; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
155 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
156 return $node->can($prop) ? $node->$prop() : $node->nodeProperty($prop); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
157 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
158 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
159 sub _matchRx { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
160 $_[0] =~ $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
161 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
162 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
163 sub _notMatchRx { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
164 $_[0] !~ $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
165 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
166 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
167 sub _equals { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
168 $_[0] == $_[1]; |
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 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
171 sub _notEquals { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
172 $_[0] != $_[0]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
173 } |
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 sub _equalsString { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
176 $_[0] eq $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
177 } |
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 sub _notEqualsString { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
180 $_[0] ne $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
181 } |
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 sub _less { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
184 $_[0] < $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
185 } |
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 sub _greater { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
188 $_[0] > $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
189 } |
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 sub _lessString { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
192 $_[0] lt $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
193 } |
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 sub _greaterString { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
196 $_[0] gt $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
197 } |
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 sub _lessEq { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
200 $_[0] <= $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
201 } |
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 sub _greaterEq { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
204 $_[0] >= $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
205 } |
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 1; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
208 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
209 __END__ |
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 =pod |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
212 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
213 =head1 NAME |
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 C<IMPL::DOM::Schema::Validator::Compare> - ограничение на содержимое текущего узла, |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
216 сравнивая его со значением другого узла. |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
217 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
218 =head1 SYNOPSIS |
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 Пример типа описания поля с проверочным полем |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
221 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
222 =begin code xml |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
223 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
224 <schema> |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
225 <SimpleType type="retype_field"> |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
226 <Property name="linkedNode" message="Для узла %Node.nodeName% необходимо задать свойство %Source.name%"/> |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
227 <Compare op="eq" nodePath="sibling:*[nodeName eq '%Node.linkedNode%']"/> |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
228 </SimpleType> |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
229 </schema> |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
230 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
231 =begin code xml |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
232 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
233 =head1 DESCRIPTION |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
234 |
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 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
diff
changeset
|
237 =cut |