Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/Node.pm @ 266:89179bb8c388
*corrected TTView to handle plain (and undefined) values
*added URL generating methods to Application::Action
*fixed the compare validatior for schemas
author | cin |
---|---|
date | Mon, 14 Jan 2013 03:10:06 +0400 |
parents | f48a1a9f4fa2 |
children | 4ddb27ff4a0b |
rev | line source |
---|---|
49 | 1 package IMPL::DOM::Schema::Node; |
2 use strict; | |
3 use warnings; | |
4 | |
165 | 5 use parent qw(IMPL::DOM::Node); |
49 | 6 use IMPL::Class::Property; |
7 use IMPL::DOM::Property qw(_dom); | |
8 use IMPL::Class::Property::Direct; | |
9 | |
10 BEGIN { | |
152 | 11 public _dom _direct property minOccur => prop_all; |
12 public _dom _direct property maxOccur => prop_all; | |
13 public _dom _direct property type => prop_all; | |
14 public _dom _direct property name => prop_all; | |
15 public _dom _direct property display => prop_all; | |
16 public _dom _direct property display_no => prop_all; | |
17 public _dom _direct property display_blame => prop_all; | |
49 | 18 } |
19 | |
20 our %CTOR = ( | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
21 'IMPL::DOM::Node' => sub { |
194 | 22 my %args = @_; |
23 delete @args{qw( | |
24 minOccur | |
25 maxOccur | |
26 type | |
27 name | |
28 display | |
29 display_no | |
30 display_blame | |
31 )} ; | |
32 $args{nodeName} ||= 'Node'; | |
33 %args | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
34 } |
49 | 35 ); |
36 | |
37 sub CTOR { | |
38 my ($this,%args) = @_; | |
39 | |
40 $this->{$minOccur} = defined $args{minOccur} ? $args{minOccur} : 1; | |
41 $this->{$maxOccur} = defined $args{maxOccur} ? $args{maxOccur} : 1; | |
42 $this->{$type} = $args{type}; | |
43 $this->{$name} = $args{name} or die new IMPL::InvalidArgumentException('Argument is required','name'); | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
44 $this->{$display} = $args{display} if $args{display}; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
45 $this->{$display_no} = $args{display_no} if $args{display}; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
46 $this->{$display_blame} = $args{display_blame} if $args{display}; |
49 | 47 } |
48 | |
49 sub Validate { | |
50 my ($this,$node) = @_; | |
51 | |
52 if (my $schemaType = $this->{$type} ? $this->document->resolveType($this->{$type}) : undef ) { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
53 my @errors = $schemaType->Validate($node,{Source => $this}); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
54 return @errors; |
49 | 55 } else { |
56 return (); | |
57 } | |
58 } | |
59 | |
241
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
60 sub isOptional { |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
61 my ($this) = @_; |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
62 |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
63 return $this->{$minOccur} ? 0 : 1; |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
64 } |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
65 |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
66 sub isMultiple { |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
67 my ($this) = @_; |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
68 |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
69 return ($this->{$maxOccur} eq 'unbounded' || $this->{$maxOccur} > 1 ) ? 1 : 0; |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
70 } |
f48a1a9f4fa2
+Added ViewResult to allow implementation of the view environment.
sergey
parents:
194
diff
changeset
|
71 |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
72 sub inflateValue { |
194 | 73 $_[1]; |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
74 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
75 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
76 sub inflator { undef } |
103 | 77 |
49 | 78 sub qname { |
79 $_[0]->nodeName.'[name='.$_[0]->{$name}.']'; | |
80 } | |
81 | |
82 1; | |
83 | |
84 __END__ | |
85 =pod | |
86 | |
87 =head1 SYNOPSIS | |
88 | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
89 package SchemaEntity; |
165 | 90 use parent qw(IMPL::DOM::Schema::Node); |
49 | 91 |
92 sub Validate { | |
93 my ($this,$node) = @_; | |
94 } | |
95 | |
96 =head1 DESCRIPTION | |
97 | |
180 | 98 Базовый класс для элементов схемы. Также позволяет объявлять узлы определенного типа. |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
99 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
100 =head1 MEMBERS |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
101 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
102 =head2 PROPERTIES |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
103 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
104 =over |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
105 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
106 =item C<[get,set] minOccur> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
107 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
108 C<default: 1>. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
109 |
180 | 110 Минимальное количество повторений узла. |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
111 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
112 =item C<[get,set] maxOccur> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
113 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
114 C<default: 1>. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
115 |
180 | 116 Максимальное количество повторений узла |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
117 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
118 =item C<[get,set] type> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
119 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
120 C<default: undef> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
121 |
180 | 122 Имя типа из схемы. |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
123 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
124 =item C<[get,set] name> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
125 |
180 | 126 Имя узла. |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
127 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
128 =item C<[get,set] display> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
129 |
180 | 130 Имя узла для отображения. |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
131 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
132 =item C<[get,set] display_no> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
133 |
180 | 134 Имя узла для отображения (родительный падеж). |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
135 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
136 =item C<[get,set] display_blame> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
137 |
180 | 138 Имя узла для отображения (винительный падеж). |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
139 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
140 =back |
49 | 141 |
142 =cut |