Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Navigator/Builder.pm @ 13:bb8d67f811ea
merge heads
author | Sergey |
---|---|
date | Wed, 02 Sep 2009 23:11:14 +0400 |
parents | 955b2324c1bf 75980091813b |
children | 65a7bb156fb7 |
comparison
equal
deleted
inserted
replaced
12:955b2324c1bf | 13:bb8d67f811ea |
---|---|
1 package IMPL::DOM::Navigator::Builder; | 1 package IMPL::DOM::Navigator::Builder; |
2 use strict; | 2 use strict; |
3 use warnings; | 3 use warnings; |
4 | 4 |
5 use base qw(IMPL::DOM::Navigator); | 5 use base qw(IMPL::DOM::Navigator); |
6 | |
7 use IMPL::Class::Property; | 6 use IMPL::Class::Property; |
7 use IMPL::Class::Property::Direct; | |
8 | 8 |
9 BEGIN { | 9 BEGIN { |
10 public property SchemaNavigator => prop_get | owner_set; | 10 protected _direct property _navigatorSchema => prop_all; |
11 public _direct property Document => prop_get | owner_set; | |
12 } | |
13 | |
14 __PACKAGE__->PassThroughArgs; | |
15 | |
16 sub CTOR { | |
17 my ($this,$domDocument,$schema) = @_; | |
18 | |
19 $this->{$Document} = $domDocument; | |
20 $this->{$_navigatorSchema} = new IMPL::DOM::Navigator($schema); | |
21 } | |
22 | |
23 sub NavigateCreate { | |
24 my ($this,$nodeName,%props) = @_; | |
25 | |
26 if ( my $nodeSchema = $this->{$_navigatorSchema}->Navigate($nodeName) ) { | |
27 | |
28 | |
29 } else { | |
30 die new IMPL::InvalidOperationException("Requested elemnt not found in the schema"); | |
31 } | |
11 } | 32 } |
12 | 33 |
13 1; | 34 1; |
14 | |
15 =pod | |
16 | |
17 =head1 SYNOPSIS | |
18 | |
19 my $nav = new IMPL::DOM::Navigator::Builder(Schema => $mySchema); | |
20 | |
21 # set position to root | |
22 $nav->InitRoot(); | |
23 | |
24 # go to node 'Person' and create one if not exists | |
25 $nav->NavigateAuto("Person"); | |
26 | |
27 # set some node properties | |
28 $nav->nodeCurrent->Name("Smith"); | |
29 $nav->nodeCurrent->Age("20"); | |
30 | |
31 # navigate to node 'Address' and create one if not exists | |
32 $nav->NavigateAuto("Address"); | |
33 | |
34 =head1 DESCRIPTION | |
35 | |
36 Навигатор, который позволяет формировать документ в соответствии со схемой | |
37 | |
38 =cut |