Mercurial > pub > Impl
diff Lib/IMPL/DOM/Navigator/Builder.pm @ 106:83e356614c1e
DOM Builder now is a navigator like SimpleBuilder
PostToDOM transformation
author | wizard |
---|---|
date | Wed, 12 May 2010 17:52:12 +0400 |
parents | 196bf443b5e1 |
children | 0ed8e2541b1c |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Navigator/Builder.pm Tue May 11 02:59:49 2010 +0400 +++ b/Lib/IMPL/DOM/Navigator/Builder.pm Wed May 12 17:52:12 2010 +0400 @@ -2,21 +2,24 @@ use strict; use warnings; -use base qw(IMPL::Object); +use base qw(IMPL::DOM::Navigator); use IMPL::Class::Property; use IMPL::Class::Property::Direct; require IMPL::DOM::Navigator::SchemaNavigator; require IMPL::DOM::Schema::ValidationError; +use IMPL::DOM::Document; BEGIN { private _direct property _schemaNavi => prop_all; - private _direct property _nodesPath => prop_all; - private _direct property _nodeCurrent => prop_all; private _direct property _docClass => prop_all; public _direct property BuildErrors => prop_get | prop_list; public _direct property Document => prop_get | owner_set; } +our %CTOR = ( + 'IMPL::DOM::Navigator' => sub { IMPL::DOM::Document::Empty; } +); + sub CTOR { my ($this,$docClass,$schema) = @_; @@ -35,15 +38,14 @@ my $node; if (! $this->{$Document}) { $node = $this->{$Document} = $this->{$_docClass}->new(nodeName => $nodeName,%props); + $this->_initNavigator($node); } else { - die new IMPL::InvalidOperationException('Can\t create a second top level element') unless $this->{$_nodeCurrent}; + die new IMPL::InvalidOperationException('Can\t create a second top level element') unless $this->Current; $node = $this->{$Document}->Create($nodeName,$class,\%props); - push @{$this->{$_nodesPath}}, $this->{$_nodeCurrent}; - $this->{$_nodeCurrent}->appendChild($node); + $this->Current->appendChild($node); + $this->internalNavigateNodeSet($node); } - $this->{$_nodeCurrent} = $node; - if (@errors) { $this->BuildErrors->Append( map { @@ -103,7 +105,7 @@ my ($this) = @_; $this->{$_schemaNavi}->SchemaBack(); - $this->{$_nodeCurrent} = pop @{$this->{$_nodesPath}}; + $this->SUPER::Back(); } 1;