annotate Lib/IMPL/DOM/Transform/PostToDOM.pm @ 109:ddf0f037d460

IMPL::DOM::Node updated to support TT, (added childNodesRef and selectNodesRef for using from TT) Some fixes to the web document model. (beta version)
author wizard
date Mon, 17 May 2010 05:12:08 +0400
parents 83e356614c1e
children 0ed8e2541b1c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
1 package IMPL::DOM::PostToDOM;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
5 use IMPL::DOM::Navigator;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
8 use base qw(IMPL::Transform);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
10 BEGIN {
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
11 public property documentClass => prop_get | owner_set;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
12 public property documentSchema => prop_get | owner_set;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
13 private property _navi => prop_all;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
14 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
16 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
17 'IMPL::Transform' => sub {
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
18 HASH => \&TransfromPostData
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
19 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
20 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
21
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
22 sub CTOR {
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
23 my ($this,$docClass,$docSchema) = @_;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
24 $docClass ||= 'IMPL::DOM::Document'
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
25 }
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
26
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
27 sub TransformPostData {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
28 my ($this,$data) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
30 my $navi = $this->Navigator;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
31
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
32 while (my ($key,$value) = each %$data) {
79
2d1c3f713280 ORM concept in development
wizard
parents: 49
diff changeset
33 # TODO: review
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
34 my $node = $navi->Navigate(split /\//, $key);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
35 $node->nodeValue($value);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
36 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
37
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
38 return $navi->Document;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
39 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
40
106
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
41 package IMPL::DOM::PostToDOM::Navigator;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
42 use base qw(IMPL::DOM::Navigator::Builder);
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
43
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
44 __PACKAGE__->PassThroughArgs;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
45
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
46 sub Navigate {
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
47 my ($this,@path) = @_;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
48
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
49 if (@path > 1) {
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
50 my $node;
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
51 foreach my $query (@path) {
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
52 unless($this->dosafe(sub {
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
53 $node = $this->SUPER::Navigate($query);
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
54 })) {
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
55 $node = $this->NavigateCreate($query);
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
56 }
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
57 }
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
58 } else {
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
59 die new IMPL::InvalidArgumentException("A path is a required parameter");
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
60 }
83e356614c1e DOM Builder now is a navigator like SimpleBuilder
wizard
parents: 79
diff changeset
61 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
62
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 7
diff changeset
63 1;