view 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 source

package IMPL::DOM::Transform::PostToDOM;
use strict;
use warnings;

use IMPL::DOM::Navigator::Builder;
use IMPL::Class::Property;

use base qw(IMPL::Transform);

BEGIN {
    public property documentClass => prop_get | owner_set;
    public property documentSchema => prop_get | owner_set;
    private property _navi => prop_all;
}

our %CTOR = (
    'IMPL::Transform' => sub {
        HASH => \&TransfromPostData
    }
);

sub CTOR {
	my ($this,$docClass,$docSchema) = @_;
	$docClass ||= 'IMPL::DOM::Document';
	
	$this->_navi(
		IMPL::DOM::Navigator::Builder->new(
			$docClass,
			$docSchema
		)
	);
}

sub TransformPostData {
    my ($this,$data) = @_;
    
    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;
}

sub 

sub TransformErrors {
	return $_[0]->_navi->BuildErrors;
}

1;