Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/SimpleType.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 | 4ddb27ff4a0b |
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}; |
238 | 31 $this->{$messageWrongType} = $args{messageWrongType} || "A simple node '%node.path%' is expected to be %schema.nativeType%"; |
103 | 32 } |
33 | |
34 sub Validate { | |
194 | 35 my ($this, $node, $ctx) = @_; |
36 | |
37 if ($this->{$nativeType}) { | |
38 return new IMPL::DOM::Schema::ValidationError( | |
236 | 39 node => $node, |
40 source => $ctx && $ctx->{Source} || $this, | |
41 schema => $this, | |
42 message => $this->messageWrongType | |
194 | 43 ) unless $node->isa($this->{$nativeType}); |
44 } | |
45 return $this->SUPER::Validate($node,$ctx); | |
49 | 46 } |
47 | |
102 | 48 sub qname { |
194 | 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 |