comparison Lib/IMPL/DOM/Schema/NodeList.pm @ 102:cf3b6ef2be22

Schema beta version
author wizard
date Fri, 07 May 2010 08:05:23 +0400
parents df6b4f054957
children a4b0a819bbda
comparison
equal deleted inserted replaced
101:d8dc6cad3f55 102:cf3b6ef2be22
17 17
18 sub CTOR { 18 sub CTOR {
19 my ($this,%args) = @_; 19 my ($this,%args) = @_;
20 20
21 $this->messageUnexpected($args{messageUnexpected} || 'A %Node.nodeName% isn\'t allowed in %Node.parentNode.path%'); 21 $this->messageUnexpected($args{messageUnexpected} || 'A %Node.nodeName% isn\'t allowed in %Node.parentNode.path%');
22 $this->messageNodesRequired($args{messageNodesRequired} || 'A %Schema.name% is required in the node %Node.path%'); 22 $this->messageNodesRequired($args{messageNodesRequired} || 'A %Schema.name% is required in the node %Parent.path%');
23 } 23 }
24 24
25 sub Validate { 25 sub Validate {
26 my ($this,$node) = @_; 26 my ($this,$node) = @_;
27 27
36 while ($info and not $info->{anyNode} and $info->{nodeName} ne $child->nodeName) { 36 while ($info and not $info->{anyNode} and $info->{nodeName} ne $child->nodeName) {
37 # if possible of course :) 37 # if possible of course :)
38 return new IMPL::DOM::Schema::ValidationError ( 38 return new IMPL::DOM::Schema::ValidationError (
39 Message => $this->messageUnexpected, 39 Message => $this->messageUnexpected,
40 Node => $child, 40 Node => $child,
41 Parent => $node,
41 Schema => $info->{Schema}, 42 Schema => $info->{Schema},
42 Source => $this 43 Source => $this
43 ) if $info->{Min} > $info->{Seen}; 44 ) if $info->{Min} > $info->{Seen};
44 45
45 $info = shift @nodes; 46 $info = shift @nodes;
47 48
48 # return error if no more children allowed 49 # return error if no more children allowed
49 return new IMPL::DOM::Schema::ValidationError ( 50 return new IMPL::DOM::Schema::ValidationError (
50 Message => $this->messageUnexpected, 51 Message => $this->messageUnexpected,
51 Node => $child, 52 Node => $child,
53 Parent => $node,
52 Source => $this 54 Source => $this
53 ) unless $info; 55 ) unless $info;
54 56
55 # it's ok, we found schema element for child 57 # it's ok, we found schema element for child
56 # but it may be any node or switching node wich would not satisfy current child 58 # but it may be any node or switching node wich would not satisfy current child
69 # check count limits 71 # check count limits
70 return new IMPL::DOM::Schema::ValidationError ( 72 return new IMPL::DOM::Schema::ValidationError (
71 Error => 1, 73 Error => 1,
72 Message => $this->messageUnexpected, 74 Message => $this->messageUnexpected,
73 Node => $child, 75 Node => $child,
76 Parent => $node,
74 Source => $this, 77 Source => $this,
75 ) if $info->{Max} and $info->{Seen} > $info->{Max}; 78 ) if $info->{Max} and $info->{Seen} > $info->{Max};
76 } 79 }
77 80
78 # no more children left (but may be should :) 81 # no more children left (but may be should :)
79 while ($info) { 82 while ($info) {
80 return new IMPL::DOM::Schema::ValidationError ( 83 return new IMPL::DOM::Schema::ValidationError (
81 Error => 1, 84 Error => 1,
82 Message => $this->messageNodesRequired, 85 Message => $this->messageNodesRequired,
83 Source => $this, 86 Source => $this,
87 Parent => $node,
84 Schema => $info->{Schema} 88 Schema => $info->{Schema}
85 ) if $info->{Seen} < $info->{Min}; 89 ) if $info->{Seen} < $info->{Min};
86 90
87 $info = shift @nodes; 91 $info = shift @nodes;
88 } 92 }