Mercurial > pub > Impl
diff Lib/IMPL/DOM/Navigator/Builder.pm @ 24:7f00786f8210
Первая рабочая реазизация схемы и навигаторов
author | Sergey |
---|---|
date | Mon, 05 Oct 2009 00:48:49 +0400 |
parents | 75d55f4ee263 |
children | a8086f85a571 |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Navigator/Builder.pm Wed Sep 30 17:43:52 2009 +0400 +++ b/Lib/IMPL/DOM/Navigator/Builder.pm Mon Oct 05 00:48:49 2009 +0400 @@ -5,9 +5,10 @@ use base qw(IMPL::DOM::Navigator); use IMPL::Class::Property; use IMPL::Class::Property::Direct; +require IMPL::DOM::Navigator::SchemaNavigator; BEGIN { - protected _direct property _navigatorSchema => prop_all; + protected _direct property _schemaNavi => prop_all; public _direct property Document => prop_get | owner_set; } @@ -19,30 +20,18 @@ my ($this,$domDocument,$schema) = @_; $this->{$Document} = $domDocument; - $this->{$_navigatorSchema} = new IMPL::DOM::Navigator($schema); + $this->{$_schemaNavi} = $schema; } sub NavigateCreate { my ($this,$nodeName,%props) = @_; - if ( my $nodeSchema = $this->{$_navigatorSchema}->Navigate(sub { $_[0]->nodeName eq $nodeName or $_[0]->isa('IMPL::DOM::Schema::AnyNode') }) ) { - my $class = delete $props{type} || $nodeSchema->type || $nodeName; - - my $node = $this->{$Document}->Create(delete $props{nodeName} || $nodeName, $class, \%props); - - $this->Current()->appendNode($node); - $this->Current($node); - - } else { - die new IMPL::InvalidOperationException("Requested elemnt not found in the schema"); - } + } sub Back { my ($this) = @_; - $this->{$_navigatorSchema}->Back; - return $this->SUPER::Back(); } 1;