Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/SimpleType.pm @ 144:b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
minor speed improvements to the object CTOR caching
Added support for a secure processing (and 'laundering' ) a CGI parameters
Many minor fixes
author | wizard |
---|---|
date | Tue, 13 Jul 2010 02:05:38 +0400 |
parents | e30bdd040fe3 |
children | 1e7f03414b65 |
rev | line source |
---|---|
49 | 1 package IMPL::DOM::Schema::SimpleType; |
2 use strict; | |
3 use warnings; | |
4 | |
5 use base qw(IMPL::DOM::Schema::SimpleNode); | |
6 use IMPL::Class::Property; | |
7 use IMPL::Class::Property::Direct; | |
8 | |
9 BEGIN { | |
10 public _direct property nativeType => prop_get; | |
103 | 11 public _direct property messageWrongType => prop_get; |
49 | 12 } |
13 | |
14 our %CTOR = ( | |
15 'IMPL::DOM::Schema::SimpleNode' => sub { | |
16 my %args = @_; | |
17 $args{nodeName} = 'SimpleType'; | |
18 $args{minOccur} = 0; | |
19 $args{maxOccur} = 'unbounded'; | |
20 $args{name} ||= 'SimpleType'; | |
124 | 21 delete @args{qw(nativeType messageWrongType)}; |
49 | 22 %args |
23 } | |
24 ); | |
25 | |
26 sub CTOR { | |
27 my ($this,%args) = @_; | |
28 | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
29 $this->{$nativeType} = $args{nativeType} if $args{nativeType}; |
103 | 30 $this->{$messageWrongType} = $args{messageWrongType} || "A simple node '%Node.path%' is expected to be %Schema.nativeType%"; |
31 } | |
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) = @_; |
103 | 35 |
36 if ($this->{$nativeType}) { | |
37 return new IMPL::DOM::Schema::ValidationError( | |
38 Node => $node, | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
39 Source => $ctx && $ctx->{Source} || $this, |
103 | 40 Schema => $this, |
41 Message => $this->messageWrongType | |
42 ) unless $node->isa($this->{$nativeType}); | |
43 } | |
105 | 44 return $this->SUPER::Validate($node,$ctx); |
49 | 45 } |
46 | |
102 | 47 sub qname { |
103 | 48 $_[0]->nodeName.'[type='.$_[0]->type.']'; |
102 | 49 } |
50 | |
103 | 51 1; |
49 | 52 |
103 | 53 __END__ |
54 | |
55 =pod | |
56 | |
57 =head1 NAME | |
58 | |
59 C<IMPL::DOM::Schema::SimpleType> - тип для простых узлов. | |
60 | |
61 =head1 DESCRIPTION | |
62 | |
63 Используется для описания простых узлов, которые можно отобразить в узлы | |
64 определенного типа при построении DOM документа. | |
65 | |
66 =head1 MEMBERS | |
67 | |
68 =over | |
69 | |
70 =item C<nativeType> | |
71 | |
72 Имя класса который будет представлять узел в DOM модели. | |
73 | |
74 =item C<messageWrongType> | |
75 | |
76 Формат сообщения которое будет выдано, если узел в дом модели не будет | |
77 соответствовать свойству C<nativeType>. | |
78 | |
79 =back | |
80 | |
81 =cut |