annotate Lib/IMPL/DOM/Navigator/SimpleBuilder.pm @ 40:ac21a032e7a9

bnf parser in progress
author Sergey
date Thu, 10 Dec 2009 17:43:39 +0300
parents 1828103371d0
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
1828103371d0 DOM in works
Sergey
parents:
diff changeset
1 package IMPL::DOM::Navigator::SimpleBuilder;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
2 use strict;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
3 use warnings;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
4
1828103371d0 DOM in works
Sergey
parents:
diff changeset
5 use base qw(IMPL::DOM::Navigator);
1828103371d0 DOM in works
Sergey
parents:
diff changeset
6
1828103371d0 DOM in works
Sergey
parents:
diff changeset
7 use IMPL::Class::Property;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
8 use IMPL::Class::Property::Direct;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
9
1828103371d0 DOM in works
Sergey
parents:
diff changeset
10 require IMPL::DOM::Navigator::SchemaNavigator;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
11 use IMPL::DOM::Document;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
12
1828103371d0 DOM in works
Sergey
parents:
diff changeset
13 BEGIN {
1828103371d0 DOM in works
Sergey
parents:
diff changeset
14 public _direct property Document => prop_get | owner_set;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
15 }
1828103371d0 DOM in works
Sergey
parents:
diff changeset
16
1828103371d0 DOM in works
Sergey
parents:
diff changeset
17 our %CTOR = (
1828103371d0 DOM in works
Sergey
parents:
diff changeset
18 'IMPL::DOM::Navigator' => sub { IMPL::DOM::Document::Empty; }
1828103371d0 DOM in works
Sergey
parents:
diff changeset
19 );
1828103371d0 DOM in works
Sergey
parents:
diff changeset
20
1828103371d0 DOM in works
Sergey
parents:
diff changeset
21 sub NavigateCreate {
1828103371d0 DOM in works
Sergey
parents:
diff changeset
22 my ($this,$nodeName,%props) = @_;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
23
1828103371d0 DOM in works
Sergey
parents:
diff changeset
24 my $node;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
25 if (! $this->{$Document}) {
1828103371d0 DOM in works
Sergey
parents:
diff changeset
26 $node = $this->{$Document} = IMPL::DOM::Document->new(nodeName => $nodeName,%props);
1828103371d0 DOM in works
Sergey
parents:
diff changeset
27 $this->_initNavigator($node);
1828103371d0 DOM in works
Sergey
parents:
diff changeset
28 } else {
1828103371d0 DOM in works
Sergey
parents:
diff changeset
29 die new IMPL::InvalidOperationException('Can\t create a second top level element') unless $this->Current;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
30 $node = $this->{$Document}->Create($nodeName,'IMPL::DOM::Node',\%props);
1828103371d0 DOM in works
Sergey
parents:
diff changeset
31 $this->Current->appendChild($node);
1828103371d0 DOM in works
Sergey
parents:
diff changeset
32 $this->internalNavigateNodeSet($node);
1828103371d0 DOM in works
Sergey
parents:
diff changeset
33 }
1828103371d0 DOM in works
Sergey
parents:
diff changeset
34 return $node;
1828103371d0 DOM in works
Sergey
parents:
diff changeset
35 }
1828103371d0 DOM in works
Sergey
parents:
diff changeset
36
1828103371d0 DOM in works
Sergey
parents:
diff changeset
37 1;