112
|
1 package IMPL::DOM::Transform::PostToDOM;
|
49
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
112
|
5 use IMPL::DOM::Navigator::Builder;
|
49
|
6 use IMPL::Class::Property;
|
|
7
|
|
8 use base qw(IMPL::Transform);
|
|
9
|
|
10 BEGIN {
|
106
|
11 public property documentClass => prop_get | owner_set;
|
|
12 public property documentSchema => prop_get | owner_set;
|
|
13 private property _navi => prop_all;
|
49
|
14 }
|
|
15
|
|
16 our %CTOR = (
|
|
17 'IMPL::Transform' => sub {
|
106
|
18 HASH => \&TransfromPostData
|
49
|
19 }
|
|
20 );
|
|
21
|
106
|
22 sub CTOR {
|
|
23 my ($this,$docClass,$docSchema) = @_;
|
112
|
24 $docClass ||= 'IMPL::DOM::Document';
|
|
25
|
|
26 $this->_navi(
|
|
27 IMPL::DOM::Navigator::Builder->new(
|
|
28 $docClass,
|
|
29 $docSchema
|
|
30 )
|
|
31 );
|
106
|
32 }
|
|
33
|
49
|
34 sub TransformPostData {
|
|
35 my ($this,$data) = @_;
|
|
36
|
112
|
37 my $navi = $this->_navi;
|
|
38
|
|
39 my %
|
49
|
40
|
|
41 while (my ($key,$value) = each %$data) {
|
79
|
42 # TODO: review
|
112
|
43 $navi->save;
|
106
|
44 my $node = $navi->Navigate(split /\//, $key);
|
49
|
45 $node->nodeValue($value);
|
112
|
46 $navi->resore;
|
49
|
47 }
|
|
48
|
|
49 return $navi->Document;
|
|
50 }
|
|
51
|
112
|
52 sub
|
106
|
53
|
112
|
54 sub TransformErrors {
|
|
55 return $_[0]->_navi->BuildErrors;
|
106
|
56 }
|
49
|
57
|
|
58 1;
|