Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/SimpleType.pm @ 180:d1676be8afcc
Перекодировка в utf-8
author | sourcer |
---|---|
date | Fri, 30 Dec 2011 23:40:00 +0300 |
parents | 76515373dac0 |
children | 4d0e1962161c |
rev | line source |
---|---|
49 | 1 package IMPL::DOM::Schema::SimpleType; |
2 use strict; | |
3 use warnings; | |
4 | |
165 | 5 use parent qw(IMPL::DOM::Schema::SimpleNode); |
49 | 6 use IMPL::Class::Property; |
7 use IMPL::Class::Property::Direct; | |
152 | 8 use IMPL::DOM::Property qw(_dom); |
49 | 9 |
10 BEGIN { | |
152 | 11 public _dom _direct property nativeType => prop_get; |
12 public _dom _direct property messageWrongType => prop_get; | |
49 | 13 } |
14 | |
15 our %CTOR = ( | |
16 'IMPL::DOM::Schema::SimpleNode' => sub { | |
17 my %args = @_; | |
18 $args{nodeName} = 'SimpleType'; | |
19 $args{minOccur} = 0; | |
20 $args{maxOccur} = 'unbounded'; | |
21 $args{name} ||= 'SimpleType'; | |
124 | 22 delete @args{qw(nativeType messageWrongType)}; |
49 | 23 %args |
24 } | |
25 ); | |
26 | |
27 sub CTOR { | |
28 my ($this,%args) = @_; | |
29 | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
30 $this->{$nativeType} = $args{nativeType} if $args{nativeType}; |
103 | 31 $this->{$messageWrongType} = $args{messageWrongType} || "A simple node '%Node.path%' is expected to be %Schema.nativeType%"; |
32 } | |
33 | |
34 sub Validate { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
35 my ($this, $node, $ctx) = @_; |
103 | 36 |
37 if ($this->{$nativeType}) { | |
38 return new IMPL::DOM::Schema::ValidationError( | |
39 Node => $node, | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
40 Source => $ctx && $ctx->{Source} || $this, |
103 | 41 Schema => $this, |
42 Message => $this->messageWrongType | |
43 ) unless $node->isa($this->{$nativeType}); | |
44 } | |
105 | 45 return $this->SUPER::Validate($node,$ctx); |
49 | 46 } |
47 | |
102 | 48 sub qname { |
103 | 49 $_[0]->nodeName.'[type='.$_[0]->type.']'; |
102 | 50 } |
51 | |
103 | 52 1; |
49 | 53 |
103 | 54 __END__ |
55 | |
56 =pod | |
57 | |
58 =head1 NAME | |
59 | |
180 | 60 C<IMPL::DOM::Schema::SimpleType> - тип для простых узлов. |
103 | 61 |
62 =head1 DESCRIPTION | |
63 | |
180 | 64 Используется для описания простых узлов, которые можно отобразить в узлы |
65 определенного типа при построении DOM документа. | |
103 | 66 |
67 =head1 MEMBERS | |
68 | |
69 =over | |
70 | |
71 =item C<nativeType> | |
72 | |
180 | 73 Имя класса который будет представлять узел в DOM модели. |
103 | 74 |
75 =item C<messageWrongType> | |
76 | |
180 | 77 Формат сообщения которое будет выдано, если узел в дом модели не будет |
78 соответствовать свойству C<nativeType>. | |
103 | 79 |
80 =back | |
81 | |
82 =cut |