annotate Lib/IMPL/DOM/Schema/Node.pm @ 327:6cb0d4d325d7

sync
author sergey
date Thu, 30 May 2013 20:31:37 +0400
parents 4ddb27ff4a0b
children ced5937ff21a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
1 package IMPL::DOM::Schema::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
4
165
76515373dac0 Added Class::Template,
wizard
parents: 152
diff changeset
5 use parent qw(IMPL::DOM::Node);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
7 use IMPL::DOM::Property qw(_dom);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
9 BEGIN {
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
10 public _dom _direct property minOccur => prop_all;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
11 public _dom _direct property maxOccur => prop_all;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
12 public _dom _direct property type => prop_all;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
13 public _dom _direct property name => prop_all;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
14 public _dom _direct property display => prop_all;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
15 public _dom _direct property display_no => prop_all;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
16 public _dom _direct property display_blame => prop_all;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
19 our %CTOR = (
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
20 'IMPL::DOM::Node' => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
21 my %args = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 delete @args{qw(
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23 minOccur
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
24 maxOccur
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
25 type
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
26 name
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
27 display
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28 display_no
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
29 display_blame
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
30 )} ;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
31 $args{nodeName} ||= 'Node';
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
32 %args
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
33 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
34 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
35
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
36 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
37 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
38
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
39 $this->{$minOccur} = defined $args{minOccur} ? $args{minOccur} : 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
40 $this->{$maxOccur} = defined $args{maxOccur} ? $args{maxOccur} : 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
41 $this->{$type} = $args{type};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
42 $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
43 $this->{$display} = $args{display} if $args{display};
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
44 $this->{$display_no} = $args{display_no} if $args{display};
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
45 $this->{$display_blame} = $args{display_blame} if $args{display};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
46 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
48 sub Validate {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
49 my ($this,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
50
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
51 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
52 my @errors = $schemaType->Validate($node,{Source => $this});
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
53 return @errors;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
54 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
55 return ();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
56 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
57 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
58
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
59 sub isOptional {
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
60 my ($this) = @_;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
61
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
62 return $this->{$minOccur} ? 0 : 1;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
63 }
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 sub isMultiple {
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
66 my ($this) = @_;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
67
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
68 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
69 }
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
70
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
71 sub inflateValue {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
72 $_[1];
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
73 }
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 sub inflator { undef }
103
c289ed9662ca Schema beta 2
wizard
parents: 100
diff changeset
76
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
77 sub qname {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
78 $_[0]->nodeName.'[name='.$_[0]->{$name}.']';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
79 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
80
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
81 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
82
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
83 __END__
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
84 =pod
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
85
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
86 =head1 SYNOPSIS
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
87
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
88 package SchemaEntity;
165
76515373dac0 Added Class::Template,
wizard
parents: 152
diff changeset
89 use parent qw(IMPL::DOM::Schema::Node);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
90
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
91 sub Validate {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
92 my ($this,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
93 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
94
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
95 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
96
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
97 Базовый класс для элементов схемы. Также позволяет объявлять узлы определенного типа.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
98
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
99 =head1 MEMBERS
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
100
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
101 =head2 PROPERTIES
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
102
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
103 =over
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
104
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
105 =item C<[get,set] minOccur>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
106
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
107 C<default: 1>.
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
108
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
109 Минимальное количество повторений узла.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
110
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
111 =item C<[get,set] maxOccur>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
112
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
113 C<default: 1>.
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
114
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
115 Максимальное количество повторений узла
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
116
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
117 =item C<[get,set] type>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
118
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
119 C<default: undef>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
120
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
121 Имя типа из схемы.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
122
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
123 =item C<[get,set] name>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
124
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
125 Имя узла.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
126
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
127 =item C<[get,set] display>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
128
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
129 Имя узла для отображения.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
130
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
131 =item C<[get,set] display_no>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
132
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
133 Имя узла для отображения (родительный падеж).
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
134
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
135 =item C<[get,set] display_blame>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
136
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
137 Имя узла для отображения (винительный падеж).
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
138
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
139 =back
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
140
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
141 =cut