Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Schema/Node.pm @ 24:7f00786f8210
Первая рабочая реазизация схемы и навигаторов
| author | Sergey |
|---|---|
| date | Mon, 05 Oct 2009 00:48:49 +0400 |
| parents | 267460284fb3 |
| children | c2e7f7c96bcd |
comparison
equal
deleted
inserted
replaced
| 23:716b287d4795 | 24:7f00786f8210 |
|---|---|
| 6 use IMPL::Class::Property; | 6 use IMPL::Class::Property; |
| 7 use IMPL::DOM::Property qw(_dom); | 7 use IMPL::DOM::Property qw(_dom); |
| 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 _direct property minOccur => prop_all; |
| 12 public property maxOccur => prop_all; | 12 public _direct property maxOccur => prop_all; |
| 13 public property type => prop_all; | 13 public _direct property type => prop_all; |
| 14 public property name => prop_all; | 14 public _direct property name => prop_all; |
| 15 } | 15 } |
| 16 | 16 |
| 17 our %CTOR = ( | 17 our %CTOR = ( |
| 18 'IMPL::DOM::Node' => sub {my %args = @_; $args{nodeName} ||= 'Node'; %args} | 18 'IMPL::DOM::Node' => sub {my %args = @_; $args{nodeName} ||= 'Node'; %args} |
| 19 ); | 19 ); |
| 20 | 20 |
| 21 sub CTOR { | 21 sub CTOR { |
| 22 my ($this,%args) = @_; | 22 my ($this,%args) = @_; |
| 23 | 23 |
| 24 $this->minOccur(defined $args{minOccur} ? $args{minOccur} : 1); | 24 $this->{$minOccur} = defined $args{minOccur} ? $args{minOccur} : 1; |
| 25 $this->maxOccur(defined $args{maxOccur} ? $args{maxOccur} : 1); | 25 $this->{$maxOccur} = defined $args{maxOccur} ? $args{maxOccur} : 1; |
| 26 $this->type($args{type}); | 26 $this->{$type} = $args{type}; |
| 27 $this->name($args{name}) or die new IMPL::InvalidArgumentException('Argument is required','name'); | 27 $this->{$name} = $args{name} or die new IMPL::InvalidArgumentException('Argument is required','name'); |
| 28 } | 28 } |
| 29 | 29 |
| 30 sub Validate { | 30 sub Validate { |
| 31 my ($this,$node) = @_; | 31 my ($this,$node) = @_; |
| 32 | 32 |
| 33 if (my $schemaType = $this->type ? $this->rootNode->resolveType($this->type) : undef ) { | 33 if (my $schemaType = $this->{$type} ? $this->rootNode->resolveType($this->{$type}) : undef ) { |
| 34 return $schemaType->Validate($node); | 34 return $schemaType->Validate($node); |
| 35 } else { | 35 } else { |
| 36 return (); | 36 return (); |
| 37 } | 37 } |
| 38 } | |
| 39 | |
| 40 sub qname { | |
| 41 $_[0]->nodeName.'[name='.$_[0]->{$name}.']'; | |
| 38 } | 42 } |
| 39 | 43 |
| 40 1; | 44 1; |
| 41 | 45 |
| 42 __END__ | 46 __END__ |
