comparison Lib/IMPL/DOM/Schema/NodeSet.pm @ 20:267460284fb3

DOM Schema
author Sergey
date Tue, 22 Sep 2009 17:17:38 +0400
parents 1ca530e5c9c5
children 7f00786f8210
comparison
equal deleted inserted replaced
19:1ca530e5c9c5 20:267460284fb3
17 17
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.nodeName% 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 here');
24 } 24 }
25 25
26 sub Validate { 26 sub Validate {
27 my ($this,$node) = @_; 27 my ($this,$node) = @_;
32 my $anyNode; 32 my $anyNode;
33 foreach (@{$this->childNodes}) { 33 foreach (@{$this->childNodes}) {
34 if ($_->isa('IMPL::DOM::Schema::AnyNode')) { 34 if ($_->isa('IMPL::DOM::Schema::AnyNode')) {
35 $anyNode = {Schema => $_, Min => $_->minOccur, Max => $_->maxOccur eq 'unbounded' ? undef : $_->maxOccur , Seen => 0 }; 35 $anyNode = {Schema => $_, Min => $_->minOccur, Max => $_->maxOccur eq 'unbounded' ? undef : $_->maxOccur , Seen => 0 };
36 } else { 36 } else {
37 $nodes{$_->nodeName} = {Schema => $_, Min => $_->minOccur, Max => $_->maxOccur eq 'unbounded' ? undef : $_->maxOccur , Seen => 0 }; 37 $nodes{$_->name} = {Schema => $_, Min => $_->minOccur, Max => $_->maxOccur eq 'unbounded' ? undef : $_->maxOccur , Seen => 0 };
38 } 38 }
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) {