Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Navigator/Builder.pm @ 35:f25d021780b3
DOM::Navigator::Builder working version
author | Sergey |
---|---|
date | Tue, 17 Nov 2009 17:46:24 +0300 |
parents | a8086f85a571 |
children | 16ada169ca75 |
comparison
equal
deleted
inserted
replaced
34:a8086f85a571 | 35:f25d021780b3 |
---|---|
17 | 17 |
18 sub CTOR { | 18 sub CTOR { |
19 my ($this,$docClass,$schema) = @_; | 19 my ($this,$docClass,$schema) = @_; |
20 | 20 |
21 $this->{$_docClass} = $docClass; | 21 $this->{$_docClass} = $docClass; |
22 $this->{$_schemaNavi} = IMPL::DOM::Navigator::SchemaNavigator->new($schema); | 22 $this->{$_schemaNavi} = $schema ? IMPL::DOM::Navigator::SchemaNavigator->new($schema) : undef; |
23 } | 23 } |
24 | 24 |
25 sub NavigateCreate { | 25 sub NavigateCreate { |
26 my ($this,$nodeName,%props) = @_; | 26 my ($this,$nodeName,%props) = @_; |
27 | 27 |
30 | 30 |
31 my $node; | 31 my $node; |
32 if (! $this->{$Document}) { | 32 if (! $this->{$Document}) { |
33 $node = $this->{$Document} = $this->{$_docClass}->new(nodeName => $nodeName,%props); | 33 $node = $this->{$Document} = $this->{$_docClass}->new(nodeName => $nodeName,%props); |
34 } else { | 34 } else { |
35 die new IMPL::InvalidOperationException('Can\t create a second top level element'); | 35 die new IMPL::InvalidOperationException('Can\t create a second top level element') unless $this->{$_nodeCurrent}; |
36 $node = $this->{$Document}->Create($nodeName,$class,\%props); | 36 $node = $this->{$Document}->Create($nodeName,$class,\%props); |
37 push @{$this->{$_nodesPath}}, $this->{$_nodeCurrent}; | 37 push @{$this->{$_nodesPath}}, $this->{$_nodeCurrent}; |
38 $this->{$_nodeCurrent}->appendChild($node); | 38 $this->{$_nodeCurrent}->appendChild($node); |
39 } | 39 } |
40 | 40 |