Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Transform/ObjectToDOM.pm @ 257:299af584c05f
collapse empty array elements in POSTed data
author | sergey |
---|---|
date | Fri, 14 Dec 2012 03:07:41 +0400 |
parents | 129e48bb5afb |
children | 0f59b2de72af |
comparison
equal
deleted
inserted
replaced
256:32aceba4ee6d | 257:299af584c05f |
---|---|
77 | 77 |
78 KEYLOOP: foreach my $key (keys %$data) { | 78 KEYLOOP: foreach my $key (keys %$data) { |
79 my $value = $data->{$key}; | 79 my $value = $data->{$key}; |
80 | 80 |
81 if (ref $value eq 'ARRAY') { | 81 if (ref $value eq 'ARRAY') { |
82 foreach my $subval (@$value) { | 82 #TODO: collapse empty values only if needed |
83 foreach my $subval (grep $_, @$value) { | |
83 | 84 |
84 $this->_navi->saveState(); | 85 $this->_navi->saveState(); |
85 | 86 |
86 my $node = $this->_navi->NavigateCreate($key); | 87 my $node = $this->_navi->NavigateCreate($key); |
87 | 88 |
107 next KEYLOOP; | 108 next KEYLOOP; |
108 } | 109 } |
109 | 110 |
110 $this->_navi->applyState(); | 111 $this->_navi->applyState(); |
111 | 112 |
112 warn "$key = $value"; | |
113 | |
114 $this->Transform($value); | 113 $this->Transform($value); |
115 | 114 |
116 $this->_navi->Back(); | 115 $this->_navi->Back(); |
117 } | 116 } |
118 } | 117 } |
123 # simple node. | 122 # simple node. |
124 sub StoreObject { | 123 sub StoreObject { |
125 my ($this,$node,$data) = @_; | 124 my ($this,$node,$data) = @_; |
126 | 125 |
127 $node->nodeValue($data); | 126 $node->nodeValue($data); |
128 | |
129 warn "Stored value for", $node->nodeName; | |
130 | 127 |
131 return $node; | 128 return $node; |
132 } | 129 } |
133 | 130 |
134 sub TransformDefault { | 131 sub TransformDefault { |