Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Schema/SimpleNode.pm @ 104:196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
Minor and major fixes almost for everything.
A 'Source' property of the ValidationErrors generated from a NodeSet or a NodeList is subject to change in the future.
author | wizard |
---|---|
date | Tue, 11 May 2010 02:42:59 +0400 |
parents | c289ed9662ca |
children | e30bdd040fe3 |
comparison
equal
deleted
inserted
replaced
103:c289ed9662ca | 104:196bf443b5e1 |
---|---|
6 use IMPL::Class::Property; | 6 use IMPL::Class::Property; |
7 use IMPL::Class::Property::Direct; | 7 use IMPL::Class::Property::Direct; |
8 | 8 |
9 BEGIN { | 9 BEGIN { |
10 public _direct property inflator => prop_get; | 10 public _direct property inflator => prop_get; |
11 public _direct property messageInflateError => prop_get; | |
11 } | 12 } |
12 | 13 |
13 our %CTOR = ( | 14 our %CTOR = ( |
14 'IMPL::DOM::Schema::Node' => sub {my %args = @_; $args{nodeName} ||= 'SimpleNode'; %args} | 15 'IMPL::DOM::Schema::Node' => sub {my %args = @_; $args{nodeName} ||= 'SimpleNode'; %args} |
15 ); | 16 ); |
16 | 17 |
17 sub CTOR { | 18 sub CTOR { |
18 my ($this,%args) = @_; | 19 my ($this,%args) = @_; |
19 | 20 |
20 $this->{$inflator} = $args{inflator} if $args{iflator}; | 21 $this->{$inflator} = $args{inflator} if $args{inflator}; |
22 $this->{$messageInflateError} = $args{messageInflateError} || 'Failed to inflate nodeValue %Node.path%: %Error%'; | |
21 } | 23 } |
22 | 24 |
23 sub Validate { | 25 sub Validate { |
24 my ($this,$node) = @_; | 26 my ($this,$node,$ctx) = @_; |
25 | 27 |
26 return map $_->Validate($node), @{$this->childNodes}; | 28 my @result; |
29 | |
30 push @result, $_->Validate($node,$ctx) foreach $this->childNodes; | |
31 | |
32 return @result; | |
33 } | |
34 | |
35 sub inflateValue { | |
36 my ($this,$value) = @_; | |
37 | |
38 if ( my $inflator = $this->inflator ) { | |
39 return $inflator->new($value); | |
40 } else { | |
41 return $value; | |
42 } | |
27 } | 43 } |
28 | 44 |
29 1; | 45 1; |
30 | 46 |
31 __END__ | 47 __END__ |