Loading ...
Sorry, an error occurred while loading the content.

3252parsing undeclared array / patch proposal

Expand Messages
  • wackerl@iatms11.iatm.tuwien.ac.at
    Dec 29, 2003
    • 0 Attachment
      it is apparently possible (though maybe not legal xml)
      to bild an array without declaring an arraytype.
      something like this chunk:
      <A>
      <B>x1</B>
      <B>x2</B>
      <B>x3</B>
      </A>
      but when this is fed to a SOAP::Lite server, only the
      last <B> element is put into the hash.

      [XML::Generator produces xml like this, XmlSpy does,...
      so it's a reality we have to cope with, i'd say]

      i dug into the source and found the line
      %$res = map {$self->decode_object($_)} @{$children || []};
      in SOAP::Deserializer::decode_value
      and replaced it with
      foreach my $child (@{$children || []})
      {
      my( $child_name, $child_data ) = $self->decode_object($child);
      if( !exists $res->{$child_name} )
      {
      #first entry; single entry
      $res->{$child_name} = $child_data;
      }
      elsif( ref($res->{$child_name}) eq 'ARRAY')
      {
      #third entry; adding to array
      push @{$res->{$child_name}}, $child_data;
      }
      else
      {
      #second entry; conversion from single to array
      $res->{$child_name} = [$res->{$child_name}, $child_data];
      }
      }
      which retains the array (and doesn't break to much else, i hope)

      here's my test suite
      send_file.pl just sends the file Beispiel.xml to afz_server.pl
      and prints the result.
    • Show all 2 messages in this topic