comparison Lib/IMPL/DOM/Schema/Node.pm @ 20:267460284fb3

DOM Schema
author Sergey
date Tue, 22 Sep 2009 17:17:38 +0400
parents 1ca530e5c9c5
children 7f00786f8210
comparison
equal deleted inserted replaced
19:1ca530e5c9c5 20:267460284fb3
8 use IMPL::Class::Property::Direct; 8 use IMPL::Class::Property::Direct;
9 9
10 BEGIN { 10 BEGIN {
11 public property minOccur => prop_all; 11 public property minOccur => prop_all;
12 public property maxOccur => prop_all; 12 public property maxOccur => prop_all;
13 public property type => prop_all 13 public property type => prop_all;
14 public property name => prop_all;
14 } 15 }
15 16
16 __PACKAGE__->PassThroughArgs; 17 our %CTOR = (
18 'IMPL::DOM::Node' => sub {my %args = @_; $args{nodeName} ||= 'Node'; %args}
19 );
17 20
18 sub CTOR { 21 sub CTOR {
19 my ($this,%args) = @_; 22 my ($this,%args) = @_;
20 23
21 $this->minOccur(defined $args{minOcuur} ? $args{minOcuur} : 1); 24 $this->minOccur(defined $args{minOccur} ? $args{minOccur} : 1);
22 $this->maxOccur(defined $args{maxOccur} ? $args{maxOccur} : 1); 25 $this->maxOccur(defined $args{maxOccur} ? $args{maxOccur} : 1);
23 $this->type($args{type}); 26 $this->type($args{type});
27 $this->name($args{name}) or die new IMPL::InvalidArgumentException('Argument is required','name');
24 } 28 }
25 29
26 sub Validate { 30 sub Validate {
27 my ($this,$node) = @_; 31 my ($this,$node) = @_;
28 32
29 if (my $schemaType = $this->type ? $this->rootNode->resolveType($this->type) : undef ) { 33 if (my $schemaType = $this->type ? $this->rootNode->resolveType($this->type) : undef ) {
30 return $schemaType->Validate($node); 34 return $schemaType->Validate($node);
35 } else {
36 return ();
31 } 37 }
32 } 38 }
33 39
34 1; 40 1;
35 41
45 my ($this,$node) = @_; 51 my ($this,$node) = @_;
46 } 52 }
47 53
48 =head1 DESCRIPTION 54 =head1 DESCRIPTION
49 55
50 Базовый класс для элементов схемы. Содержит в себе базовые методы 56 Базовый класс для элементов схемы.
51 57
52 =cut 58 =cut