annotate lib/IMPL/DOM/Schema/ComplexNode.pm @ 418:3f38dabaf5cc ref20150831

sync
author cin
date Mon, 28 Dec 2015 15:11:35 +0300
parents c6e90e02dd17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
407
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
1 package IMPL::DOM::Schema::ComplexNode;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
2 use strict;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
3 use warnings;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
4
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
5 use IMPL::declare {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
6 base => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
7 'IMPL::DOM::Schema::Node' => sub {my %args = @_; $args{nodeName} ||= 'ComplexNode'; %args }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
8 ],
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
9 props => [
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
10 content => {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
11 get => \&_getContent,
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
12 set => \&_setContent
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
13 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
14 ]
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
15 };
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
16
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
17
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
18 sub _getContent {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
19 $_[0]->firstChild;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
20 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
21
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
22 sub _setContent {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
23 $_[0]->firstChild($_[1]);
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
24 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
25
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
26 sub Validate {
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
27 my ($this,$node,$ctx) = @_;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
28
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
29 # для случаев анонимных типов, указанных прямо в узле
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
30 $ctx->{schemaNode} ||= $this;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
31 $ctx->{schemaType} = $this;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
32
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
33 map $_->Validate($node,$ctx), @{$this->childNodes};
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
34 }
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
35
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
36 1;
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
37
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
38 __END__
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
39
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
40 =pod
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
41
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
42 =head1 DESCRIPTION
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
43
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
44 Описывает сложный узел. Требует либо соответствие структуры, либо соответствия
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
45 типу.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
46
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
47 Дочерними элементами могут быть правила контроля свойств и т.п.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
48 Первым дочерним элементом может быть только содержимое узла, см. C<content>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
49
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
50 =head2 PROPERTIES
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
51
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
52 =over
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
53
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
54 =item C<content>
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
55
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
56 Содержимое узла, может быть либо C<IMPL::DOM::Schema::NodeSet> либо
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
57 C<IMPL::DOM::Schema::NodeList>, в зависимости от того важен порядок или нет.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
58 Это свойство ссылается на первый дочерний элемент узла.
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
59
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
60 =back
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
61
c6e90e02dd17 renamed Lib->lib
cin
parents:
diff changeset
62 =cut