Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Schema/NodeSet.pm @ 24:7f00786f8210
Первая рабочая реазизация схемы и навигаторов
author | Sergey |
---|---|
date | Mon, 05 Oct 2009 00:48:49 +0400 |
parents | 267460284fb3 |
children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
23:716b287d4795 | 24:7f00786f8210 |
---|---|
18 sub CTOR { | 18 sub CTOR { |
19 my ($this,%args) = @_; | 19 my ($this,%args) = @_; |
20 | 20 |
21 $this->messageMax( $args{messageMax} || 'Too many %Node.nodeName% nodes'); | 21 $this->messageMax( $args{messageMax} || 'Too many %Node.nodeName% nodes'); |
22 $this->messageMin( $args{messageMin} || '%Schema.name% nodes expected'); | 22 $this->messageMin( $args{messageMin} || '%Schema.name% nodes expected'); |
23 $this->messageUnexpected( $args{messageUnexpected} || 'A %Node.nodeName% isn\'t allowed here'); | 23 $this->messageUnexpected( $args{messageUnexpected} || 'A %Node.nodeName% isn\'t allowed in %Node.parentNode.path%'); |
24 } | 24 } |
25 | 25 |
26 sub Validate { | 26 sub Validate { |
27 my ($this,$node) = @_; | 27 my ($this,$node) = @_; |
28 | 28 |
39 } | 39 } |
40 | 40 |
41 foreach my $child ( @{$node->childNodes} ) { | 41 foreach my $child ( @{$node->childNodes} ) { |
42 if (my $info = $nodes{$child->nodeName} || $anyNode) { | 42 if (my $info = $nodes{$child->nodeName} || $anyNode) { |
43 $info->{Seen}++; | 43 $info->{Seen}++; |
44 push @errors,new IMPL::DOM::Schema::VaidationError ( | 44 push @errors,new IMPL::DOM::Schema::ValidationError ( |
45 Source => $this, | 45 Source => $this, |
46 Node => $child, | 46 Node => $child, |
47 Schema => $info->{Schema}, | 47 Schema => $info->{Schema}, |
48 Message => $this->messageMax | 48 Message => $this->messageMax |
49 ) if ($info->{Max} and $info->{Seen} > $info->{Max}); | 49 ) if ($info->{Max} and $info->{Seen} > $info->{Max}); |
50 | 50 |
51 if (my @localErrors = $info->{Schema}->Validate($child)) { | 51 if (my @localErrors = $info->{Schema}->Validate($child)) { |
52 push @errors,@localErrors; | 52 push @errors,@localErrors; |
53 } | 53 } |
54 } else { | 54 } else { |
55 push @errors, new IMPL::DOM::Schema::VaidationError ( | 55 push @errors, new IMPL::DOM::Schema::ValidationError ( |
56 Source => $this, | 56 Source => $this, |
57 Node => $child, | 57 Node => $child, |
58 Schema => $info->{Schema}, | 58 Schema => $info->{Schema}, |
59 Message => $this->messageUnexpected | 59 Message => $this->messageUnexpected |
60 ) | 60 ) |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 foreach my $info (values %nodes) { | 64 foreach my $info (values %nodes) { |
65 push @errors, new IMPL::DOM::Schema::VaidationError ( | 65 push @errors, new IMPL::DOM::Schema::ValidationError ( |
66 Source => $this, | 66 Source => $this, |
67 Schema => $info->{Schema}, | 67 Schema => $info->{Schema}, |
68 Node => $node, | 68 Node => $node, |
69 Message => $this->messageMin | 69 Message => $this->messageMin |
70 ) if $info->{Min} > $info->{Seen}; | 70 ) if $info->{Min} > $info->{Seen}; |