Mercurial > pub > Impl
diff Lib/IMPL/DOM/Schema/Validator/Compare.pm @ 266:89179bb8c388
*corrected TTView to handle plain (and undefined) values
*added URL generating methods to Application::Action
*fixed the compare validatior for schemas
author | cin |
---|---|
date | Mon, 14 Jan 2013 03:10:06 +0400 |
parents | b8c724f6de36 |
children | 5aff94ba842f |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema/Validator/Compare.pm Thu Jan 10 03:25:02 2013 +0400 +++ b/Lib/IMPL/DOM/Schema/Validator/Compare.pm Mon Jan 14 03:10:06 2013 +0400 @@ -13,6 +13,7 @@ public property optional => prop_all; private property _pathTranslated => prop_all; private property _targetNode => prop_all; + private property _sourceSchema => prop_all; public property message => prop_all; } @@ -68,11 +69,13 @@ if ($filter =~ /^\w+|\*$/ ) { $query = $filter eq '*' ? undef : $filter; - } elsif ( $filter =~ /^(\w+|\*)\s*((?:\[\s*\w+\s*(?:=|!=|=~|!~|eq|ne|lt|gt|)\s*["'](?:[\\'"]|\\[\\"'])*["']\])+)$/) { + } elsif ( $filter =~ /^(\w+|\*)\s*((?:\[\s*\w+\s*(?:=|!=|=~|!~|eq|ne|lt|gt)\s*["'](?:[^\\'"]|\\[\\"'])*["']\])+)$/) { my ($nodeName,$filterArgs) = ($1,$2); + my @parsedFilters = map { - my ($prop,$op,$value) = ($_ =~ /\s*(\w+)\s*(=|!=|=~|!~)\s*(["'](?:[\\'"]|\\[\\"'])*["'])/); + my ($prop,$op,$value) = ($_ =~ /\s*(\w+)\s*(=|!=|=~|!~|eq|ne|lt|gt)\s*(?:["']((?:[^\\'"]|\\[\\"'])*)["'])/); + $value =~ s/\\[\\'"]/$1/g; { prop => $prop, @@ -89,10 +92,13 @@ _resovleProperty($node,$_->{prop}), FormatMessage($_->{value},{ Schema => $this->parentNode, - Node => $this->_targetNode + Node => $this->_targetNode, + schema => $this->parentNode, + node => $this->_targetNode, + source => $this->_sourceSchema },\&_resovleProperty) ) or return 0 foreach @parsedFilters; - + return 1; }; } else { die new IMPL::Exception("Invalid query syntax",$path,$chunk); @@ -111,13 +117,17 @@ my @result; + my $Source = $ctx && $ctx->{Source} || $this->parentNode; + + $this->_sourceSchema($Source); + $this->_targetNode($node); my $query = $this->_pathTranslated() || $this->_pathTranslated($this->TranslatePath($this->nodePath)); my ($foreignNode) = $node->selectNodes(@$query); - my $Source = $ctx && $ctx->{Source} || $this->parentNode; + if ($foreignNode) { my $value = $this->nodeValue; @@ -147,6 +157,7 @@ } $this->_targetNode(undef); + $this->_sourceSchema(undef); return @result; }