Mercurial > pub > Impl
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 35:f25d021780b3 | 36:1828103371d0 |
|---|---|
| 1 package IMPL::DOM::Navigator::SimpleBuilder; | |
| 2 use strict; | |
| 3 use warnings; | |
| 4 | |
| 5 use base qw(IMPL::DOM::Navigator); | |
| 6 | |
| 7 use IMPL::Class::Property; | |
| 8 use IMPL::Class::Property::Direct; | |
| 9 | |
| 10 require IMPL::DOM::Navigator::SchemaNavigator; | |
| 11 use IMPL::DOM::Document; | |
| 12 | |
| 13 BEGIN { | |
| 14 public _direct property Document => prop_get | owner_set; | |
| 15 } | |
| 16 | |
| 17 our %CTOR = ( | |
| 18 'IMPL::DOM::Navigator' => sub { IMPL::DOM::Document::Empty; } | |
| 19 ); | |
| 20 | |
| 21 sub NavigateCreate { | |
| 22 my ($this,$nodeName,%props) = @_; | |
| 23 | |
| 24 my $node; | |
| 25 if (! $this->{$Document}) { | |
| 26 $node = $this->{$Document} = IMPL::DOM::Document->new(nodeName => $nodeName,%props); | |
| 27 $this->_initNavigator($node); | |
| 28 } else { | |
| 29 die new IMPL::InvalidOperationException('Can\t create a second top level element') unless $this->Current; | |
| 30 $node = $this->{$Document}->Create($nodeName,'IMPL::DOM::Node',\%props); | |
| 31 $this->Current->appendChild($node); | |
| 32 $this->internalNavigateNodeSet($node); | |
| 33 } | |
| 34 return $node; | |
| 35 } | |
| 36 | |
| 37 1; |
