comparison Lib/IMPL/DOM/Schema/ComplexNode.pm @ 388:648dfaf642e0

DOM refactoring, removed inflators from DOM Schema, DOM validation - in progress
author cin
date Tue, 11 Feb 2014 20:22:01 +0400
parents d1676be8afcc
children
comparison
equal deleted inserted replaced
387:4cc6cc370fb2 388:648dfaf642e0
1 package IMPL::DOM::Schema::ComplexNode; 1 package IMPL::DOM::Schema::ComplexNode;
2 use strict; 2 use strict;
3 use warnings; 3 use warnings;
4 4
5 use parent qw(IMPL::DOM::Schema::Node); 5 use IMPL::declare {
6 use IMPL::Class::Property; 6 base => [
7 'IMPL::DOM::Schema::Node' => sub {my %args = @_; $args{nodeName} ||= 'ComplexNode'; %args }
8 ],
9 props => [
10 content => {
11 get => \&_getContent,
12 set => \&_setContent
13 }
14 ]
15 };
7 16
8 BEGIN {
9 public property content => {
10 get => \&_getContent,
11 set => \&_setContent
12 }
13 }
14
15 our %CTOR = (
16 'IMPL::DOM::Schema::Node' => sub {my %args = @_; $args{nodeName} ||= 'ComplexNode'; %args }
17 );
18 17
19 sub _getContent { 18 sub _getContent {
20 $_[0]->firstChild; 19 $_[0]->firstChild;
21 } 20 }
22 21
24 $_[0]->firstChild($_[1]); 23 $_[0]->firstChild($_[1]);
25 } 24 }
26 25
27 sub Validate { 26 sub Validate {
28 my ($this,$node,$ctx) = @_; 27 my ($this,$node,$ctx) = @_;
28
29 # для случаев анонимных типов, указанных прямо в узле
30 $ctx->{schemaNode} ||= $this;
31 $ctx->{schemaType} = $this;
29 32
30 map $_->Validate($node,$ctx), @{$this->childNodes}; 33 map $_->Validate($node,$ctx), @{$this->childNodes};
31 } 34 }
32 35
33 1; 36 1;