Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/SimpleNode.pm @ 245:7c517134c42f
Added Unsupported media type Web exception
corrected resourceLocation setting in the resource
Implemented localizable resources for text messages
fixed TT view scopings, INIT block in controls now sets globals correctly.
author | sergey |
---|---|
date | Mon, 29 Oct 2012 03:15:22 +0400 |
parents | b8c724f6de36 |
children | 814d755e5d12 |
rev | line source |
---|---|
49 | 1 package IMPL::DOM::Schema::SimpleNode; |
2 use strict; | |
3 use warnings; | |
4 | |
165 | 5 use parent qw(IMPL::DOM::Schema::Node); |
103 | 6 use IMPL::Class::Property; |
7 use IMPL::Class::Property::Direct; | |
152 | 8 use IMPL::DOM::Property qw(_dom); |
103 | 9 |
10 BEGIN { | |
194 | 11 public _dom _direct property inflator => prop_get; |
12 public _dom _direct property messageInflateError => prop_get; | |
103 | 13 } |
49 | 14 |
15 our %CTOR = ( | |
124 | 16 'IMPL::DOM::Schema::Node' => sub { |
194 | 17 my %args = @_; |
18 $args{nodeName} ||= 'SimpleNode'; | |
19 delete @args{qw(inflator messageInflateError)}; | |
20 %args | |
124 | 21 } |
103 | 22 ); |
23 | |
24 sub CTOR { | |
194 | 25 my ($this,%args) = @_; |
26 | |
27 if ( $args{inflator} ) { | |
28 $this->{$inflator} = $args{inflator} ; | |
238 | 29 $this->{$messageInflateError} = exists $args{messageInflateError} ? $args{messageInflateError} : 'Failed to inflate nodeValue %node.path%: %error%'; |
194 | 30 } |
103 | 31 } |
49 | 32 |
33 sub Validate { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
34 my ($this,$node,$ctx) = @_; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
35 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
36 my @result; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
37 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
38 push @result, $_->Validate($node,$ctx) foreach $this->childNodes; |
49 | 39 |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
40 return @result; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
41 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
42 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
43 sub inflateValue { |
194 | 44 my ($this,$value) = @_; |
45 | |
46 if ( my $inflator = $this->inflator ) { | |
47 return $inflator->new($value); | |
48 } else { | |
49 return $value; | |
50 } | |
49 | 51 } |
52 | |
53 1; | |
54 | |
55 __END__ | |
56 | |
57 =pod | |
58 | |
103 | 59 =head1 NAME |
60 | |
180 | 61 C<IMPL::DOM::SimpleNode> - узел с текстом. |
103 | 62 |
49 | 63 =head1 DESCRIPTION |
64 | |
180 | 65 Узел имеющий простое значение. Данный узел может содержать ограничения |
66 на простое значение. | |
49 | 67 |
180 | 68 Производит валидацию содержимого, при постоении DOM модели не имеет специального |
69 типа и будет создан в виде C<IMPL::DOM::Node>. | |
103 | 70 |
180 | 71 Также определяет как будет воссоздано значение узла в DOM модели. |
49 | 72 |
73 =cut |