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

Question on 'Cannot encode... as hash, encode as map instead'

Expand Messages
  • Ron Murphy
    Hi, I have some code similar to sub foo { my $class = shift; my %hash; $hash{ } = emptyval ; $hash{ bbb }{ } = emptybbbval ; } This prints warnings like,
    Message 1 of 2 , Oct 14, 2002
    • 0 Attachment
      Hi,
       
      I have some code similar to
       
      sub foo
      {
          my $class = shift;
          my %hash;
          $hash{""} = "emptyval";
          $hash{"bbb"}{""} = "emptybbbval";
      }
       
      This prints warnings like,
       
      Cannot encode unnamed element as 'hash'. Will be encoded as 'map' instead
      Cannot encode 'value' element as 'hash'. Will be encoded as 'map' instead
       
      I see that values such as empty string do not conform to what XML wants as names, so that's fine.  The receiving SOAP::Lite client also grabs these mutated values just fine as hashes.
       
      My question is, what would be equivalent code I can write, in order to **encode these as map values in the first place?**  I'd rather write code that does not produce warnings (I don't want to disable warnings like these).
       
      If there is any documentation explaining this already, kindly point me to it.
       
      Thanks
      Ron
    • Paul Kulchenko
      Hi Ron, ... Pseudo-type map can be used: SOAP::Data- type(map = { = foo}); you shouldn t have varning in this case. Best wishes, Paul. ...
      Message 2 of 2 , Oct 14, 2002
      • 0 Attachment
        Hi Ron,

        > My question is, what would be equivalent code I can write, in order
        > to
        > **encode these as map values in the first place?** I'd rather
        Pseudo-type 'map' can be used:

        SOAP::Data->type(map => {"" => foo});

        you shouldn't have varning in this case.

        Best wishes, Paul.

        --- Ron Murphy <rmurphy@...> wrote:
        > Hi,
        >
        > I have some code similar to
        >
        > sub foo
        > {
        > my $class = shift;
        > my %hash;
        > $hash{""} = "emptyval";
        > $hash{"bbb"}{""} = "emptybbbval";
        > }
        >
        > This prints warnings like,
        >
        > Cannot encode unnamed element as 'hash'. Will be encoded as 'map'
        > instead
        > Cannot encode 'value' element as 'hash'. Will be encoded as 'map'
        > instead
        >
        > I see that values such as empty string do not conform to what XML
        > wants as
        > names, so that's fine. The receiving SOAP::Lite client also grabs
        > these
        > mutated values just fine as hashes.
        >
        > My question is, what would be equivalent code I can write, in order
        > to
        > **encode these as map values in the first place?** I'd rather
        > write code
        > that does not produce warnings (I don't want to disable warnings
        > like
        > these).
        >
        > If there is any documentation explaining this already, kindly point
        > me to
        > it.
        >
        > Thanks
        > Ron
        >


        __________________________________________________
        Do you Yahoo!?
        Faith Hill - Exclusive Performances, Videos & More
        http://faith.yahoo.com
      Your message has been successfully submitted and would be delivered to recipients shortly.