49
|
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;
|