Diff of /branches/0.71/lib/SOAP/Lite.pm [r385] .. [r386]  Maximize  Restore

Switch to side-by-side view

--- a/branches/0.71/lib/SOAP/Lite.pm
+++ b/branches/0.71/lib/SOAP/Lite.pm
@@ -4,7 +4,7 @@
 # SOAP::Lite is free software; you can redistribute it
 # and/or modify it under the same terms as Perl itself.
 #
-# $Id: Lite.pm 384 2011-08-16 17:08:08Z kutterma $
+# $Id: Lite.pm 386 2011-08-18 19:48:31Z kutterma $
 #
 # ======================================================================
 
@@ -18,7 +18,7 @@
 
 use 5.006; #weak references require perl 5.6
 use strict;
-our $VERSION = 0.713;
+our $VERSION = 0.714;
 # ======================================================================
 
 package SOAP::XMLSchemaApacheSOAP::Deserializer;
@@ -1033,8 +1033,14 @@
 }
 
 sub multiref_anchor {
-    my $seen = shift->seen->{my $id = shift || return undef};
-    return $seen->{multiref} ? "ref-$id" : undef;
+    my ($self, $id) = @_;
+    no warnings qw(uninitialized);
+    if ($self->{ _seen }->{ $id }->{multiref}) {
+        return "ref-$id"
+    }
+    else {
+        return undef;
+    }
 }
 
 sub encode_multirefs {
@@ -1445,18 +1451,28 @@
     $attrs ||= {};
 
     local $self->{_level} = $self->{_level} + 1;
+
     return $self->tag($name, $attrs)
         unless defined $values;
+
     return $self->tag($name, $attrs, $values)
         unless UNIVERSAL::isa($values => 'ARRAY');
+
     return $self->tag($name, {%$attrs, href => '#'.$self->multiref_anchor($id)})
         if $self->is_href($id, delete($attrs->{_id}));
-    return $self->tag($name,
-        {
-            %$attrs, id => $self->multiref_anchor($id)
-        },
-        map {$self->xmlize($_)} @$values
-    );
+
+    # we have seen this element as a reference
+    if (defined $id && $self->{ _seen }->{ $id }->{ multiref}) {
+        return $self->tag($name,
+            {
+                %$attrs, id => $self->multiref_anchor($id)
+            },
+            map {$self->xmlize($_)} @$values
+        );
+    }
+    else {
+        return $self->tag($name, $attrs, map {$self->xmlize($_)} @$values);
+    }
 }
 
 sub uriformethod {