Mercurial > pub > Impl
diff Lib/IMPL/DOM/Transform/PostToDOM.pm @ 112:0ed8e2541b1c
Form processing mechanism
author | wizard |
---|---|
date | Tue, 18 May 2010 17:59:31 +0400 |
parents | 83e356614c1e |
children | 7b14e0122b79 |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Transform/PostToDOM.pm Tue May 18 01:33:37 2010 +0400 +++ b/Lib/IMPL/DOM/Transform/PostToDOM.pm Tue May 18 17:59:31 2010 +0400 @@ -1,8 +1,8 @@ -package IMPL::DOM::PostToDOM; +package IMPL::DOM::Transform::PostToDOM; use strict; use warnings; -use IMPL::DOM::Navigator; +use IMPL::DOM::Navigator::Builder; use IMPL::Class::Property; use base qw(IMPL::Transform); @@ -21,43 +21,38 @@ sub CTOR { my ($this,$docClass,$docSchema) = @_; - $docClass ||= 'IMPL::DOM::Document' + $docClass ||= 'IMPL::DOM::Document'; + + $this->_navi( + IMPL::DOM::Navigator::Builder->new( + $docClass, + $docSchema + ) + ); } sub TransformPostData { my ($this,$data) = @_; - my $navi = $this->Navigator; + my $navi = $this->_navi; + + my % while (my ($key,$value) = each %$data) { # TODO: review + $navi->save; my $node = $navi->Navigate(split /\//, $key); $node->nodeValue($value); + $navi->resore; } return $navi->Document; } -package IMPL::DOM::PostToDOM::Navigator; -use base qw(IMPL::DOM::Navigator::Builder); - -__PACKAGE__->PassThroughArgs; +sub -sub Navigate { - my ($this,@path) = @_; - - if (@path > 1) { - my $node; - foreach my $query (@path) { - unless($this->dosafe(sub { - $node = $this->SUPER::Navigate($query); - })) { - $node = $this->NavigateCreate($query); - } - } - } else { - die new IMPL::InvalidArgumentException("A path is a required parameter"); - } +sub TransformErrors { + return $_[0]->_navi->BuildErrors; } 1;