Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/SimpleNode.pm @ 126:c8dfbbdd8005
Several bug fixes
Forms support pre-alfa version
author | wizard |
---|---|
date | Fri, 11 Jun 2010 04:29:51 +0400 |
parents | e30bdd040fe3 |
children | 1e7f03414b65 |
rev | line source |
---|---|
49 | 1 package IMPL::DOM::Schema::SimpleNode; |
2 use strict; | |
3 use warnings; | |
4 | |
5 use base qw(IMPL::DOM::Schema::Node); | |
103 | 6 use IMPL::Class::Property; |
7 use IMPL::Class::Property::Direct; | |
8 | |
9 BEGIN { | |
10 public _direct property inflator => prop_get; | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
11 public _direct property messageInflateError => prop_get; |
103 | 12 } |
49 | 13 |
14 our %CTOR = ( | |
124 | 15 'IMPL::DOM::Schema::Node' => sub { |
16 my %args = @_; | |
17 $args{nodeName} ||= 'SimpleNode'; | |
18 delete @args{qw(inflator messageInflateError)}; | |
19 %args | |
20 } | |
103 | 21 ); |
22 | |
23 sub CTOR { | |
24 my ($this,%args) = @_; | |
25 | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
26 $this->{$inflator} = $args{inflator} if $args{inflator}; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
27 $this->{$messageInflateError} = $args{messageInflateError} || 'Failed to inflate nodeValue %Node.path%: %Error%'; |
103 | 28 } |
49 | 29 |
30 sub Validate { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
31 my ($this,$node,$ctx) = @_; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
32 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
33 my @result; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
34 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
35 push @result, $_->Validate($node,$ctx) foreach $this->childNodes; |
49 | 36 |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
37 return @result; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
38 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
39 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
40 sub inflateValue { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
41 my ($this,$value) = @_; |
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 if ( my $inflator = $this->inflator ) { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
44 return $inflator->new($value); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
45 } else { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
46 return $value; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
47 } |
49 | 48 } |
49 | |
50 1; | |
51 | |
52 __END__ | |
53 | |
54 =pod | |
55 | |
103 | 56 =head1 NAME |
57 | |
58 C<IMPL::DOM::SimpleNode> - узел с текстом. | |
59 | |
49 | 60 =head1 DESCRIPTION |
61 | |
62 Узел имеющий простое значение. Данный узел может содержать ограничения | |
63 на простое значение. | |
64 | |
103 | 65 Производит валидацию содержимого, при постоении DOM модели не имеет специального |
66 типа и будет создан в виде C<IMPL::DOM::Node>. | |
67 | |
68 Также определяет как будет воссоздано значение узла в DOM модели. | |
49 | 69 |
70 =cut |