Mercurial > pub > Impl
diff Lib/IMPL/DOM/Navigator/SimpleBuilder.pm @ 36:1828103371d0
DOM in works
author | Sergey |
---|---|
date | Fri, 20 Nov 2009 16:48:08 +0300 |
parents | |
children | 16ada169ca75 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/DOM/Navigator/SimpleBuilder.pm Fri Nov 20 16:48:08 2009 +0300 @@ -0,0 +1,37 @@ +package IMPL::DOM::Navigator::SimpleBuilder; +use strict; +use warnings; + +use base qw(IMPL::DOM::Navigator); + +use IMPL::Class::Property; +use IMPL::Class::Property::Direct; + +require IMPL::DOM::Navigator::SchemaNavigator; +use IMPL::DOM::Document; + +BEGIN { + public _direct property Document => prop_get | owner_set; +} + +our %CTOR = ( + 'IMPL::DOM::Navigator' => sub { IMPL::DOM::Document::Empty; } +); + +sub NavigateCreate { + my ($this,$nodeName,%props) = @_; + + my $node; + if (! $this->{$Document}) { + $node = $this->{$Document} = IMPL::DOM::Document->new(nodeName => $nodeName,%props); + $this->_initNavigator($node); + } else { + die new IMPL::InvalidOperationException('Can\t create a second top level element') unless $this->Current; + $node = $this->{$Document}->Create($nodeName,'IMPL::DOM::Node',\%props); + $this->Current->appendChild($node); + $this->internalNavigateNodeSet($node); + } + return $node; +} + +1;