Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/SimpleType.pm @ 164:eb3e9861a761
SQL traits in progress
author | wizard |
---|---|
date | Mon, 28 Mar 2011 01:36:24 +0400 |
parents | 1e7f03414b65 |
children | 76515373dac0 |
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; | |
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 | |
60 C<IMPL::DOM::Schema::SimpleType> - тип для простых узлов. | |
61 | |
62 =head1 DESCRIPTION | |
63 | |
64 Используется для описания простых узлов, которые можно отобразить в узлы | |
65 определенного типа при построении DOM документа. | |
66 | |
67 =head1 MEMBERS | |
68 | |
69 =over | |
70 | |
71 =item C<nativeType> | |
72 | |
73 Имя класса который будет представлять узел в DOM модели. | |
74 | |
75 =item C<messageWrongType> | |
76 | |
77 Формат сообщения которое будет выдано, если узел в дом модели не будет | |
78 соответствовать свойству C<nativeType>. | |
79 | |
80 =back | |
81 | |
82 =cut |